Help using __FlashStringHelper with Digispark

Hi

I’m trying to refactor a Seeeduino SIM900 libraryhttps://github.com/Seeed-Studio/GPRS_SIM900 to fit in program memory for my Digispark. Everything works on the Arduino UNO, but I get the error shown below with Digispark (Original).

Adding #include <avr/pgmspace.h> doesn’t help. Any ideas?

Arduino: 1.6.8 (Linux), Board: "Digispark (Default - 16.5mhz)"

In file included from /home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:35:0,
                 from /home/edanweis/Arduino/Seeeduino_GPRS_SIM900_DIGI/Seeeduino_GPRS_SIM900_DIGI.ino:11:
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/sim900.h:55:29: error: '__FlashStringHelper' does not name a type
 void  sim900_send_cmd(const __FlashStringHelper* cmd);
                             ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/sim900.h:55:50: error: ISO C++ forbids declaration of 'cmd' with no type [-fpermissive]
 void  sim900_send_cmd(const __FlashStringHelper* cmd);
                                                  ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/sim900.h:61:38: error: '__FlashStringHelper' does not name a type
 boolean  sim900_check_with_cmd(const __FlashStringHelper* cmd, const char *resp, DataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int chartimeout = DEFAULT_INTERCHAR_TIMEOUT);
                                      ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/sim900.h:61:59: error: ISO C++ forbids declaration of 'cmd' with no type [-fpermissive]
 boolean  sim900_check_with_cmd(const __FlashStringHelper* cmd, const char *resp, DataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int chartimeout = DEFAULT_INTERCHAR_TIMEOUT);
                                                           ^
In file included from /home/edanweis/Arduino/Seeeduino_GPRS_SIM900_DIGI/Seeeduino_GPRS_SIM900_DIGI.ino:11:0:
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:220:21: error: '__FlashStringHelper' does not name a type
     bool join(const __FlashStringHelper *apn = 0, const __FlashStringHelper *userName = 0, const __FlashStringHelper *passWord = 0);
                     ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:220:48: error: ISO C++ forbids declaration of 'apn' with no type [-fpermissive]
     bool join(const __FlashStringHelper *apn = 0, const __FlashStringHelper *userName = 0, const __FlashStringHelper *passWord = 0);
                                                ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:220:57: error: '__FlashStringHelper' does not name a type
     bool join(const __FlashStringHelper *apn = 0, const __FlashStringHelper *userName = 0, const __FlashStringHelper *passWord = 0);
                                                         ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:220:89: error: ISO C++ forbids declaration of 'userName' with no type [-fpermissive]
     bool join(const __FlashStringHelper *apn = 0, const __FlashStringHelper *userName = 0, const __FlashStringHelper *passWord = 0);
                                                                                         ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:220:98: error: '__FlashStringHelper' does not name a type
     bool join(const __FlashStringHelper *apn = 0, const __FlashStringHelper *userName = 0, const __FlashStringHelper *passWord = 0);
                                                                                                  ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:220:130: error: ISO C++ forbids declaration of 'passWord' with no type [-fpermissive]
     bool join(const __FlashStringHelper *apn = 0, const __FlashStringHelper *userName = 0, const __FlashStringHelper *passWord = 0);
                                                                                                                                  ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:237:35: error: '__FlashStringHelper' does not name a type
  bool connect(Protocol ptl, const __FlashStringHelper *host, const __FlashStringHelper *port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 * DEFAULT_INTERCHAR_TIMEOUT);
                                   ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:237:56: error: ISO C++ forbids declaration of 'host' with no type [-fpermissive]
  bool connect(Protocol ptl, const __FlashStringHelper *host, const __FlashStringHelper *port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 * DEFAULT_INTERCHAR_TIMEOUT);
                                                        ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:237:68: error: '__FlashStringHelper' does not name a type
  bool connect(Protocol ptl, const __FlashStringHelper *host, const __FlashStringHelper *port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 * DEFAULT_INTERCHAR_TIMEOUT);
                                                                    ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:237:89: error: ISO C++ forbids declaration of 'port' with no type [-fpermissive]
  bool connect(Protocol ptl, const __FlashStringHelper *host, const __FlashStringHelper *port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 * DEFAULT_INTERCHAR_TIMEOUT);
                                                                                         ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:301:28: error: '__FlashStringHelper' does not name a type
     bool getLocation(const __FlashStringHelper *apn, float *longitude, float *latitude);
                            ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:301:49: error: ISO C++ forbids declaration of 'apn' with no type [-fpermissive]
     bool getLocation(const __FlashStringHelper *apn, float *longitude, float *latitude);
                                                 ^
Seeeduino_GPRS_SIM900_DIGI:23: error: expected ',' or ';' before 'GPRS'
 GPRS gprsTest(PIN_TX,PIN_RX,BAUDRATE);//RX,TX,BaudRate
 ^
/home/edanweis/Arduino/Seeeduino_GPRS_SIM900_DIGI/Seeeduino_GPRS_SIM900_DIGI.ino: In function 'void setup()':
Seeeduino_GPRS_SIM900_DIGI:27: error: 'gprsTest' was not declared in this scope
   while(!gprsTest.init()) {
          ^
Seeeduino_GPRS_SIM900_DIGI:30: error: 'gprsTest' was not declared in this scope
   gprsTest.sendSMS(PHONE_NUMBER,MESSAGE); //define phone number and text
   ^
exit status 1
expected ',' or ';' before 'GPRS'

__FlashStringHelper is only used in the pro core, not the tiny used in the Digispark ATtiny85. So unless you want to modify the Digispark core you probably would need to remove all references to __FlashStringHelper from the library and the use of the F() macro from any of the examples.

/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/sim900.h:55:29: error: '__FlashStringHelper' does not name a type
 void  sim900_send_cmd(const __FlashStringHelper* cmd);
                             ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/sim900.h:61:38: error: '__FlashStringHelper' does not name a type
 boolean  sim900_check_with_cmd(const __FlashStringHelper* cmd, const char *resp, DataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int chartimeout = DEFAULT_INTERCHAR_TIMEOUT);
                                      ^

These functions are overloaded so you can just remove the prototype from sim900.h and the function from sim900.cpp.

/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:220:21: error: '__FlashStringHelper' does not name a type
     bool join(const __FlashStringHelper *apn = 0, const __FlashStringHelper *userName = 0, const __FlashStringHelper *passWord = 0);
                     ^
/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:301:28: error: '__FlashStringHelper' does not name a type
     bool getLocation(const __FlashStringHelper *apn, float *longitude, float *latitude);
                            ^

You're going to have to modify these functions to use const char* instead of __FlashStringHelper.

/home/edanweis/Arduino/libraries/GPRS_SIM900_DIGI/GPRS_Shield_Arduino.h:237:35: error: '__FlashStringHelper' does not name a type
  bool connect(Protocol ptl, const __FlashStringHelper *host, const __FlashStringHelper *port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 * DEFAULT_INTERCHAR_TIMEOUT);
                                   ^

This function is overloaded so you can just remove the prototype from GPRS_Shield_Arduino.h and the function from GPRS_Shield_Arduino.cpp.

_FlashStringHelper is defined in Wstring.h which is included by Arduino.h for C++ compiles. Does the Digispark core not include Wstring.h?

johnwasser: _FlashStringHelper is defined in Wstring.h which is included by Arduino.h for C++ compiles. Does the Digispark core not include Wstring.h?

It does, but the tiny core WString.h doesn't have the __FlashStringHelper definition: https://github.com/digistump/DigistumpArduino/blob/master/digistump-avr/cores/tiny/WString.h. Their pro core has it: https://github.com/digistump/DigistumpArduino/blob/master/digistump-avr/cores/pro/WString.h#L37-L38 so that makes me think it was intentionally left out of the tiny core.