Git Product home page Git Product logo

arduinothreadedgsm's People

Contributors

neta540 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

maribeiro choncba

arduinothreadedgsm's Issues

sendSMS examples

Hi there, thanks for making this library. Could you add an sms send example. You mention that the string to pass to the method should be a PDU but it's not particularly clear what format this should take without an example.

As for help with putting ThreadedGSM class to another class

I have to ask you a favor. I want to “hide” Your class ThreadedGSM in my own class. I made a try, but not everything is working. It’s look like:

gms_c.h

#include "ThreadedGSM.h" // Author: Neta Yahav
#include "PduEncoder.h" // Author: Ludovic Laurent

class gsm_c {
private:
//ThreadedGSM *SIM800L;
void signal(ThreadedGSM& modem, ThreadedGSM::SignalLevel& Signal);

public:
    // ----- Constructor -----          
    //gsm_c();
    gsm_c(HardwareSerial& port);        
    void init();
    void sendAlarmSMS();
    void gsm_loop();        

};

gms_c.cpp

#include "gsm_c.h"

//gsm_c::gsm_c() {
// // nothing
// init();
//}

gsm_c::gsm_c(HardwareSerial& port) {
init();
}

void gsm_c::init() {
Serial1.begin(115200);
//SIM800L->begin();
SIM800L.begin();

//SIM800L->setInterval(ThreadedGSM::INTERVAL_SIGNAL, 60000);
SIM800L.setInterval(ThreadedGSM::INTERVAL_SIGNAL, 60000);

SIM800L.setHandlers({
.signal = signal,
.clock = NULL,
.incoming = NULL,
.ready = NULL,
.outgoing = NULL,
.power = NULL
});     

}

void gsm_c::signal(ThreadedGSM& modem, ThreadedGSM::SignalLevel& Signal) {
Serial.print("Modem signal: Dbm:");
Serial.print(Signal.Dbm);
Serial.print(" value: ");
Serial.println(Signal.Value);
}

void gsm_c::sendAlarmSMS() {
PduEncoder PDU;
String sms, encodedPDU;

PDU.setSMSCnumber("+XXXXXXXXXXX");
PDU.setSender("+XXXXXXXXXXX");

sms  = "Piec - ALARM - Temp: ";
sms += currentTemp;
sms += "\rStan pompy: ";

switch(stanPompy) {
    case 0: sms +="OFF"; break;
    case 1: sms +="ON"; break;
    default: sms +="???"; break;
}

sms += "\rTryb pracy pompy: ";
switch(trybPompy) {
    case 0: sms += "AUTO"; break;
    case 1: sms += "ON"; break;
    case 2: sms += "OFF"; break;
    default: sms += "???"; break;
}

PDU.setText(sms);
encodedPDU = PDU.encode();

//SIM800L->sendSMS(encodedPDU);
SIM800L.sendSMS(encodedPDU);

}

void gsm_c::gsm_loop() {
//SIM800L->loop();
SIM800L.loop();
}

The problem is with the SIM800L.setHandlers function. When I put there

SIM800L.setHandlers({
.signal = NULL,
.clock = NULL,
.incoming = NULL,
.ready = NULL,
.outgoing = NULL,
.power = NULL
});     

Sending SMS and loop() is working, but I need signal. If I change .signal = NULL to .signal = signal I’m getting this error:

src\gsm_c.cpp:50:3: error: no matching function for call to 'ThreadedGSM::setHandlers()'
In file included from include/gsm_c.h:10:0,
from src\gsm_c.cpp:1:
src/ThreadedGSM.h:186:7: note: candidate: void ThreadedGSM::setHandlers(ThreadedGSM::conf)
void setHandlers(conf config)
^
src/ThreadedGSM.h:186:7: note: no known conversion for argument 1 from '' to 'ThreadedGSM::conf'

How should I pass config to ThreadedGSM object in this situation? Could You help mi with that please? My knowledge of C++ is rather at basic level. :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.