I have a CC2531 USB Evaluation Kit connected to the USB port on my BeagleBoneBlack (BBB). I also have two zigbee end-devices within the surroundings of my BBB which are expected to join the network once opened. When the following code
const ccznp = require('cc-znp');
const spCfg = {
path: '/dev/ttyACM0',
options: {
baudrate: 115200,
flowControl: true,
rtscts: true
}
};
ccznp.on('ready', () => {
console.log('Device is ready.');
ccznp.sapiRequest('startRequest', {}, () => {
});
ccznp.sapiRequest('permitJoiningRequest', {destination: 0xFFFC, timeout: 0xAA}, (error, result) => {
if (error) {
throw error;
}
// Verify the results
console.log(result);
});
});
ccznp.on('AREQ', (data) => {
console.dir(data);
});
ccznp.init(spCfg, (error) => {
console.log(error);
});
ccznp.on('close', function() {
console.log('Serial port closed.');
});
is run, I get the following error:
Error: request timeout
at ccznp.sapiRequest (.../test.js:82:23)
at CcZnp.<anonymous> (.../node_modules/cc-znp/lib/ccznp.js:190:13)
at CcZnp.g (events.js:286:16)
at emitOne (events.js:96:13)
at CcZnp.emit (events.js:188:7)
at Timeout.<anonymous> (.../node_modules/cc-znp/lib/ccznp.js:170:18)
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)
After running the script again several times (at least 6 times), the error suddenly disappears and I get the following results:
{
sof: 254,
len: 1,
type: 'SRSP',
subsys: 'SAPI',
cmd: 'permitJoiningRequest',
payload: { status: 0 },
fcs: 111,
csum: 111
}
After getting the results finally, if I run the same script again it just hangs until I stop it with CRTL+C!
It is worth noting that this procedure happens with all the other commands (e.g. UTIL_GET_DEVICE_INFO etc.) I try to call i.e. I must run the script several times, get the 'Error: request timeout' message above during each run, before it finally runs without any errors and yield the results.
Am I perhaps doing something wrong or is this a bug within the cc-znp package? I would be grateful if you can investigate this issue as soon as possible and let me know your feedback/solution.
Many thanks in advance.