esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
15.89k stars 13.35k forks source link

Adafruit FONA 3G and strstr_P not declared #1749

Closed gardi-innovation closed 8 years ago

gardi-innovation commented 8 years ago

Basic Infos

Hardware

Hardware: Adafruit Feather Huzzah (?ESP-12?) Core Version: I've tried all versions. Currently using 2.1.0-rc2

Description

I'm trying to use the Adafruit Feather Huzzah and the Adafruit FONA 3G (European version) in the same project.

I'm using the Adafruit Fona Library. And my sketch is based on a super stripped down version of the FONAtest example.

The FONA 3G library is not ported to ESP8266 and thus I made the following change:

Correction in this file: Adafruit_Fona/includes/platform/FONAPlatStd.h

//#include <avr/pgmspace.h>

#ifdef __AVR
#include <avr/pgmspace.h>
#elif defined(ESP8266)
#include <pgmspace.h>
#endif

When compiling I get the following error:

Arduino/libraries/Adafruit_FONA/includes/platform/FONAPlatStd.h:72:53: error: 'strstr_P' was not declared in this scope
 #define prog_char_strstr(a, b)     strstr_P((a), (b))

The sketch compiles, if I uncomment this line in the same file:

//#define prog_char_strstr(a, b)                    strstr_P((a), (b))

but then it keeps on crashing like this (print from terminal):

FONA basic test
Initializing....(May take 3 seconds)
Attempting to open comm with ATs
    ---> AT
    <--- 
    ---> AT
    <--- 
    ---> AT
    <--- 
    ---> AT
    <--- 
    ---> AT
    <--- 
    ---> AT
    <--- 
    ---> AT
    <--- 
    ---> AT
    <--- START
    ---> AT
    <--- AT
    ---> AT
    <--- AT
    ---> ATE0
    <--- ATE0
    ---> ATE0
    <--- OK
    ---> AT+CVHU=0
    <--- OK
    ---> ATI
    <--- Manufacturer: SIMCOM INCORPORATED
Model: SIMCOM_SIM5320E
Revision: SIM5320E_V1.5
IMEI: 861311004419965
+GCAP: +CGSM,+FCLASS,+
Exception (3):
epc1=0x4000e1f0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40230f8d depc=0x00000000

ctx: cont 
sp: 3ffefc10 end: 3ffefe10 offset: 01a0

>>>stack>>>
3ffefdb0:  3ffe8452 3ffeed2c 3ffeeaa8 402025b5  
3ffefdc0:  000012c0 3ffeed2c 3ffeed2c 3ffeede4  
3ffefdd0:  3ffeeaa8 3ffeed2c 3ffe8368 40202079  
3ffefde0:  feefeffe feefeffe feefeffe feefeffe  
3ffefdf0:  3fffdad0 00000000 3ffeeddd 40203148  
3ffefe00:  feefeffe feefeffe 3ffeedf0 40100114  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x42
csum 0x42
~ld

I have pinpointed the crash to this section in the Adafruit_FONA.cpp file:

  mySerial->println("ATI");
  readline(500, true);

  DEBUG_PRINT (F("\t<--- ")); DEBUG_PRINTLN(replybuffer);

  if (prog_char_strstr(replybuffer, (prog_char *)F("SIM808 R14")) != 0) {
    _type = FONA808_V2;
  } else if (prog_char_strstr(replybuffer, (prog_char *)F("SIM808 R13")) != 0) {
    _type = FONA808_V1;
  } else if (prog_char_strstr(replybuffer, (prog_char *)F("SIM800 R13")) != 0) {
    _type = FONA800L;
  } else if (prog_char_strstr(replybuffer, (prog_char *)F("SIMCOM_SIM5320A")) != 0) {
    _type = FONA3G_A;
  } else if (prog_char_strstr(replybuffer, (prog_char *)F("SIMCOM_SIM5320E")) != 0) {
    _type = FONA3G_E;
  }

The program crashes when calling the prog_char_strstr() function which I uncommented in the FONAPlatStd.h...

I am very confused as to why there is no strstr_P() function defined? By searching for several hours all over the internet I've found this ESP8266 library which seems to have this function defined.

I would be tremendously grateful if somebody could please point me in the right direction on how to solve this? Thank you!

For your information:

Module: ?Generic ESP8266 Module? Flash Size: ?4MB/1MB? CPU Frequency: ?80Mhz? Flash Mode: ?qio? Flash Frequency: ?40Mhz? Upload Using: ?OTA / SERIAL? Reset Method: ?ck / nodemcu?

Sketch

#include "Adafruit_FONA.h"

//#define FONA_RX 2
//#define FONA_TX 3
//#define FONA_RST 4

#define FONA_RX 12
#define FONA_TX 13
#define FONA_RST 14

// this is a large buffer for replies
char replybuffer[255];

// We default to using software serial. If you want to use hardware serial
// (because softserial isnt supported) comment out the following three lines 
// and uncomment the HardwareSerial line
#include <SoftwareSerial.h>
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;

// Hardware serial is also possible!
//  HardwareSerial *fonaSerial = &Serial1;

// Use this for FONA 800 and 808s
//Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
// Use this one for FONA 3G
Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);

uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);

uint8_t type;

void setup() {
  //while (!Serial);

  Serial.begin(115200);
  Serial.println(F("FONA basic test"));
  Serial.println(F("Initializing....(May take 3 seconds)"));

  fonaSerial->begin(4800);
  if (! fona.begin(*fonaSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while (1);
  }

  type = fona.type();
  Serial.println(F("FONA is OK"));
  Serial.print(F("Found "));
  switch (type) {
    case FONA800L:
      Serial.println(F("FONA 800L")); break;
    case FONA800H:
      Serial.println(F("FONA 800H")); break;
    case FONA808_V1:
      Serial.println(F("FONA 808 (v1)")); break;
    case FONA808_V2:
      Serial.println(F("FONA 808 (v2)")); break;
    case FONA3G_A:
      Serial.println(F("FONA 3G (American)")); break;
    case FONA3G_E:
      Serial.println(F("FONA 3G (European)")); break;
    default: 
      Serial.println(F("???")); break;
  }

  // Print module IMEI number.
  char imei[15] = {0}; // MUST use a 16 character buffer for IMEI!
  uint8_t imeiLen = fona.getIMEI(imei);
  Serial.println("Post IMEI");
  if (imeiLen > 0) {
    Serial.print("Module IMEI: "); Serial.println(imei);
  }

}

void loop() {

Serial.println("loop..");
delay(1000);

}

Debug Messages

error: 'strstr_P' was not declared in this scope
 #define prog_char_strstr(a, b)     strstr_P((a), (b))

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

bfruiz04 commented 8 years ago

hi, Friends, i have the same error, how do work it, please help me, thanks