Home/Support/Support Forum/Micropython mode - Node announce

Micropython mode - Node announce

0 votes
Hi,

I'm trying to use micropython to program an xbee3, my goal being to join an existing network (the coordinator is a cc2531 / zigbee2mqtt) and publish a weight sensor reading periodically.

I am able to join the network just fine, but at that point zigbee-herdsman (which is the library used by zigbee2mqtt on the controller) starts the interview process, to try and discover the endpoints on the device.

And to my surprise, it looks like the xbee is answering those requests on it's own, at least partly :

```
Mar 01 12:45:28 ha npm[23269]: 2020-03-01T12:45:28.309Z zigbee-herdsman:adapter:zStack:znp:AREQ <-- ZDO - endDeviceAnnceInd - {"srcaddr":53423,"nwkaddr":53423,"ieeeaddr":"0x0013a20041b47f93","capabilities":128}
Mar 01 12:45:28 ha npm[23269]: 2020-03-01T12:45:28.309Z zigbee-herdsman:controller:log Device announce '0x0013a20041b47f93'

...

Mar 01 12:45:28 ha npm[23269]: 2020-03-01T12:45:28.700Z zigbee-herdsman:adapter:zStack:znp:AREQ <-- ZDO - nodeDescRsp - {"srcaddr":53423,"status":0,"nwkaddr":53423,"logicaltype_cmplxdescavai_userdescavai":2,"apsflags_freqband":64,"maccapflags":128,"manufacturercode":4126,"maxbuffersize":82,"maxintransfersize":255,"servermask":11264,"maxouttransfersize":255,"descriptorcap":0}
Mar 01 12:45:28 ha npm[23269]: 2020-03-01T12:45:28.701Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext []
Mar 01 12:45:28 ha npm[23269]: 2020-03-01T12:45:28.709Z zigbee-herdsman:controller:device Interview - got node descriptor for device '0x0013a20041b47f93'
```

The xbee board is announcing itself with a capability of 128.
Sometimes it's even announcing an endpoint :

```
Mar 01 12:41:59 ha npm[23269]: 2020-03-01T12:41:59.355Z zigbee-herdsman:adapter:zStack:znp:AREQ <-- ZDO - simpleDescRsp - {"srcaddr":56375,"status":0,"nwkaddr":56375,"len":8,"endpoint":230,"profileid":49413,"deviceid":1,"deviceversion":0,"numinclusters":0,"inclusterlist":[],"numoutclusters":0,"outclusterlist":[]}
Mar 01 12:41:59 ha npm[23269]: 2020-03-01T12:41:59.356Z zigbee-herdsman:adapter:zStack:unpi:parser --- parseNext []
Mar 01 12:41:59 ha npm[23269]: 2020-03-01T12:41:59.357Z zigbee-herdsman:controller:device Interview - got simple descriptor for endpoint '230' device '0x0013a20041b47f93'
Mar 01 12:41:59 ha npm[23269]: 2020-03-01T12:41:59.366Z zigbee-herdsman:adapter:zStack:znp:SREQ --> ZDO - simpleDescReq - {"dstaddr":56375,"nwkaddrofinterest":56375,"endpoint":232}
```

Here it's saying it got an endpoint descriptor for 230, somehow.

Is there any documentation about why this is happening, and how to control what is being announced ?

I'm trying to figure out how to get it to be a simple end device, used only to publish one number to the coordinator from time to time, and that without an external CPU, my goal is to have all the logic directly in /flash/main.py so it's running in micropython mode only.

Thanks !
asked Mar 2 in XBee3 ZigBee by Ulrar New to the Community (2 points)
Hi Ulrar,

Have you managed to make any progress on this?  I am struggling with the same thing and would appreciate any additional info you have managed to uncover.
Hi, unfortunately I did not. AO 3 doesn't seem to change much, and I'm not sure on what I'm supposed to do. I wish I could find an example but it doesn't look like anyone published any code for xbee ..
At this rate this will end up running on an esp8266, at least that's very easy to pick up with all the code on GitHub :(
Ah sorry.  I will keep trying to find a solution and will let you know if I come up with anything useful
Hey, got some news on this, I've gotten a reply to my github issue asking for an example and apparently it's simply not supported yet by the firmware, which explains why I can't get it to work. See here : https://github.com/digidotcom/xbee-micropython/issues/37#issuecomment-614288855

Please log in or register to answer this question.

4 Answers

0 votes
Ulrar,

Have you looked at the product manual for the XBee yet? I would suggest starting there.

Yes, some of the active end point requests the radio will respond to directly as they are part of its responsibility. For your application, you will want to use API mode with Explicit frames and ZDO pass thru mode.

Digi Support
answered Mar 2 by mvut Veteran of the Digi Community (12,834 points)
Hi,

Do you mean setting AO to 3 ?
If yes, I did try that.

The only difference seems to be an extra xbee.receive(), one on profile 0 and one on profile 260, but on the controller's side I'm still seeing an automatic node announce and simple endpoint descriptor sent from xbee.

Or do you mean I should just ignore those automated responses and send packets announcing my own endpoint anyway ?
This seems to be the doc for the python module, which uses serial to communicate with xbee. I don't have anything connected to the serial pins, I'm trying to run the whole thing directly using micropython on the xbee board itself.

I tried setting AO to 3 and 4 already without success (or at least it's still responding automatically to the controller's discovery requests), which setting do you mean by "Explicit frames and ZDO pass thru mode" ? Do you mean 4 & 1 ?
In other words from micropython what should I pass as an argument to `xbee.atcmd("AO", ????)` ?

Thanks !
That's the doc for the receive command, which I did read. As mentioned in the original post I do receive one or two messages, depending on the setting of AO, but in all cases xbee responds to the discovery requests on it's own, regardless of what's in the receive queue.
Are we meant to ignore that and just transmit our own endpoint announcement anyway, on top of what xbee is automatically responding ?
Hi, according to zackyancey on this github issue I opened about this, the firmware simply doesn't support it yet, which explains it : https://github.com/digidotcom/xbee-micropython/issues/37#issuecomment-614288855
0 votes
Hi,

Do you mean setting AO to 3 ?
If yes, I did try that.

The only difference seems to be an extra xbee.receive(), one on profile 0 and one on profile 260, but on the controller's side I'm still seeing an automatic node announce and simple endpoint descriptor sent from xbee.

Or do you mean I should just ignore those automated responses and send packets announcing my own endpoint anyway ?
answered Mar 5 by Ulrar New to the Community (2 points)
0 votes
Hey, got some news on this, I've gotten a reply to my github issue asking for an example and apparently it's simply not supported yet by the firmware, which explains why I can't get it to work. See here : https://github.com/digidotcom/xbee-micropython/issues/37#issuecomment-614288855
answered Apr 17 by Ulrar New to the Community (2 points)
Finally got this working!
I copied and ported a fair amount of code from [zigpy] (https://github.com/zigpy/zigpy) to manage the zigbee protocol.  I ran into two problems when I initially ported:
- I ran out of memory on the xbee
- Some of the python libraries used by zigpy aren't in micropython (especially lib/enum).

As a result, I butchered the library to get it working and in many cases just reverted to hard coding numeric encodings - which doesn't help readability.

I might take a stab at doing a proper port of relevant parts of the library at a later stage.

At the moment, I have it working with Home Assistant.  Home Assistant sends two general commands that I am not handling (0x06, Configure Reporting and 0x0B, Default Response when I report attributes).  I will keep chipping away at those.

I have added what I have done to github and will update any new changes as I make them:
(https://github.com/petertrain/xbee3-i2c-relay)
Hey,

This is great, I've almost got it working on my side. Unfortunately I'm using zigbee2mqtt which seems to require a bit more than pure HA, and trying to implement the genBasic attributes (in particular the model ID that zigbee2mqtt uses to match a controller) I'm running out of space on the module.

I've been trying to make the code shorter and shorter but I haven't been able to make it run since I added handling for those attributes, which I imagine happened to you too.
I might try controlling the module from a separate micro controller with a bit more memory if this doesn't pan out, but it's a bit frustrating to be so close and fail because of a few extra lines of code :(
0 votes
Thanks for the update.

Would have been good if documentation made this more explicit!

Anyway, after waiting this long, end April doesn't feel like long to wait for a new version of firmware that supports the feature

Weird thing, is I did try to use serial console in XCTU to see if different network packets were reported when "AP=API Mode..." instead of "AP=MicroPython...". I thought I was seeing the same packets arriving on both. Anyway, will be good to see new version of the firmware.
answered Apr 20 by petertrain New to the Community (1 point)
...