Xbee set sleep mode and write changes through java

Hi, I have a java application configuring all my devices in my ZigBee network. That’s done through the coordinator sending remote AT commands to all devices.

I use the MyDiscoveryListener to get all my devices: List remotes = myXBeeNetwork.getDevices();

Then I use the setParameter command to modify the connected nodes. E.g. remotes.get(i).setParameter(“ID”, ID);

This works fine until the second to final setting: SM, cyclic sleep mode in my case: remotes.get(i).setParameter(“SM”, SM_E); When applying the SM it imediately goes to sleep so my final command WR (write changes to NVM) won’t apply: remotes.get(i).writeChanges();.

So if a reset occurs I’m never able to sustain the sleep mode in the node (END device). Through the XCTU/UART it’s working fine (+++ mode), but that would not be efficient configuring >50 nodes network…

I’m not able to find a solution in documents, web or in this forum, but if anyone has a solution or somewhere to look for a solution it would be perfect. Thanks!

When sending configuration control parameters using remote AT commands, it is a good practice to send your configuration parameters using the Remote Command Options byte set to 0x00. This way, you can send each configuration change command, and get the response, and when all configuration parameters have been sent, the parameters can be applied only at the end. Do this, by sending your last command with the Remote Configuration Command Option byte set to 0x02.

Otherwise, each remote AT command is being applied when it is received, which in your case, when the SM command is received, it immediately applies the SM setting, which causes the module to become and End device.

Thanks for your reply! This sounds like it’ll do the trick, and I’ll try it out asap.

First of all, Thank you for asking because I accidentally set SP and ST parameters the way that the device would sleep right after sending response and XCTU couldn’t discover the device since it would be in sleep mode. Only solution was to set those ST and SP via my java code and your question helped!

to answer your question, you need to specify values in form of byte[]. I am gonna share you this link in case you have hex values and want to convert them.