NOW RESOLVED: Meshtastic Arduino Driver

I’d like to listen for key messages from my meshtastic network with an external ESP32 connected over wifi or bluetooth and thought I had struck gold when I found the Arduino driver for Meshtastic. See here: Meshtastic Arduino Driver

Using the included example as a guide, I adapted some reliable wifi connection code for an ESP32 Wrover Module in an attempt to connect to the mesh. Unfortunately, I cannot get the code to compile in either Arduino IDE or by importing into PlatformIO.

Both IDE’s have exactly the same compiler issues in the file mt_protocol.cpp. See attached screenshot.

Any hints? Am I missing a critical library not obvious in the documentation / example or is there a problem with the mt_protocol.cpp declarations?

1 Like

Hi @MtnGeek

I am a professional “C” and C++ developer so I should know, however I don’t have the full source code at hand. What I can tell you is, that the first error message is caused, because the sequence of the definition and the usage (of struct pb_istream_s) isn’t correct. This is obviously not supposed to happen.

As I understand it you are adapting the code for your specific usage. Try to look for an include file named mt_protocol.h and if found, try to include that at the top of the mt_protocol.cpp file.

The pb_read error message is a missing definition, most likely due to the same problem as above. The 3 following error messages as well.

1 Like

I would use the Arduino library instructions, not the GitHub Meshtastic - Arduino Reference

1 Like

Thanks @Hidayatullah and @garth.

I last did any C++ programming 25 years ago, so a bit rusty and trying hard to catch up.

Referring to @Hidayatullah’s comment on the mt_protocol.h file - there isn’t a header file with that name in the src folder on git hub and/or the downloaded libraries in Arduino and PlatformIO. As such, it doesn’t appear in either of the IDEs.

In both Arduino Editor (Cloud) and Arduino (IDE), I include a call for the Meshtastic.h library at the start of my code: #include <Meshtastic.h>.

I’ve imported the library per the Arduino Instructions in both the IDE and Cloud IDEs.

In PlatformIO, I’ve included a lib-deps = meshtastic.h in the platformio.ini file.

My code is identical to the GPSClient example in the library with the exception of replacing the void setup() section in the example (which establishes either a serial or wifi connection) with my own code to connect an ESP32 Wrover Dev Kit to my router.

Missing file in the repository?

Thanks for your advice (and patience!),

Andy

Should have said that I get exactly the same errors trying to compile the GPSClient example in PlatformIO and Arduino as well.

In PlatformIO, after importing the GPSClient example, I have included lib_deps for libraries including meshtastic, nanopb and ESPSoftwareSerial.

Get the same errors no matter the order of the include and lib_dep statements

One other error in the GPSClient example is that I get was that ground_track (line 116 of the example) is not a member of “struct mt_node_t” - easy enough to get rid of that error, just comment it out in the code.

Thanks

You need the nanopb dependency either in platformio.ini or in Arduino ide

1 Like

Thanks @caveman99 - I am pretty sure that I have included the nanopb dependency correctly in the env section of platformio.ini

My workflow:

Import the arduino project GPSClient.ino example exactly as is from into PlatformIO
Include the following in the lib_deps section under the env section of platformIO.ini
lib_deps = meshtastic
= nanopb
= ESPSoftwareSerial

I can see the libraries installing and all seems fine until I get the errors shown above in my original post. Should I be including a specific call to include nanopb somewhere in the code - if so where? I thought that it would be invoked as part of the compiling of the example code.

The code is exactly as the example - it is the example given on github. Can anyone compile and or lead me by the nose on how to modify it for platformIO?

I’ve got load of other code running on ESP32 (steep learning curve) pulling in libraries through lib_deps but this has got me completely stumped.

Thanks.

OK so … the declaration problems noted above go away by modifying the original SRC mt_protocol.h file in the repository with the following includes:
#include “pb_encode.h”
#include “pb_decode.h”

Next problem …

Somehow, the functions aren’t being linked through. Toggling the 0/1 value in the main code toggles the error codes from mt_wifi to mt_serial so clearly something is/isn’t following through in the code.

No idea whether its a sequencing issue /a class being defined twice / a .cpp file that should be a .c file - not a clue and I’m running out of googling ideas. As before, all I’m trying to do is compile the example given in the meshtastic-arduino library. Nothing fancy - just trying to compile the code from the example in PlatformIO.

I’m not a programmer by any means. Rather, I’m a old time hardware guy that did firmware before open source and github came into being. Have some great plans for my nodes so all help gratefully received on my relearning journey.

Thanks

MtnGeek

It is very frustrating with all these odd compile/link errors showing up, and I too wonder if an important include file is missing from the package. What I would like to suggest is, to take the sample (GPS Client example) package and compile that per the included instructions, so without changing anything. This exercise should go through correctly, if not something is missing or wrong with the original package, and we got a somewhat bigger problem on our hands. If it works out fine, then include your own code making sure to spell all function names correctly, in order to do things in small steps, making it easier to locate any problems showing up. Let us know how it works out.

1 Like

So … after a couple hours …

The good news (for me) is that I managed to get my modified version of the example code connected to some of my t-beams over WiFi. Definitely connected as turning rhe software AP disables the connection to the ESP32.

That’s the end of the good news.

Next problem is that there is no data coming back over the serialport.

The example code calls on the bool mt_request_node_report(node_report_callback) before returning a true/false.

Manually setting the logic in the code makes no difference.

No output from the device showing. No error messages. Just a recursive set of messages relating to requesting.

Just a tad frustrating, but every day is a school day.

It is occurring to me that the capability to connect to the device stream might have been disabled since the example code was written.

I’m hoping that firmware 1.2.60 and 1.2.64 (T-beams one and two) should still work with the code.

After five days of frustration, I’ve now reached my goal of getting a stand-alone ESP32 module chatting away to my three mesh nodes.

Thanks to @garth, @caveman99 and @Hidayatullah for offering bits of the breadcrumb trail along the way.

Most of my issues came from the mt_wifi.cpp and mt_protobuf.h files which are geared more to an Arduino and connected Adafruit wifi board. Much of that code now trashed to connect to the ESP32.

After many years away, it’s funny how you remember basics like how important Serial.println() is in debugging.

Game on!

2 Likes

Congratulations on the success :slightly_smiling_face:

Hey MtnGeek,
I have been running into the same exact issues you were seeing here. it seems there is a lot of modification needed to just get the example code to compile. I pretty much have gone through the same steps as you and have been fixing it one thing at a time.
I was wondering if you could give a little more detail on all the changes you made in the end or if would be able to just send me your modified library to help me get it closer to a working state.

Any help would be greatly appreciated!

Thank you.

1 Like

Im trying to compile it for ESP8266 nodemcu, someone did some advance?

:grimacing:

Hi ! may you help me with it for ESP8266 nodemcu ?

I’m stuck at this linker error, How were yu able to correct this error?

Thanks in advance!

Would you mind sharing your code? I think there are many in the community (myself included) that would benefit from code that is already been stripped of the Adafruit WiFi board dependencies. There a so many great ESP32 boards, I’m not sure why they chose such an odd board for their example.