In my application, I need to be able to associate devices to their controller. The devices use API Routers and the controllers use API coordinators. To always make sure the right device connects to the right controller, each coordinator is given a fixed PAN withing a known range. When the devices are first powered up, they don’t know which controller they belong to, and so they attempt to join each PAN in the range until they find a controller that a) exists and b) accepts them. In theory, this should be fairly simple. In practice, it has been quite a pain.
Originally, we ran an unencrypted network. The devices determined if they had joined a PAN by waiting for the Modem Status message after joining. If the Modem Status was 0x02, the device was joined. This never quite worked well, because quite often, the device would attempt to join the PAN, but the Modem Status would never come in. This became worse when we enabled encryption.
So, rather than look for the Modem Status message, I decided to be a bit more direct and use the AI command to read out the Association Indicator. This is where things get interesting.
Let’s say I have one coordinator and three devices. The coordinator is on PAN 0x1234, The first device attempts to join 0x1234 and succeeds (the AI command eventually returns 0x00). The next device now attempts to join 0x1234. While polling the AI command looking for joined, first I’ll see 0xFF (Scanning), but then I’ll see 0xAC (Secure join error - network security key received unsecured). A little later, I’ll receive 0x22 (Scan found no valid PANs based on SC and ID settings). A little later, 0xAC again, then 0x22. Eventually I’ll timeout and move on to the next PAN in the range. But, the device that was joined continues to operate normally. This means that it was able to join properly, but the next device was not. Eventually (sometimes hours later) the device will actually join.
My NJ option is set to always allow joins.
What could cause the 0xAC error? Why would one device connect and not another? Why will the same device eventually connect? Has anyone else seen this kind of thing, or do most people use automatic PAN selection or push button association techniques?
Any help would be appreciated.