Closed koopermark closed 5 years ago
Hi, Any information on this would be greatly appreciated, I would gladly send a donation if you can help.
Sorry I’ve been swamped but I believe there is an XBeeAddress.Broadcast value you can use.
From: Mark Cooper notifications@github.com Sent: Tuesday, February 26, 2019 10:11 AM To: jefffhaynes/XBee Cc: Subscribed Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
Hi, Any information on this would be greatly appreciated, I would gladly send a donation if you can help.
— 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/56#issuecomment-467476000, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR_g3BWbqipu1giIwz5-tB9RPfCUqks5vRU6wgaJpZM4bEpG0.
No worries, on being busy ;-)
I am struggling to understand how to use it XBeeAddress.Broadcast after the following
XBeeController controller = controllers.First();
I think something like await controller.SendDataAsync, no?
From: Mark Cooper notifications@github.com Sent: Tuesday, February 26, 2019 11:56 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
No worries, on being busy ;-)
I am struggling to understand how to use it XBeeAddress.Broadcast after the following XBeeController controller = controllers.First();
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/56#issuecomment-467520762, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR0N9Vt-bm-Hm0WPeD7STAHcGdCgmks5vRWc4gaJpZM4bEpG0.
I was trying await controller.Local.TransmitDataAsync(Encoding.UTF8.GetBytes("Hello!"));
but i seem to get Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.ni.dll
Hm. How are you getting controllers?
From: Mark Cooper notifications@github.com Sent: Tuesday, February 26, 2019 1:50 PM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
I was trying await controller.Local.TransmitDataAsync(Encoding.UTF8.GetBytes("Hello!")); but i seem to get Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.ni.dll
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/56#issuecomment-467564140, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR1wQZ5q2gGOMOi_ELolmdihs1Lguks5vRYITgaJpZM4bEpG0.
Like this
`namespace test {
public sealed class StartupTask : IBackgroundTask
{
private BackgroundTaskDeferral deferral;
public async void Run(IBackgroundTaskInstance taskInstance)
{
//
// TODO: Insert code to perform background work
//
// If you start any asynchronous methods here, prevent the task
// from closing prematurely by using BackgroundTaskDeferral as
// described in http://aka.ms/backgroundtaskdeferral
//
Debug.WriteLine("Starting Connection");
deferral = taskInstance.GetDeferral();
List<XBeeController> controllers = await XBeeController.FindControllersAsync(9600);
XBeeController controller = controllers.First();
Debug.WriteLine("Connection Done");
await controller.Local.TransmitDataAsync(Encoding.UTF8.GetBytes("Hello!"));
}
}
}`
Looks right to me. That exception is fishy. It seems like a system device issue. Is there any message to go with it?
From: Mark Cooper notifications@github.com Sent: Tuesday, February 26, 2019 4:46 PM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
Like this
`namespace test {
public sealed class StartupTask : IBackgroundTask {
private BackgroundTaskDeferral deferral;
public async void Run(IBackgroundTaskInstance taskInstance)
{
//
// TODO: Insert code to perform background work
//
// If you start any asynchronous methods here, prevent the task
// from closing prematurely by using BackgroundTaskDeferral as
// described in http://aka.ms/backgroundtaskdeferral
//
Debug.WriteLine("Starting Connection");
deferral = taskInstance.GetDeferral();
List<XBeeController> controllers = await XBeeController.FindControllersAsync(9600);
XBeeController controller = controllers.First();
Debug.WriteLine("Connection Done");
await controller.Local.TransmitDataAsync(Encoding.UTF8.GetBytes("Hello!"));
}
}
}`
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/56#issuecomment-467627010, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR85DPI99yU2Xfwk67qDSl1BjT0zSks5vRaskgaJpZM4bEpG0.
I will check and let you know in the morning. Thank you for your help.
The error message I get is Can't send data to local device.
Oh of course. Maybe that should default to broadcast...
I guess there might not be a great way to broadcast right now, which is unfortunate. What happens if you do
await controller.GetNodeAsync(XBeeAddress.Broadcast, ... etc)
and then transmit data to that node?
From: Mark Cooper notifications@github.com Sent: Wednesday, February 27, 2019 6:01 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
The error message I get is Can't send data to local device.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/56#issuecomment-467819304, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKRyQi8LOweKstOx2lvJllWK7-oLu3ks5vRmV0gaJpZM4bEpG0.
I get - The name 'XBeeAddress' does not exist in the current context
If i change it to await controller.GetNodeAsync(LongAddress.Broadcast);
then I get - cannot convert from 'XBee.LongAddress' to 'XBee.NodeAddress'
Sorry, I only have my phone here. Can you construct a NodeAddress from a LongAddress?
From: Mark Cooper notifications@github.com Sent: Wednesday, February 27, 2019 7:40 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
I get - The name 'XBeeAddress' does not exist in the current context If i change it to await controller.GetNodeAsync(LongAddress.Broadcast);
then I get - cannot convert from 'XBee.LongAddress' to 'XBee.NodeAddress'
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/56#issuecomment-467847217, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR6LKu1qC8NLDy-NoBa1j09eqV2dwks5vRnzEgaJpZM4bEpG0.
I added the following ` XBeeNode localNode = controller.Local;
NodeAddress BroadcastNodeAddress = new NodeAddress(LongAddress.Broadcast);
Debug.WriteLine(BroadcastNodeAddress);
try
{
await controller.GetNodeAsync(BroadcastNodeAddress);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
try
{
await localNode.TransmitDataAsync(Encoding.UTF8.GetBytes("Hello!"));
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
` and get the following output 000000000000FFFF, FFFE Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.ni.dll Can't send data to local device.
You need to use the returned node.
var remoteNode = await controller.GetNodeAsync(BroadcastNodeAddress);
remoteNode.Transmit...
From: Mark Cooper notifications@github.com Sent: Wednesday, February 27, 2019 8:03 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
I added the following ` XBeeNode localNode = controller.Local;
NodeAddress BroadcastNodeAddress = new NodeAddress(LongAddress.Broadcast);
Debug.WriteLine(BroadcastNodeAddress);
try
{
await controller.GetNodeAsync(BroadcastNodeAddress);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
try
{
await localNode.TransmitDataAsync(Encoding.UTF8.GetBytes("Hello!"));
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
` and get the following output 000000000000FFFF, FFFE Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.ni.dll Can't send data to local device.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/56#issuecomment-467853815, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR_KqC5jNYfNkktZA0lmTKrJaSfSWks5vRoIegaJpZM4bEpG0.
ok so using the following
`NodeAddress BroadcastNodeAddress = new NodeAddress(LongAddress.Broadcast);
Debug.WriteLine(BroadcastNodeAddress);
var remoteNode = await controller.GetNodeAsync(BroadcastNodeAddress);
Debug.WriteLine(remoteNode);
try
{
await remoteNode.TransmitDataAsync(Encoding.UTF8.GetBytes("Hello!"));
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
Debug.WriteLine("Sent I guess");`
I get the following Connection Done 000000000000FFFF, FFFE XBee.Devices.XBeeSeries2 Sent I guess
There is noting showing in XCTU as being received so i'm not sure if it did - but there are no errors
scratch that last comment, reloaded XCTU and its working :-) :-) thank you soooo much
A face full of smiles and a tear in the eye
Phew. Glad to hear it :)
From: Mark Cooper notifications@github.com Sent: Wednesday, February 27, 2019 8:25:03 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
scratch that last comment, reloaded XCTU and its working :-) :-) thank you soooo much
A face full of smiles and a tear in the eye
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/56#issuecomment-467860422, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR5eTFem1axZ5aZ2GbmI7KsyVuM4rks5vRocvgaJpZM4bEpG0.
How can I repay your effort - buy you a beer / Pizza - PayPal donation
Ha, thanks. No need, it’s an enjoyable hobby for me.
I’ll probably look at making broadcast a little easier too. Seems confusing as designed.
From: Mark Cooper notifications@github.com Sent: Wednesday, February 27, 2019 9:42 AM To: jefffhaynes/XBee Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/XBee] Broadcast Message (#56)
How can I repay your effort - buy you a beer / Pizza - PayPal donation
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/XBee/issues/56#issuecomment-467887487, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR0JvaZEyuP95X7FTbnBOTGJjzHuoks5vRplqgaJpZM4bEpG0.
Thanks again, its very much appreciated.
Hi, Is there a way to broadcast a message so all modules receive it?
I am using XTCU to send messages and picking them up by using controller.DataReceived but I would like to be able to do it the other way round.
Send from the PI to XTCU (multiple xbee's connected) using broadcast so that each Xbee would receive a message - I will then handle the message and send back a response.
Kind Regards