Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Arduino Nano Every with FONA 808 GPS Compile Errors
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Arduino Nano Every with FONA 808 GPS Compile Errors

by ichasney on Mon Jan 13, 2020 6:46 pm

I recently purchased a FONA 808+GPS for use with an Arduino Nano Every. When compiling the FONAtest sketch I get a lot of compile problems. I'm using 1.8.1 of the IDE and the latest version 1.3.5 of the Adafruit FONA library from the library manager. I've tried with the ATMEGA328 emulator on and off but no effect. I've tried on Mac and a Windows 10 machine with the same results. If I use a start Arduino Uno everything works fine but the different architecture of the Nano Every seems to be causing problems.

It starts out erroring with:
Code: Select all | TOGGLE FULL SIZE
no matching function for call to 'Adafruit_FONA::enableNTPTimeSync(bool, const char [13])'

If this is commented out if moves to a different missing function call:
Code: Select all | TOGGLE FULL SIZE
no matching function for call to 'Adafruit_FONA::HTTP_POST_start(char [80], const char [11], uint8_t*, size_t, uint16_t*, uint16_t*)'


If this is commented out then it goes into a whole bunch of conversion fail errors, full logs attached. Is there anything that can be done? Any work arounds or plans to support the Nano Every board?
Attachments
NanoEveryFONA808GPSCompileErrors.txt
Output Logs for Compile Errors with Nano Every and FONA 808 + GPS
(113.33 KiB) Downloaded 10 times

ichasney
 
Posts: 4
Joined: Mon Jan 13, 2020 6:18 pm

Re: Arduino Nano Every with FONA 808 GPS Compile Errors

by adafruit_support_mike on Tue Jan 14, 2020 5:00 am

Errors like that are the software equivalent of a marching band hitting a banana peel: only the first to fall is related to the actual cause, everything else is collateral.

In this case, the compiler doesn't like the F() macro, which existed to save RAM on the Arduino Uno. 32-bit microcontrollers don't need it, and don't access Flash memory in the same way, so the macro doesn't work for them.

If you change line 59 of FONAPlatStd.h from this:

Code: Select all | TOGGLE FULL SIZE
typedef const __FlashStringHelper *   FONAFlashStringPtr;
to this:

Code: Select all | TOGGLE FULL SIZE
typedef const char *   FONAFlashStringPtr;
It should make things work.

https://github.com/adafruit/Adafruit_FO ... tStd.h#L59

adafruit_support_mike
 
Posts: 61197
Joined: Thu Feb 11, 2010 2:51 pm

Re: Arduino Nano Every with FONA 808 GPS Compile Errors

by ichasney on Sun Jan 26, 2020 3:12 pm

Many thanks for your help Mike, I've persevered with trying to get the Nano Every working with the FONA 808. I've made a little progress and had some success but things are getting a little over my head. It's been a long time since I've done any C++ so I was a bit rusty. Sorry this is a bit of an essay but I better walk through everything I've done.

I followed your advice and replaced the __FlashStringHelper reference as you suggested on line 59 of FONAPlatStd.h and set it to a char.
There were some further compiler problems that I traced back to a problem to line 1518 of the ... The Adafruit_FONA::HTTP_para method didn't seem to accept the int32_t values being parsed to it. So I changed the type from to just int

https://github.com/adafruit/Adafruit_FONA/blob/master/Adafruit_FONA.cpp#L1518
Code: Select all | TOGGLE FULL SIZE
boolean Adafruit_FONA::HTTP_para(FONAFlashStringPtr parameter,
                                 int32_t value) {

becomes
Code: Select all | TOGGLE FULL SIZE
boolean Adafruit_FONA::HTTP_para(FONAFlashStringPtr parameter,
                                 int value) {


Everything then compiled OK.

Try as a might however I couldn't get it to work on SoftwareSerial I tried all sorts of configurations, different pins etc. So I gave up and had a look at using the second hardware serial port Serial1.

I knocked up a simple test sketch to prove my pinouts are working correctly and to prove that on a basic level I could talk to the FONA808, see attached file.

I was able to get a AT OK response and query things like battery state with AT+CBC, stuff like that.

I went to plug back in what I'd learned to the library FONAtest sketch and FONA library itself however the RST pin configuration had me puzzled. I couldn't fathom what it was for exactly. Every time I tried to configure it to a pin the test sketch would not return any OK responses when the sketch connection test ran and just kept restarting. Eventually I commented out the code controlling it.
https://github.com/adafruit/Adafruit_FONA/blob/master/Adafruit_FONA.cpp#L52
Code: Select all | TOGGLE FULL SIZE
  pinMode(_rstpin, OUTPUT);
  digitalWrite(_rstpin, HIGH);
  delay(10);
  digitalWrite(_rstpin, LOW);
  delay(100);
  digitalWrite(_rstpin, HIGH);


So on to my final problem. When I run the FONATest sketch on Hardware Serial I get responses that look like they should be good, however it falls all the way through the FONA begin function and ends up telling me it can't connect to FONA. Despite a load of traces that say AT > OK, which look like it does have connection.

Looking into this in more detail it seems as though there is a series of functions designed to check and compare the replybuffer with the correct reply. This comparison appears to be failing and I can't understand why.

https://github.com/adafruit/Adafruit_FONA/blob/master/Adafruit_FONA.cpp#L1933
Code: Select all | TOGGLE FULL SIZE
boolean Adafruit_FONA::sendCheckReply(char* send, FONAFlashStringPtr reply, uint16_t timeout) {
  if (! getReply(send, timeout) )
     return false;
  return (prog_char_strcmp(replybuffer, (prog_char*)reply) == 0);
}


Any assistance you could offer on where to go next would be extremely appreciated, as I'm getting a little out of my depth now.

Cheers

Charlie
Attachments
HardwareSerialTestFONAArduinoNano.ino
(991 Bytes) Downloaded 6 times

ichasney
 
Posts: 4
Joined: Mon Jan 13, 2020 6:18 pm

Re: Arduino Nano Every with FONA 808 GPS Compile Errors

by ichasney on Sun Jan 26, 2020 6:01 pm

For reference, here is the output from the Serial Monitor when running FONATest

FONA basic test
Initializing....(May take 3 seconds)
Attempting to open comm with ATs
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
Timeout: No response to AT... last ditch attempt.
---> AT
<--- OK
---> AT
<--- OK
---> AT
<--- OK
---> ATE0
<--- OK
---> ATE0
<--- OK
Couldn't find FONA

ichasney
 
Posts: 4
Joined: Mon Jan 13, 2020 6:18 pm

Re: Arduino Nano Every with FONA 808 GPS Compile Errors

by ichasney on Mon Jan 27, 2020 1:51 pm

Thinking a bit more about what you said regarding there being no need for the F() functions anymore because accessing flash memory is done differently in this architecture, most of the comparison lines in these functions are comparing values in PROGMEM to values in RAM. Could making them all be in RAM be the way to go I wonder?

ichasney
 
Posts: 4
Joined: Mon Jan 13, 2020 6:18 pm

Re: Arduino Nano Every with FONA 808 GPS Compile Errors

by adafruit_support_mike on Tue Jan 28, 2020 4:30 am

ichasney wrote:Could making them all be in RAM be the way to go I wonder?

Yes. That's what the original #define I suggested should do, but if you're already writing a new version of the library, go ahead and get rid of them at the source level.

ichasney wrote:Try as a might however I couldn't get it to work on SoftwareSerial I tried all sorts of configurations

SAMD microcontrollers don't support SoftwareSerial, but they rarely need anything like it. They have a free hardware Serial interface, and you can program the SERCOMs to get more if you need them.

ichasney wrote:however the RST pin configuration had me puzzled. I couldn't fathom what it was for exactly.

The hardware reset pin forces the SIM800 to go to a known state that's ready to listen for AT commands. I'm not sure why that would fail on your hardware. Maybe try adding another delay() after you send the pin high so the SIM800 has time to stabilize before you start talking to it.

ichasney wrote:Looking into this in more detail it seems as though there is a series of functions designed to check and compare the replybuffer with the correct reply. This comparison appears to be failing and I can't understand why.

That's probably related to the F() macro stuff again. It will probably be easiest to go through the code and turn all the F() macro'd strings into regular ones.

adafruit_support_mike
 
Posts: 61197
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.