Porting MKRGSM to Leonardo

I have some older Leonardo boards and a slightly different uBlox modem, so I wanted to port MKRGSM library. It is based off the now deprecated GSM library which used the SoftwareSerial library, causing other headaches.

If I tweak modem.cpp in the library to this:
ModemClass MODEM(Serial1, 115200, 4, 7);

I get this compiler error:

WARNING: library MKRGSM claims to run on samd architecture(s) and may be incompatible with your current board which runs on avr architecture(s).
In file included from \Arduino\libraries\MKRGSM\src/GSMVoiceCall.h:23:0,
                 from \Arduino\libraries\MKRGSM\src/MKRGSM.h:24,
                 from \AppData\Local\Temp\.arduinoIDE-unsaved2023123-26736-sy7p7s.4vyce\TestModem\TestModem.ino:18:
\Arduino\libraries\MKRGSM\src/Modem.h:35:18: error: expected ')' before '&' token
   ModemClass(Uart& uart, unsigned long baud, int resetPin, int dtrPin);
                  ^
\Arduino\libraries\MKRGSM\src/Modem.h:71:3: error: 'Uart' does not name a type; did you mean 'sqrt'?
   Uart* _uart;
   ^~~~
   sqrt

exit status 1

I am afraid my C++ skillz are not quite up to figuring out why that constructor hates me for passing in Serial1 instead of SerialGSM

Any help is greatly appreciated!

I solved a problem similar to yours in the SomeSerial library

Uart is a class that exists for the SAMD21 core as a subclass of HardwareSerial

if you compile the library for a non SAMD21 architecture, you don't get the same core and thus you don't have the Uart.h and Uart.cpp files as part of the compilation and thus it fails.

of course you can't just copy those 2 files over because they include SAMD21 specific stuff like SERCOM

with no guarantee whatsoever, you could try to replace the Uart mention with HardwareSerial in the source code of the MKRGSM Library.

It's in Modem.cpp ➜ change

ModemClass::ModemClass(Uart& uart, unsigned long baud, int resetPin, int dtrPin) :

into

ModemClass::ModemClass(HardwareSerial& uart, unsigned long baud, int resetPin, int dtrPin) :

and in Modem.h make similar changes in two places:

  ModemClass(Uart& uart, unsigned long baud, int resetPin, int dtrPin);

becomes

  ModemClass(HardwareSerial& uart, unsigned long baud, int resetPin, int dtrPin);

and of course the instance variable needs to be changed so

private:
  Uart* _uart;

becomes

private:
  HardwareSerial* _uart;

if you are lucky the rest of the library uses just standard functions that are defined in the HardwareSerial class and nothing exotic

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.