Skip to content

Commit

Permalink
[Telink] [WIP] Full commissioning with retention
Browse files Browse the repository at this point in the history
  • Loading branch information
andriy-bilynskyy committed Oct 10, 2023
1 parent 8905974 commit afb9966
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 35 deletions.
6 changes: 4 additions & 2 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ config SYSTEM_WORKQUEUE_STACK_SIZE
default 616 if PM

config HEAP_MEM_POOL_SIZE
default 256
default 256

config COMMON_LIBC_MALLOC_ARENA_SIZE
default 9216

config NET_IPV6_MLD
default n
Expand Down Expand Up @@ -306,5 +309,4 @@ config PWM_SHELL

config OPENTHREAD_SHELL
default n

endif
26 changes: 25 additions & 1 deletion src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ using chip::app::DataModel::MakeNullable;
using chip::app::DataModel::Nullable;
using chip::app::DataModel::NullNullable;

#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

static void reboot_timer_handler(struct k_timer * dummy)
{
extern const uint8_t __rom_region_end;
void (*boot_thread_mode)(void) = (void (*)(void)) &__rom_region_end;

printk("** Reboot to Thread mode %p\n", boot_thread_mode);

boot_thread_mode();
}

static K_TIMER_DEFINE(reboot_timer, reboot_timer_handler, NULL);

static void delayed_sys_reboot(unsigned int timeout_ms)
{
k_timer_start(&reboot_timer, K_MSEC(timeout_ms), K_FOREVER);
}

#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

namespace {

// As per specifications (Section 13.3), Nodes SHALL exit commissioning mode after 20 failed commission attempts.
Expand All @@ -57,7 +78,7 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv
{
if (event->Type == DeviceLayer::DeviceEventType::kCommissioningComplete)
{
ChipLogProgress(AppServer, "Commissioning completed successfully");
ChipLogProgress(AppServer, "Commissioning completed successfully!!!");
DeviceLayer::SystemLayer().CancelTimer(HandleCommissioningWindowTimeout, this);
mCommissioningTimeoutTimerArmed = false;
Cleanup();
Expand All @@ -66,6 +87,9 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv
#if CONFIG_NETWORK_LAYER_BLE
mServer->GetBleLayerObject()->CloseAllBleConnections();
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
delayed_sys_reboot(1000);
#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
}
else if (event->Type == DeviceLayer::DeviceEventType::kFailSafeTimerExpired)
{
Expand Down
21 changes: 5 additions & 16 deletions src/platform/telink/tlsr9528a.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,14 @@
/delete-node/ partition@f0000;
/delete-node/ partition@f4000;
/delete-node/ partition@fe000;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0x19000>;
};
slot0_partition: partition@19000 {

slot0_partition: partition@0 {
label = "image-0";
reg = <0x19000 0xee000>;
reg = <0x000000 0x180000>;
};
factory_partition: partition@107000 {
label = "factory-data";
reg = <0x107000 0x1000>;
};
storage_partition: partition@108000 {
storage_partition: partition@180000 {
label = "storage";
reg = <0x108000 0x8000>;
};
slot1_partition: partition@110000 {
label = "image-1";
reg = <0x110000 0xee000>;
reg = <0x180000 0x8000>;
};
vendor_partition: partition@1fe000 {
label = "vendor-data";
Expand Down
21 changes: 5 additions & 16 deletions src/platform/telink/tlsr9528a_retention.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,14 @@
/delete-node/ partition@f0000;
/delete-node/ partition@f4000;
/delete-node/ partition@fe000;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0x19000>;
};
slot0_partition: partition@19000 {

slot0_partition: partition@0 {
label = "image-0";
reg = <0x19000 0xee000>;
reg = <0x000000 0x180000>;
};
factory_partition: partition@107000 {
label = "factory-data";
reg = <0x107000 0x1000>;
};
storage_partition: partition@108000 {
storage_partition: partition@180000 {
label = "storage";
reg = <0x108000 0x8000>;
};
slot1_partition: partition@110000 {
label = "image-1";
reg = <0x110000 0xee000>;
reg = <0x180000 0x8000>;
};
vendor_partition: partition@1fe000 {
label = "vendor-data";
Expand Down

0 comments on commit afb9966

Please sign in to comment.