12 #ifndef ADAFRUITIO_FONA_H 13 #define ADAFRUITIO_FONA_H 16 #include "Adafruit_FONA.h" 17 #include "Adafruit_MQTT.h" 18 #include "Adafruit_MQTT_FONA.h" 20 #include <SoftwareSerial.h> 26 #define FONA_BAUD 4800 47 _serial =
new SoftwareSerial(FONA_TX, FONA_RX);
48 _fona =
new Adafruit_FONA(FONA_RST);
64 void setAPN(FONAFlashStringPtr apn, FONAFlashStringPtr username = 0,
65 FONAFlashStringPtr password = 0) {
66 _fona->setGPRSNetworkSettings(apn, username, password);
77 if (
_status == AIO_NET_CONNECT_FAILED)
81 if (
_fona->GPRSstate())
82 return AIO_NET_CONNECTED;
85 if (
_fona->getNetworkStatus() != 1)
86 return AIO_NET_DISCONNECTED;
88 _fona->enableGPRS(
true);
89 return AIO_NET_CONNECTED;
113 _serial->begin(FONA_BAUD);
116 if (!_fona->begin(*_serial)) {
117 _status = AIO_NET_CONNECT_FAILED;
122 _serial->println(
"AT+CMEE=2");
124 _status = AIO_NET_DISCONNECTED;
133 if (!_fona->enableGPRS(
false)) {
136 _status = AIO_NET_DISCONNECTED;
140 #endif // ADAFRUITIO_FONA_H Class for interacting with Adafruit IO.
Definition: AdafruitIO.h:45
AdafruitIO_FONA(const char *user, const char *key)
Initializes a new AdafruitIO_FONA instance.
Definition: AdafruitIO_FONA.h:46
void setAPN(FONAFlashStringPtr apn, FONAFlashStringPtr username=0, FONAFlashStringPtr password=0)
Sets Adafruit Fona APN name.
Definition: AdafruitIO_FONA.h:64
aio_status_t _status
Definition: AdafruitIO.h:138
void _disconnect()
Disconnects from Adafruit IO and the cellular network.
Definition: AdafruitIO_FONA.h:132
aio_status_t networkStatus()
Returns network connection status.
Definition: AdafruitIO_FONA.h:75
void _connect()
Establishes a connection to Adafruit IO.
Definition: AdafruitIO_FONA.h:111
Adafruit_MQTT * _mqtt
Definition: AdafruitIO.h:144
uint16_t _packetread_timeout
Definition: AdafruitIO.h:155
Class for interfacing with an Adafruit FONA Ceullar Module.
Definition: AdafruitIO_FONA.h:33
#define AIO_DEBUG_PRINTLN(...)
Prints line from debug output.
Definition: AdafruitIO_Definitions.h:89
SoftwareSerial * _serial
Definition: AdafruitIO_FONA.h:103
const char * connectionType()
Returns network module type.
Definition: AdafruitIO_FONA.h:98
Adafruit_FONA * _fona
Definition: AdafruitIO_FONA.h:104
const char * _host
Definition: AdafruitIO.h:149
aio_status_t
Definition: AdafruitIO_Definitions.h:142
uint16_t _mqtt_port
Definition: AdafruitIO_FONA.h:101