XBee Toolkit that supports API in W10 IoT?

HI All;

So I’m pretty basic at coding. In my previous kick at my project idea I was using a Cerberus and the MFToolkit’s XBee library:

https://mftoolkit.codeplex.com/SourceControl/latest#Zigbee/XBee.cs

It worked well, and I needed it because I use the remote XBee in IO mode to gather readings, which requires the co-ordinator to be in API mode to get data back off the pins. I was able to use the MicroXBee library with the Cerberus and get the data I needed.

With my move to try and implement things on W10 IoT, I’ve come to realize there’s a fundamental shift in serial device access that breaks the library. When I look at examples like in HelloZigBee/MainPage.xaml.cs at master · falafelsoftware/HelloZigBee · GitHub I see that instead of naming a COM port, you enumerate the serial devices and get an ID that is then used to access the serial device.

Unfortunately while I can find sample code for basic TX/RX in AT mode, but I have yet to find a library that could be used like the MFToolkit one but with W10 IoT. Has anyone else seen one?

How about modifying the MFTOOLKIT to do what you need?

With the new Devices namespace in Win10 we’re going to see a flurry of new drivers for all kinds of gadgets coming from manufacturers, particularly in the IoT space. The transport layer on the GBee library is isolated from the API command objects, so it should be straightforward to port it. Caveat - I’m saying that without doing any research on the topic.

I haven’t seen any other open source libraries yet, but have not looked that hard. Try asking on the XBee forums.

Modding was my second choice after finding something ready to go, given my experience with C#. That said, I’ll give it a shot!

I’ve updated @ ransomhall’s GBee library and added Win10 support, but I still have a bunch of files checked out wrt the Win10 support (I was in the middle of testing it and got distracted). If this is of interest, I can look into finishing it around Dec 1. The source (as it currently stands) is at : GitHub - VerdantAutomation/GBee: Update and Port of the GBee support libraries for XBee/Zigbee devices

I believe that the current status is that it is fully updated for netmf 4.3, but I haven’t finished with the Win10 support (I seem to have a dozen or so files still checked out, and I recall I was testing it on my RPi).

2 Likes

@ mcalsyn - Oh I would very much like that!

Mike

@ mcalsyn - Is the hardware setup for the XBee on the Win10 Pi a direct pin mapping, one of GHI’s Pi shields, or some other UART?

Many thanks for bringing the GBee library back to the future (pun intended).

In my case it’s an XBee, on a Gadgeteer XBee module connected to a FEZ Cream. It connected directly to the serial pins and uses the RPi UART.

So… all of the above? :wink:

It should work on any serial channel supported by the RPi, and that includes the native hardware UART, UART exposed through GHI boards, and any USB-serial adapters (which is where I started before the UARTs were working).

My USB-Serial adapters arrived the day before they released a new W10 IoT with UART support.

Not to worry. You can never have too many USB-Serial adapters.

@ mcalsyn - Thought I’d wait a day after your ETA before asking “Are we there yet?” :wink:

1 Like

Yup - no worries. I finished the coding, but haven’t created the nuget wads yet. Unfortunately, it will probably be the weekend as I am running behind. Gotta keep the paying customers happy first :slight_smile: Peter and serial wifi 4.4 and mtylerjr and Scratch display support share your pain.

@ mcalsyn - Made the upgrade to 4.4 already in the PD namespace for Oxygen & Neon … so take your time, I’m OK so far …

1 Like

Yes, and well done! I’m glad I wasn’t holding you up. The main outstanding change for me was just to refactor everything so that I can now get 4.3 and 4.4 in a single build and a single nuget package. You will want to pick up the new code, though, once I declare victory on it and merge back into the mainline because there are other bug fixes.

1 Like

@ mcalsyn - No worries at all, I try and have nothing but patience for those who do awesome things that I benefit from.

1 Like

@ mcalsyn - But I do check in every couple of weeks. :wink:

Well, then I do have some good news. I have been working on it yesterday and today. I have an RPi2+Fez Cream+XBee Adapter (plus an adafruit display) all hooked up, running and forming a network. I am doing some testing and debugging now, and then I need to figure out how to package it all up alongside the other Fez Cream drivers. I probably have another good day of work to do.

It should also work with a USB serial adapter (and that’s where I started before UARTs worked), but I will probably drop a Fez Cream release first before going back and testing that interface further.

Awesome, can’t wait to be a tester!

Well, get cracking, because here it is.

To use with Universal apps on Win10 IoT:
Grab source from : [url]https://github.com/VerdantAutomation/GBee[/url]
Select target : ARM
Build
Create a new UWP program and include a reference to …\GBee\source\XBee.Universal\bin\ARM{flavor}\OpenSource.XBee.dll

Use this with Fez Cream and or raw RPi UARTs:

            string serialSelector = SerialDevice.GetDeviceSelector();
            var devices = await DeviceInformation.FindAllAsync(serialSelector);
            if (devices != null && devices.Count > 0)
            {
                var device = devices[0];
                var serport = await SerialDevice.FromIdAsync(device.Id);
                if (serport != null)
                {
                    serport.DataBits = 8;
                    serport.StopBits = SerialStopBitCount.One;
                    serport.Parity = SerialParity.None;
                    serport.BaudRate = 9600;

                    var xbee = new XBeeApi(serport);
                    xbee.Open();
// ... party on ...
                }
            }

And use this with USB serial adapters (you will have to modify this because devices will contain more than one serial device, and [0] may not be the right one):


            string serialSelector = SerialDevice.GetDeviceSelector();
            var devices = await DeviceInformation.FindAllAsync(serialSelector);
            if (devices != null && devices.Count > 0)
            {
                var device = devices[0];  // <=== select the correct device if there is more than one
                var serport = await SerialDevice.FromIdAsync(device.Id);
                if (serport != null)
                {
                    serport.IsDataTerminalReadyEnabled = true;
                    serport.IsRequestToSendEnabled = true;
                    serport.DataBits = 8;
                    serport.StopBits = SerialStopBitCount.One;
                    serport.Parity = SerialParity.None;
                    serport.BaudRate = 9600;

                    var xbee = new XBeeApi(serport);
                    xbee.Open();
// ... party on ...
                }

I have seen it hang, but then work when debugging is turned on, so if you see hangs, add this before the snippets above:

            Logger.Initialize(DebugPrint, LogLevel.Warn, LogLevel.Info, LogLevel.Debug, LogLevel.LowDebug, LogLevel.Error, LogLevel.Fatal);
            Logger.LoggingLevel = LogLevel.All;

I’ll get that debugged, and I will get this all packaged more nicely (as updated nuget packages for 4.2, 4.3 (plain and Gadgeteer), and for Fez Cream), but you should be able to get started with this.

1 Like