This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
I posted a question which I can't find about an issue where I am trying to do what is done when the Collector is started and you hold BTN-2 to clear NVRAM which also clears ram since it is done when the device is first powered up. I need to do this similar thing in code and need to be able to clear ram. It is indicated as a bug to be fixed in a future release, but I need to do this now. Is there anyone that could point to where I may find the structures that I could clear myself?
Thanks,
Kevin
Hi Kevin,
if you call the function “Csf_clearAllNVItems();” after the device is started up it will erase the NV flash but the addresses of the joined devices still survive in RAM. After you reset the device the erase will take effect because when booting up the device cannot restore any addresses of previously connected devices. This is not a bug. If you want to disassociate devices you have two options:
1. You call the “Csf_clearAllNVItems();” and implement a procedure that restarts the device afterwards (timer?).
2. You can remove the devices at runtime following the example below.
If you want to remove devices at runtime I would suggest you to look into the example for removing a device. Therefore, you need to add at the beginning of the file “csf.c” in the collector project (application -> collector) the define:
#define TEST_REMOVE_DEVICE
After starting the network of the collector with BTN-1 you can then delete the first joined sensor by pressing BTN-1 again.
The implementation of it can be found in the function “removeTheFirstDevice()” (line 2697, csf.c).
The function call is implemented in line 754:
You can modify the removeFirstDevice function to remove all devices or the ones that you specify and call it where you need it in your code. This also ensures that the disassociated devices are not left orphaned.
Please let me know if you could remove the devices at runtime using one of the two suggested methods.
Kind regards,
Theo
Theo,
I was unable to get this to remove all the items. I still need to restart the collector side (maybe even the sensor) to get the two to pair up again on the network. The message I see is access denied. Do you know what the nature of that message is and how it relates to the network state?
Thanks,
Kevin
Hi Kevin,
which of the two explained approaches did you follow and how have you implemented it?
The message "access denied" occurs if the collectors NV flash was cleared and then rebooted. If following a sensor that was connected to the collectors previous network tries to connect to it (because it is not cleared and rebooted) the collector won't allow it to join its network as it can't remember it.
If you want to use "Csf_clearAllNVItems();" you must call it on the collector and the sensor and then reboot the devices.
I would really recommend you to look into the option of removing devices safely from the network following "removeTheFirstDevice()". If you use it to remove a sensor from the collector the sensor can afterwards join again a new network and is not left orphaned.
Kind regards,
Theo
Theo,
I used the removeTheFirstDevice() and still had the problem. Here is the calls I used when I want to remove the sensor from the network:
// Send a dis-associate message to the current paired device so it doesn't try to rejoin immediately after trying to pair with another device
Csf_sendDisassociateMsg(networkItems.item[0].devInfo.shortAddress);
// Network needs time to dissassociate
usleep(100000);
// Remove all the NV items for this network.
Csf_clearAllNVItems();
// Network needs time to clear items
usleep(100000);
// Remove the first device found in the device list.
removeTheFirstDevice();
// Network needs time to clear active connections
usleep(100000);
// Start the fast blinking
LED_startBlinking(ledHandle[CONFIG_LED_RIGHT], 250, LED_BLINK_FOREVER);
/* Tell the collector to start network */
formNwkAndUpdateUser();
/* Wake up the application thread when it waits for clock event */
sem_post(getCollectorSemaphore());
/* Open network */
openCloseNwkAndUpdateUser(true);
/* Wake up the application thread when it waits for clock event */
sem_post(getCollectorSemaphore());
Kevin
Hi Kevin,
to test only the removing of a sensor please remove all the function calls except the call to "removeTheFirstDevice();" and test again.
Once that works we can add back the rest of your functionality.
Thank you,
Theo