The CSRMesh 1.3 Light example application has a feature to remove association by pressing on the SW2 switch on the development board. I have tested this and it works fine.
My question now is, how do I go about implementing this feature to remove association on the CSRMesh 1.3 Switch example application? I tried to use the same method, but it just doesnt want to unassociate. The only way to remove association is to delete the device from the app so that it can be discovered again.
If say the switch device is associated to my android phone app and I lose my phone. There is no way I can unassociate the switch device anymore. That is why I need to implement a manual way to unassociate the switch device by pressing on a button on the device.
These are the codes I used:
/* Move device to dissociated state */
g_switchapp_data.assoc_state = app_state_not_associated;
/* Clear the assigned groups and save it to NVM */
/* Light model */
MemSet(dst_id_list, 0x0000, sizeof(dst_id_list));
Nvm_Write((uint16 *)dst_id_list, sizeof(dst_id_list),
/* Reset Watchdog Model data. */
#endif /* ENABLE_WATCHDOG_MODEL */
/* Enable promiscuous mode on un-associated devices so that they
* relay all the messages. This helps propagate messages(MCP) based
* on the newly assigned network key as they will be relayed also by
* the devices not yet associated.
(BLE_BEARER_MASK | BLE_GATT_SERVER_BEARER_MASK);
/* Update Bearer Model Data to NVM */
/* Start Mesh association again */
When I press the button, the above is executed and the initiateAssociation function is called. The led blinks to indicate that it is unassociated. However, I cannot discover the device on my phone app. Also, if I remove power from the device and power it up again, the led does not blink anymore.
Can anyone help on this?
call this api CSRmeshResult CSRmeshRemoveNetwork(CsrUint8 netId) to remove network information and then do a warm reset