-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"platformio.platformio-ide" | ||
], | ||
"unwantedRecommendations": [ | ||
"ms-vscode.cpptools-extension-pack" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[env:nodemcuv2] | ||
build_type = debug | ||
platform = espressif8266 | ||
board = nodemcuv2 | ||
framework = arduino | ||
lib_deps = | ||
plerup/EspSoftwareSerial@^8.1.0 | ||
arduino-sim800=symlink://../../ | ||
|
||
[env:wemos_d1_mini32] | ||
build_type = debug | ||
platform = espressif32 | ||
board = wemos_d1_mini32 | ||
framework = arduino | ||
lib_deps = | ||
plerup/EspSoftwareSerial@^8.1.0 | ||
arduino-sim800=symlink://../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <Arduino.h> | ||
#include <SoftwareSerial.h> | ||
#include <ATConnection.hpp> | ||
#include <Sim800.hpp> | ||
#include <Sim800/Events.hpp> | ||
|
||
SoftwareSerial swSerial(D3, D4); // RX & TX pins | ||
ATConnection at(&swSerial); | ||
Sim800 sim800(&at); | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
swSerial.begin(9600); | ||
|
||
sim800.setup(); | ||
sim800.on(Sim800IncomingSMSEvent::type, [](const Event *e) { | ||
auto env = (Sim800IncomingSMSEvent *)e; | ||
Serial.printf("New SMS received (memory: %s, index: %hhu)\n", env->getMemory(), env->getIndex()); | ||
|
||
Serial.println("Retrieve SMS from sim800"); | ||
sim800.getSMS(env->getIndex()) | ||
->onSuccess([](const SMS *sms) { | ||
Serial.println("Retrieve SMS from sim800 [done]"); | ||
if (sms->getType() == SMS::Type::TEXT_SMS) { | ||
auto textSMS = (TextSMS *)sms; | ||
Serial.println("Type: TEXT_SMS"); | ||
Serial.printf("Sender: %s\n", textSMS->getPeer()); | ||
Serial.printf("Text: \"%s\"\n", textSMS->getText()); | ||
} else if (sms->getType() == SMS::Type::STATUS_SMS) { | ||
Serial.println("Type: STATUS_SMS"); | ||
} else { | ||
Serial.println("Type: Unsupported"); | ||
} | ||
}) | ||
->onFail([](const std::exception &reason) { | ||
Serial.println("Retrive SMS from sim800 [failed]"); | ||
}) | ||
->freeOnFinish(); | ||
}); | ||
|
||
Serial.println("Initialize Sim800 connection"); | ||
sim800.init() | ||
->onSuccess([]() { | ||
Serial.println("Initialize Sim800 connection [done]"); | ||
Serial.println("Put sim800 into sms text mode"); | ||
sim800.putInTextMode() | ||
->onSuccess([]() { | ||
Serial.println("Put sim800 into sms text mode [done]"); | ||
}) | ||
->onFail([](const std::exception &reason) { | ||
Serial.println("Put sim800 into sms text mode [failed]"); | ||
}) | ||
->freeOnFinish(); | ||
}) | ||
->onFail([](const std::exception &reason) { | ||
Serial.println("Initialize Sim800 connection [failed]"); | ||
}) | ||
->freeOnFinish(); | ||
} | ||
|
||
void loop() | ||
{ | ||
at.communicate(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters