jefffhaynes / XBee

A .NET library for XBee wireless controllers
MIT License
40 stars 17 forks source link

How to Get into API Mode programmatically? #45

Closed PaulHeitkemper closed 6 years ago

PaulHeitkemper commented 6 years ago

Seems like a bootstrapping problem. Is there a way to talk to a local XBee device via serial port to do what XCTU does to set API Mode?

jefffhaynes commented 6 years ago

Yeah I was thinking about this recently. It is a bootstrapping problem but I can work on it.

— If you want to build a ship, don't drum up people to collect wood and don't assign them tasks and work, but rather teach them to long for the endless immensity of the sea.

Antoine de Saint-Exupery


From: PaulHeitkemper notifications@github.com Sent: Monday, February 26, 2018 3:37:23 PM To: jefffhaynes/XBee Cc: Subscribed Subject: [jefffhaynes/XBee] How to Get into API Mode programmatically? (#45)

Seems like a bootstrapping problem. Is there a way to talk to a local XBee device via serial port to do what XCTU does to set API Mode?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/45, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR3dYOBN3lpG7Ep1xqR1rLzaUasCdks5tYxX2gaJpZM4ST4qz.

PaulHeitkemper commented 6 years ago

Is this the right answer? I won't be looking into it for several days.

https://www.digi.com/support/forum/66685/digimesh-how-to-enter-api-mode?show=66685#q66685

jefffhaynes commented 6 years ago

Yes, that’s how you enter it. I was trying to come up with a way to detect that it needed to be switched but maybe that doesn’t make sense. If it’s just a method call then that’s easy.

— If you want to build a ship, don't drum up people to collect wood and don't assign them tasks and work, but rather teach them to long for the endless immensity of the sea.

Antoine de Saint-Exupery


From: PaulHeitkemper notifications@github.com Sent: Monday, February 26, 2018 4:19:52 PM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] How to Get into API Mode programmatically? (#45)

Is this the right answer? I won't be looking into it for several days.

https://www.digi.com/support/forum/66685/digimesh-how-to-enter-api-mode?show=66685#q66685

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/45#issuecomment-368654284, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR_sk-HrxTEMfnwqaoZy5RRmnU80tks5tYx_4gaJpZM4ST4qz.

PaulHeitkemper commented 6 years ago

Can you just read the AP value to see if it is 0, or are you talking about something else? In the serial console in XCTU, I get the following:

+++OK

ATAP 1

jefffhaynes commented 6 years ago

Well I think that’s the rub. You can but do you read it with API mode or not?

— If you want to build a ship, don't drum up people to collect wood and don't assign them tasks and work, but rather teach them to long for the endless immensity of the sea.

Antoine de Saint-Exupery


From: PaulHeitkemper notifications@github.com Sent: Tuesday, February 27, 2018 9:34:52 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] How to Get into API Mode programmatically? (#45)

Can you just read the AP value to see if it is 0, or are you talking about something else? In the serial console in XCTU, I get the following:

+++OK

ATAP 1

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/45#issuecomment-368897708, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR9JhWspVopyk6300lJlJ5iD8q45iks5tZBKMgaJpZM4ST4qz.

PaulHeitkemper commented 6 years ago

I was able to issue the following commands from the serial console inside XCTU.

+++OK ATAP 0 ATAP1 OK ATWR OK ATAP 1 ATAP0 OK ATWR OK

jefffhaynes commented 6 years ago

Gotcha. Ok, that should work.

— If you want to build a ship, don't drum up people to collect wood and don't assign them tasks and work, but rather teach them to long for the endless immensity of the sea.

Antoine de Saint-Exupery


From: PaulHeitkemper notifications@github.com Sent: Tuesday, February 27, 2018 4:08:02 PM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] How to Get into API Mode programmatically? (#45)

I was able to issue the following commands from the serial console inside XCTU.

+++OK ATAP 0 ATAP1 OK ATWR OK ATAP 1 ATAP0 OK ATWR OK

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/45#issuecomment-369026427, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR29wPKg2TZyUaY06aAKk9ZybsHzxks5tZG6ygaJpZM4ST4qz.

jefffhaynes commented 6 years ago

Are you ok if I just set API mode on controller open? It's probably the easiest since after that the handlers take over and I can't easily inject textual AT commands

PaulHeitkemper commented 6 years ago

seems fine. I plan to use them all in API Mode anyway.

Or you could have a different device type to talk to module not in serial mode. Once it's in API mode, one could dispose that object and begin using the API as always.

jefffhaynes commented 6 years ago

Done. Core 1.6 will automatically switch controllers into API mode when opened. However, note that it will not persist the settings. Once in API mode you can use the normal Set/GetApiModeAsync methods to manage it along with WriteAsync().

PaulHeitkemper commented 6 years ago

Thanks!