RadioHead Packet Radio library?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
VisualEcho
Posts: 17
Joined: Mon Jul 04, 2016 7:49 pm
Location: Ann Arbor, Michigan
Contact:

RadioHead Packet Radio library?

Post by VisualEcho » Fri Jul 15, 2016 4:13 pm

( http://www.airspayce.com/mikem/arduino/RadioHead/ )

As much as I like the idea of porting as much code into MicroPython as possible, I have need of the RadioHead C++ library. I've been reading the forums for a few days, but I can't seem to find any example of a C++ library being compiled into the DFU or the best way to connect it up.

Very explicitly, I want to be able to "import radiohead", I would prefer to use the RFMesh manager, and I'll be talking to SX1276 LoRa radios (RF95 driver). I'm wishing I could just link the compiled library into microPython, with a few convenience c/c++ translation functions if needed. I know not everybody will like this idea, but I'm confused as to why nobody seems to have tried this library yet (or if my ability to search the innerwebs is failing miserably). The code seems extremely suited to this platform, but so far, only 'arduinolized'. If this is a taboo topic or there's a court order not to talk about it, my apologies.

Has anybody done this, are there any similar examples, and/or what am I needing to do this?

User avatar
dhylands
Posts: 3246
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: RadioHead Packet Radio library?

Post by dhylands » Fri Jul 15, 2016 4:35 pm

I think it should be possible, although I think it depends on the exact feature set of C++ which is used.

At the very least you'd need to create a C API, since MicroPython has no way of calling non-static C++ functions.

Then there are the internal plumbing details. You'd need to provide new/delete and perhaps support for exceptions. MicroPython using setjmp/longjmp for its own exception model, so if the C++ code used native exceptions then those would need to be dealt with somehow.

There are probably some other support functions needed, but I'm not sure what they are off the top of my head.

Currently MicroPython builds without libgcc. That will probably present some challenges for integrating C++ code.

danielm
Posts: 159
Joined: Mon Oct 05, 2015 12:24 pm

Re: RadioHead Packet Radio library?

Post by danielm » Sat Jul 16, 2016 9:02 am

I did some experiments with RFM95 back in February.

I slightly modified following library or some fork of it:
https://github.com/mayeranalytics/pySX127x

I made only initialization and RSSI measurement working, I did not try any communication as there was not any working LoRa gateway in my area at that time (now there is one) and I also returned to work on my laser 3D printer controller project.
pyboard_LoRa._small.jpg
pyboard_LoRa._small.jpg (134.34 KiB) Viewed 5270 times
Anyway, I suggest to wait few weeks what Pycom comes with as their LoPy board should use SX1272 chip, which should have almost the same SPI interface command set as RFM95. I got this information from some forums alhtough it is not confirmed on 100%. I hope that they will not just bake in some compiled code into the LoPy's FW but they will provide stand-alone MicroPython library for communication with SPI LoRa chips from HopeRF and Semtech.

I also pre-ordered a LoPy board to support their work at least a little bit. I hope the port will be running on generic ESP32's as well as the WiPy's port is running on generic CC3200 modules. What I like about LoPy's design is that it can be directly soldered to carrier board without breakout headers.

User avatar
VisualEcho
Posts: 17
Joined: Mon Jul 04, 2016 7:49 pm
Location: Ann Arbor, Michigan
Contact:

Re: RadioHead Packet Radio library?

Post by VisualEcho » Sat Jul 16, 2016 6:10 pm

Those answers are pretty much exactly what I needed. I know difficulties with C/C++ linkage, so as that hasn't happened with anything else yet, I know I don't quite have the skill to do that (without a lot of eye strain and aspirins). I hadn't seen the LoPy at all (hey, I also don't own a working television set), but I'm about to draw an Eagle part for an STM32F405LGBT6 and try some of that, halve my hardware footprint.

Looking further into code details of the RadioHead library, I think the logic for the mesh networking is the best and simplest I've seen, and changing over to Python won't be as hard, even for me, especially with those low level routines, THANK YOU. I also want to expand on it quite a bit, so this is probably best. I think I just made 6 weeks of work for myself right there (would be longer without your git code).

So much work to do... thank you for your input, gentlemen.

danielm
Posts: 159
Joined: Mon Oct 05, 2015 12:24 pm

Re: RadioHead Packet Radio library?

Post by danielm » Sat Jul 16, 2016 6:48 pm

Just to make myself clear the link I posted is a library for CPython. I downloaded it and modified it so it is able to init and read RSSI from the chip connected to MicroPython host.

I suggest to save your time and wait for what Pycom people will publish. I really hope it will be pure MicroPython library which can work on any MicroPython host with SPI interface together with both HopeRF and Semtech chips.

User avatar
VisualEcho
Posts: 17
Joined: Mon Jul 04, 2016 7:49 pm
Location: Ann Arbor, Michigan
Contact:

Re: RadioHead Packet Radio library?

Post by VisualEcho » Sun Jul 17, 2016 1:29 am

It's all good... more code examples the better, and I'm very much asking for help with something which you're familiar. Anything that avoids having to read the data sheet and hook hardware up to a digital delay oscilloscope is worth a lot of coding time. I haven't looked at how much work it might be to collapse the RadioHead mesh networking code C++ hierarchy into a tiny semi-stable atomic Python driver, so maybe more coffee and reading before I vamp somebody's nice logic. I'm not really that good with Python language yet, so I'll have to convert the data structures carefully for efficiency. This is not the greatest of my problems on this project, and I do have time to wait for a more elegant solution.

Terrence
Posts: 13
Joined: Thu Aug 18, 2016 6:40 pm

Re: RadioHead Packet Radio library?

Post by Terrence » Thu Aug 18, 2016 9:01 pm

Any update on this topic? I am also interested in the Radiohead lib on MicroPython.

Post Reply