mirror of
https://github.com/0015/ThatProject.git
synced 2026-01-12 09:17:42 +03:00
Send an SMS from ESP32 (ft. Twilio)
This commit is contained in:
32
MESSAGE/Twilio/0_ESP32TTGO_FIRESTORE_SMS/Messenger.cpp
Normal file
32
MESSAGE/Twilio/0_ESP32TTGO_FIRESTORE_SMS/Messenger.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "Messenger.h"
|
||||
|
||||
// Values from Twilio (find them on the dashboard)
|
||||
static const char *account_sid = "";
|
||||
static const char *auth_token = "";
|
||||
// Phone number should start with "+<countrycode>"
|
||||
static const char *from_number = "";
|
||||
|
||||
// You choose!
|
||||
// Phone number should start with "+<countrycode>"
|
||||
static const char *to_number = "";
|
||||
|
||||
Messenger::Messenger() {
|
||||
twilio = new Twilio(account_sid, auth_token);
|
||||
}
|
||||
|
||||
Messenger::~Messenger() {
|
||||
delete twilio;
|
||||
}
|
||||
|
||||
void Messenger::sendMessage(String msg) {
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED) return;
|
||||
|
||||
String response;
|
||||
bool success = twilio->send_message(to_number, from_number, msg, response);
|
||||
if (success) {
|
||||
Serial.println("Sent message successfully!");
|
||||
} else {
|
||||
Serial.println(response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user