jefffhaynes / XBee

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

How to add a Sleeping End Node to the Controller #11

Closed PaulNoto closed 8 years ago

PaulNoto commented 8 years ago

Since Sleeping End Nodes won't show up during Network Discovery, I have to add them to the Controller manually. I didn't find any reference to this in the ReadMe file. After your last change to the Library, the way I was doing it stopped working. The Only way I was able to figure out, now, was to make a change to the Source Code, by making XBeeController.CreateNode Public. That allows me to add a Sleeping End Node after Network Discovery and also it's Event Handler.

await controller.DiscoverNetwork();

AddLog( "END network discovery" );

AddLog( "Adding Node End_Grove" );

endGrove = await Task.FromResult( controller.CreateNode( HardwareVersion.XBee24C, new NodeAddress( new LongAddress( ulong.Parse( "0013A20040F7829A", System.Globalization.NumberStyles.HexNumber ) ), new ShortAddress( ushort.Parse( "0A90", System.Globalization.NumberStyles.HexNumber ) ) ) ) );

endGrove.SampleReceived += ( node, sample ) => AddLog( cntr1++.ToString() + " " + DateTime.Now.ToShortTimeString() + " End_Grove Sample: " + sample.DigitalSampleState.ToString() );

AddLog( "End_Grove Added to controller" );

Is there a way to do this that I didn't find?

jefffhaynes commented 8 years ago

Can you just call GetNodeAsync on the controller?

On Sun, Apr 24, 2016 at 2:38 PM -0700, "PaulNoto" notifications@github.com wrote:

Since Sleeping End Nodes won't show up during Network Discovery, I have to add them to the Controller manually. I didn't find any reference to this in the ReadMe file. After your last change to the Library, the way I was doing it stopped working. The Only way I was able to figure out, now, was to make a change to the Source Code, by making XBeeController.CreateNode Public. That allows me to add a Sleeping End Node after Network Discovery and also it's Event Handler.

await controller.DiscoverNetwork();

AddLog( "END network discovery" );

AddLog( "Adding Node End_Grove" );

endGrove = await Task.FromResult( controller.CreateNode( HardwareVersion.XBee24C, new NodeAddress( new LongAddress( ulong.Parse( "0013A20040F7829A", System.Globalization.NumberStyles.HexNumber ) ), new ShortAddress( ushort.Parse( "0A90", System.Globalization.NumberStyles.HexNumber ) ) ) ) );

endGrove.SampleReceived += ( node, sample ) => AddLog( cntr1++.ToString() + " " + DateTime.Now.ToShortTimeString() + " End_Grove Sample: " + sample.DigitalSampleState.ToString() );

AddLog( "End_Grove Added to controller" );

Is there a way to do this that I didn't find?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

PaulNoto commented 8 years ago

That is what I was doing before the last change to your library. Now, I get an Unhandled Timeout exception.

jefffhaynes commented 8 years ago

Oh, of course. It's trying to get the specific version of the remote node. Ok, I'll fix it. 

On Sun, Apr 24, 2016 at 3:22 PM -0700, "PaulNoto" notifications@github.com wrote:

That is what I was doing before the last change to your library. Now, I get an Unhandled Timeout exception.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub

PaulNoto commented 8 years ago

Tested. I can add sleeping end nodes using GetNodeAsync( Address, HardwareVersion ). Thanks Jeff.