Dear All,
The condition _cell.available() retunr false and I do not understand why
if(_cell.available() != 0){ // if there are data in the UART input buffer, reads it and checks for the asnwer
response[x] = _cell.read();
Serial.print(response[x]);
x++;
Serial.print(F("Response"));
Serial.println(response);
Serial.print(F("Expected answer"));
Serial.println(expected_answer);
if (strstr(response, expected_answer) != NULL) // check if the desired answer (OK) is in the response of the module
{
answer = 1;
}
}else{
if(_debug){
Serial.println(F("No data in UART"));
}
}
In my .ino file I do have this
// GENERAL
int debug = true;
int pinToPowerOnModule = 8;
int dtr = 7;
// LED
int green = 12;
#define MSEC 500
#define MSEC_FAST 150
// SERIAL
int baud_rate = 9600;
int rxpin = 2;
int txpin = 3;
Sim908 sim908(rxpin, txpin, baud_rate, pinToPowerOnModule, debug, dtr);
My constructor look like:
Sim908::Sim908(int rxpin, int txpin, int baud_rate, int pinToPowerOnModule, int debug, int dtr)
{
pinMode(pinToPowerOnModule, OUTPUT);
pinMode(dtr, OUTPUT);
_pinToPowerOnModule = pinToPowerOnModule;
_debug = debug;
_baud_rate = baud_rate;
_dtr = dtr;
_rxpin = rxpin;
_txpin = txpin;
};
I also have an initialize function
void Sim908::initializeSim908()
{
//digitalWrite(_dtr,LOW);
SoftwareSerial _cell(_rxpin,_txpin);
_cell.begin(_baud_rate);
powerOnSim908();
}
in My Sim908.h file, I declare _call like this:
Sim908.h - Library
*/
#ifndef Sim908_h
#define Sim908_h
#include <SoftwareSerial.h>
#include "Arduino.h"
class Sim908{
private:
int _pinToPowerOnModule;
//Stream* _cell;
SoftwareSerial _cell;
//SoftwareSerial* _cell;
int _debug;
int _baud_rate;
int _dtr;
int _rxpin;
int _txpin;
public:
Sim908(int rxpin, int txpin, int baud_rate, int pinToPowerOnModule, int debug, int dtr);
//Sim908(SoftwareSerial cell, int baud_rate, int pinToPowerOnModule, int debug, int dtr);
void initializeSim908();
void powerOnSim908();
int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout);
void blinkLed(int lPin, int nBlink, int msec);
};
#endif
The terminal display that error message:
/Users/pierrot/Documents/Arduino/libraries/Sim908/Sim908.cpp: In constructor 'Sim908::Sim908(int, int, int, int, int, int)':
/Users/pierrot/Documents/Arduino/libraries/Sim908/Sim908.cpp:6: error: no matching function for call to 'SoftwareSerial::SoftwareSerial()'
/Applications/Arduino.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.h:83: note: candidates are: SoftwareSerial::SoftwareSerial(uint8_t, uint8_t, bool)
/Applications/Arduino.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.h:48: note: SoftwareSerial::SoftwareSerial(const SoftwareSerial&)
NB: In my Sim908.h and Sim908.cpp I added that line #include "SoftwareSerial.h"
So _cell.available or _cell.read should work as if in my .ino file, I would use that?
SoftwareSerial cell(rxpin,txpin);
cell.begin();
cell.available()
cell.read();
Do you see somethink wrong?
Thank a lot