Skip to content

Commit

Permalink
Leave network if the device type changed (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminiuga authored Jan 28, 2025
1 parent d87a3e4 commit 6549ab9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions MLight/mods/device-nwk-join-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,26 @@ void emberAfPluginNetworkSteeringCompleteCallback(EmberStatus status,
*/
EmberNetworkStatus dnjcInit(void)
{
tokTypeStackNodeData networkData;

if ( ! dnjcState.isInitialized ) {
dnjcState.isInitialized = true;

memset(&networkData, 0xFF, sizeof(networkData));
halCommonGetToken(&networkData, TOKEN_STACK_NODE_DATA);
sl_zigbee_app_debug_println(
"Network token node type: 0x%02x, Firmware note type: 0x%02x",
networkData.nodeType,
SLI_ZIGBEE_PRIMARY_NETWORK_DEVICE_TYPE
);
if ( networkData.nodeType && networkData.nodeType
!= SLI_ZIGBEE_PRIMARY_NETWORK_DEVICE_TYPE
&& networkData.nodeType < SLI_ZIGBEE_NETWORK_DEVICE_TYPE_END_DEVICE
&& SLI_ZIGBEE_PRIMARY_NETWORK_DEVICE_TYPE < SLI_ZIGBEE_NETWORK_DEVICE_TYPE_END_DEVICE ) {
// nodeType is set, so it is joined the network.
// Check if we need to leave the network: stay only if SED or ED
_post_indicate_leaving_nwk();
}
sl_zigbee_event_init(&dnjcState.dnjcEvent, _event_handler);
sl_zigbee_event_set_delay_ms(&dnjcState.dnjcEvent, DNJC_STARTUP_STATUS_DELAY_MS);
dnjcState.smPostTransition = _event_state_indicate_startup_nwk;
Expand Down

0 comments on commit 6549ab9

Please sign in to comment.