Skip to content

Commit

Permalink
[K32W0] Fix shell app
Browse files Browse the repository at this point in the history
* fix linkage error by disabling the ping functionality
* fix deadlock in Thread implementation
* fix printing by adding CR

This commit relates to project-chip#11346

Signed-off-by: Doru Gucea <[email protected]>
  • Loading branch information
doru91 committed Nov 23, 2021
1 parent 54ffcc8 commit d950620
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion examples/shell/nxp/k32w/k32w0/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ extern "C" void main_task(void const * argument)
}

// cmd_otcli_init();
cmd_ping_init();
//cmd_ping_init();
cmd_send_init();

shellTaskHandle = xTaskCreate(shell_task, "shell_task", shell_task_size / sizeof(StackType_t), NULL, shell_task_priority, NULL);
Expand Down
52 changes: 26 additions & 26 deletions src/lib/shell/commands/Dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ class DnsShellResolverDelegate : public Dnssd::ResolverDelegate
public:
void OnNodeIdResolved(const Dnssd::ResolvedNodeData & nodeData) override
{
streamer_printf(streamer_get(), "DNS resolve for " ChipLogFormatX64 "-" ChipLogFormatX64 " succeeded:\n",
streamer_printf(streamer_get(), "DNS resolve for " ChipLogFormatX64 "-" ChipLogFormatX64 " succeeded:\r\n",
ChipLogValueX64(nodeData.mPeerId.GetCompressedFabricId()), ChipLogValueX64(nodeData.mPeerId.GetNodeId()));
streamer_printf(streamer_get(), " Hostname: %s\n", nodeData.mHostName);
streamer_printf(streamer_get(), " IP address: %s\n", nodeData.mAddress.ToString(ipAddressBuf));
streamer_printf(streamer_get(), " Port: %" PRIu16 "\n", nodeData.mPort);
streamer_printf(streamer_get(), " Hostname: %s\r\n", nodeData.mHostName);
streamer_printf(streamer_get(), " IP address: %s\r\n", nodeData.mAddress.ToString(ipAddressBuf));
streamer_printf(streamer_get(), " Port: %" PRIu16 "\r\n", nodeData.mPort);

auto retryInterval = nodeData.GetMrpRetryIntervalIdle();

if (retryInterval.HasValue())
streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\n", retryInterval.Value());
streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\r\n", retryInterval.Value());

retryInterval = nodeData.GetMrpRetryIntervalActive();

if (retryInterval.HasValue())
streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\n", retryInterval.Value());
streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\r\n", retryInterval.Value());

streamer_printf(streamer_get(), " Supports TCP: %s\n", nodeData.mSupportsTcp ? "yes" : "no");
streamer_printf(streamer_get(), " Supports TCP: %s\r\n", nodeData.mSupportsTcp ? "yes" : "no");
}

void OnNodeIdResolutionFailed(const PeerId & peerId, CHIP_ERROR error) override {}
Expand All @@ -75,33 +75,33 @@ class DnsShellResolverDelegate : public Dnssd::ResolverDelegate
Encoding::BytesToUppercaseHexString(nodeData.rotatingId, nodeData.rotatingIdLen, rotatingId, sizeof(rotatingId));

streamer_printf(streamer_get(), "DNS browse succeeded: \n");
streamer_printf(streamer_get(), " Hostname: %s\n", nodeData.hostName);
streamer_printf(streamer_get(), " Vendor ID: %" PRIu16 "\n", nodeData.vendorId);
streamer_printf(streamer_get(), " Product ID: %" PRIu16 "\n", nodeData.productId);
streamer_printf(streamer_get(), " Long discriminator: %" PRIu16 "\n", nodeData.longDiscriminator);
streamer_printf(streamer_get(), " Hostname: %s\r\n", nodeData.hostName);
streamer_printf(streamer_get(), " Vendor ID: %" PRIu16 "\r\n", nodeData.vendorId);
streamer_printf(streamer_get(), " Product ID: %" PRIu16 "\r\n", nodeData.productId);
streamer_printf(streamer_get(), " Long discriminator: %" PRIu16 "\r\n", nodeData.longDiscriminator);
streamer_printf(streamer_get(), " Device type: %" PRIu16 "\n", nodeData.deviceType);
streamer_printf(streamer_get(), " Device name: %s\n", nodeData.deviceName);
streamer_printf(streamer_get(), " Commissioning mode: %d\n", static_cast<int>(nodeData.commissioningMode));
streamer_printf(streamer_get(), " Pairing hint: %" PRIu16 "\n", nodeData.pairingHint);
streamer_printf(streamer_get(), " Pairing instruction: %s\n", nodeData.pairingInstruction);
streamer_printf(streamer_get(), " Rotating ID %s\n", rotatingId);
streamer_printf(streamer_get(), " Device name: %s\r\n", nodeData.deviceName);
streamer_printf(streamer_get(), " Commissioning mode: %d\r\n", static_cast<int>(nodeData.commissioningMode));
streamer_printf(streamer_get(), " Pairing hint: %" PRIu16 "\r\n", nodeData.pairingHint);
streamer_printf(streamer_get(), " Pairing instruction: %s\r\n", nodeData.pairingInstruction);
streamer_printf(streamer_get(), " Rotating ID %s\r\n", rotatingId);

auto retryInterval = nodeData.GetMrpRetryIntervalIdle();

if (retryInterval.HasValue())
streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\n", retryInterval.Value());
streamer_printf(streamer_get(), " MRP retry interval (idle): %" PRIu32 "ms\r\n", retryInterval.Value());

retryInterval = nodeData.GetMrpRetryIntervalActive();

if (retryInterval.HasValue())
streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\n", retryInterval.Value());
streamer_printf(streamer_get(), " MRP retry interval (active): %" PRIu32 "ms\r\n", retryInterval.Value());

streamer_printf(streamer_get(), " Supports TCP: %s\n", nodeData.supportsTcp ? "yes" : "no");
streamer_printf(streamer_get(), " IP addresses:\n");
streamer_printf(streamer_get(), " Supports TCP: %s\r\n", nodeData.supportsTcp ? "yes" : "no");
streamer_printf(streamer_get(), " IP addresses:\r\n");
for (uint8_t i = 0; i < nodeData.kMaxIPAddresses; i++)
{
if (nodeData.ipAddress[i] != Inet::IPAddress::Any)
streamer_printf(streamer_get(), " %s\n", nodeData.ipAddress[i].ToString(ipAddressBuf));
streamer_printf(streamer_get(), " %s\r\n", nodeData.ipAddress[i].ToString(ipAddressBuf));
}
}

Expand All @@ -115,7 +115,7 @@ CHIP_ERROR ResolveHandler(int argc, char ** argv)
{
VerifyOrReturnError(argc == 2, CHIP_ERROR_INVALID_ARGUMENT);

streamer_printf(streamer_get(), "Resolving ...\n");
streamer_printf(streamer_get(), "Resolving ...\r\n");

PeerId peerId;
peerId.SetCompressedFabricId(strtoull(argv[0], NULL, 10));
Expand Down Expand Up @@ -175,11 +175,11 @@ CHIP_ERROR BrowseCommissionableHandler(int argc, char ** argv)

if (!ParseSubType(argc, argv, filter))
{
streamer_printf(streamer_get(), "Invalid argument\n");
streamer_printf(streamer_get(), "Invalid argument\r\n");
return CHIP_ERROR_INVALID_ARGUMENT;
}

streamer_printf(streamer_get(), "Browsing commissionable nodes...\n");
streamer_printf(streamer_get(), "Browsing commissionable nodes...\r\n");

return Dnssd::Resolver::Instance().FindCommissionableNodes(filter);
}
Expand All @@ -190,11 +190,11 @@ CHIP_ERROR BrowseCommissionerHandler(int argc, char ** argv)

if (!ParseSubType(argc, argv, filter))
{
streamer_printf(streamer_get(), "Invalid argument\n");
streamer_printf(streamer_get(), "Invalid argument\r\n");
return CHIP_ERROR_INVALID_ARGUMENT;
}

streamer_printf(streamer_get(), "Browsing commissioners...\n");
streamer_printf(streamer_get(), "Browsing commissioners...\r\n");

return Dnssd::Resolver::Instance().FindCommissioners(filter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1971,8 +1971,6 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnDnsBrowseResult(otEr
return;
}

ThreadStackMgrImpl().LockThreadStack();

VerifyOrExit(aError == OT_ERROR_NONE, error = MapOpenThreadError(aError));

error = MapOpenThreadError(otDnsBrowseResponseGetServiceName(aResponse, type, sizeof(type)));
Expand Down Expand Up @@ -2005,8 +2003,6 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnDnsBrowseResult(otEr

exit:

ThreadStackMgrImpl().UnlockThreadStack();

// In case no service was found invoke callback to notify about failure. In other case it was already called before.
if (!wasAnythingBrowsed)
ThreadStackMgrImpl().mDnsBrowseCallback(aContext, nullptr, 0, error);
Expand Down Expand Up @@ -2059,8 +2055,6 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnDnsResolveResult(otE
return;
}

ThreadStackMgrImpl().LockThreadStack();

VerifyOrExit(aError == OT_ERROR_NONE, error = MapOpenThreadError(aError));

error = MapOpenThreadError(otDnsServiceResponseGetServiceName(aResponse, resolveResult.mMdnsService.mName,
Expand All @@ -2081,7 +2075,6 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnDnsResolveResult(otE

exit:

ThreadStackMgrImpl().UnlockThreadStack();
ThreadStackMgrImpl().mDnsResolveCallback(aContext, &(resolveResult.mMdnsService), error);
}

Expand Down
2 changes: 2 additions & 0 deletions src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1
#define CHIP_DEVICE_CONFIG_ENABLE_DNSSD 1
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 1
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DISCOVERY 1

#endif
2 changes: 2 additions & 0 deletions third_party/k32w_sdk/nxp/k32w/k32w0/k32w0_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ template("k32w0_sdk") {
defines += [
"OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1",
"OPENTHREAD_CONFIG_ECDSA_ENABLE=1",
"OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE=1",
"OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1",
]
}

Expand Down

0 comments on commit d950620

Please sign in to comment.