diff --git a/main/include/OpenThreadConfig.h b/main/include/OpenThreadConfig.h index 276669c0..badf22f7 100644 --- a/main/include/OpenThreadConfig.h +++ b/main/include/OpenThreadConfig.h @@ -31,7 +31,10 @@ #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_APP // Turn on a moderate level of logging in OpenThread -#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_NOTE +#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG + +// Turn on Nordic platform logs +#define OPENTHREAD_CONFIG_LOG_PLATFORM 1 // Use the Nordic-supplied default platform configuration for remainder // of OpenThread config options. @@ -41,6 +44,29 @@ // #include "openthread-core-nrf52840-config.h" +// ============================================================== +// CONFIG TOBLE +// ============================================================== +#define OPENTHREAD_CONFIG_ENABLE_TOBLE 1 + +#define OPENTHREAD_CONFIG_ENABLE_BLE 1 +#define OPENTHREAD_CONFIG_ENABLE_TOBLE_TO_BLE 1 +#define OPENTHREAD_CONFIG_TOBLE_CENTRAL_ENABLE 0 +#define OPENTHREAD_CONFIG_TOBLE_PERIPHERAL_ENABLE 1 +#define OPENTHREAD_CONFIG_TOBLE_MULTI_RADIO_ENABLE 1 +#define OPENTHREAD_CONFIG_TOBLE_154_ATTACH_ATTEMPT_RATIO 2 + +#define OPENTHREAD_DISABLE_TOBLE_GATT_ACKNOWLEDGEMENTS 0 + +#define OPENTHREAD_CONFIG_MAC_DATA_POLL_RESPONSE_TIMEOUT 500 +#define OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT 60 + +#define OPENTHREAD_CONFIG_MLE_PARENT_REQUEST_ROUTER_TIMEOUT 1500 +#define OPENTHREAD_CONFIG_MLE_PARENT_REQUEST_REED_TIMEOUT 3000 +#define OPENTHREAD_CONFIG_MLE_UNICAST_RETRANSMISSION_DELAY 1500 +#define OPENTHREAD_CONFIG_MLE_CHILD_ID_REQUEST_TIMEOUT 10000 + + #endif // OPENTHREAD_PLATFORM_CONFIG_H diff --git a/main/include/WeaveProjectConfig.h b/main/include/WeaveProjectConfig.h index 9647452f..d2ae7f70 100644 --- a/main/include/WeaveProjectConfig.h +++ b/main/include/WeaveProjectConfig.h @@ -28,6 +28,8 @@ #ifndef WEAVE_PROJECT_CONFIG_H #define WEAVE_PROJECT_CONFIG_H +#define WEAVE_PROGRESS_LOGGING 1 + /** * WEAVE_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY * diff --git a/main/main.cpp b/main/main.cpp index b323d566..baf14d5e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -72,6 +72,8 @@ using namespace ::nl::Weave::DeviceLayer; extern "C" size_t GetHeapTotalSize(void); +static void DeviceEventHandler(const WeaveDeviceEvent * event, intptr_t arg); + // ================================================================================ // Logging Support // ================================================================================ @@ -239,6 +241,10 @@ int main(void) APP_ERROR_HANDLER(ret); } + // Register a function to receive events from the Weave device layer. Note that calls to + // this function will happen on the Weave event loop thread, not the app_main thread. + PlatformMgr().AddEventHandler(DeviceEventHandler, 0); + NRF_LOG_INFO("Initializing OpenThread stack"); otSysInit(0, NULL); @@ -285,6 +291,19 @@ int main(void) } } + // Disable Weave Pairing if Thread network has already been provisioned. + // TODO: Change this to only disable WoBLE when *full provisioning* has completed, + // i.e. ConfigurationManager.IsPairedToAccount() + if (ConnectivityMgr().IsThreadProvisioned()) + { + ConnectivityMgr().SetBLEAdvertisingEnabled(false); + NRF_LOG_INFO("WoBLE pairing is disabled, as Thread is provisioned"); + } + else + { + NRF_LOG_INFO("WoBLE pairing is enabled"); + } + NRF_LOG_INFO("Starting Weave task"); ret = PlatformMgr().StartEventLoopTask(); @@ -329,3 +348,18 @@ int main(void) NRF_LOG_INFO("vTaskStartScheduler() failed"); APP_ERROR_HANDLER(0); } + +/* Handle events from the Weave Device layer. + * + * NOTE: This function runs on the Weave event loop task. + */ +void DeviceEventHandler(const WeaveDeviceEvent * event, intptr_t arg) +{ + if (event->Type == DeviceEventType::kSessionEstablished && + event->SessionEstablished.IsCommissioner) + { + // Disable advertising when Commissioner connected over WoBLE + // so ToBLE connectivity checks can occur. + ConnectivityMgr().SetBLEAdvertisingEnabled(false); + } +} diff --git a/third_party/openthread b/third_party/openthread index 2279ef61..78f06027 160000 --- a/third_party/openthread +++ b/third_party/openthread @@ -1 +1 @@ -Subproject commit 2279ef610eef80597bd789611d6931b95e08bf48 +Subproject commit 78f06027f21fdcd3710e6bf95d4da44cc2077cc3 diff --git a/third_party/openweave-core b/third_party/openweave-core index 645007fb..b513692f 160000 --- a/third_party/openweave-core +++ b/third_party/openweave-core @@ -1 +1 @@ -Subproject commit 645007fb66e08a85e030d5487732f3f9394ee403 +Subproject commit b513692fb1b5eadb9903faf38ebf2ae7b5a9eed4