Hi all,
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:
if(buttonpressed)
{
/* 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),
NVM_OFFSET_DST_ID_LIST);
#ifdef ENABLE_WATCHDOG_MODEL
/* Reset Watchdog Model data. */
AppWatchdogResetState();
#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.
*/
g_switchapp_data.bearer_data.bearerPromiscuous =
(BLE_BEARER_MASK | BLE_GATT_SERVER_BEARER_MASK);
CsrMeshEnablePromiscuousMode(
g_switchapp_data.bearer_data.bearerPromiscuous);
/* Update Bearer Model Data to NVM */
Nvm_Write((uint16 *)&g_switchapp_data.bearer_data,
sizeof(BEARER_MODEL_STATE_DATA_T), NVM_BEARER_DATA_OFFSET);
/* Start Mesh association again */
initiateAssociation();
}
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?
Regards,
Kian
call this api CSRmeshResult CSRmeshRemoveNetwork(CsrUint8 netId) to remove network information and then do a warm reset