Skip to content

Commit c5dbace

Browse files
committed
update fona constructor
1 parent 4fe5e0c commit c5dbace

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

AdafruitIO_FONA.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,25 @@
99

1010
#include "AdafruitIO_FONA.h"
1111

12-
AdafruitIO_FONA::AdafruitIO_FONA(const char *apn, const char *apn_user, const char *apn_pass):AdafruitIO()
12+
AdafruitIO_FONA::AdafruitIO_FONA(const char *user, const char *key):AdafruitIO(user, key)
1313
{
14-
_apn = apn;
15-
_apn_user = apn_user;
16-
_apn_pass = apn_pass;
1714
_serial = new SoftwareSerial(FONA_TX, FONA_RX);
1815
_fona = new Adafruit_FONA(FONA_RST);
1916
_mqtt = new Adafruit_MQTT_FONA(_fona, _host, _port);
2017
}
2118

22-
AdafruitIO_FONA::AdafruitIO_FONA(const __FlashStringHelper *apn, const __FlashStringHelper *apn_user, const __FlashStringHelper *apn_pass):AdafruitIO()
19+
AdafruitIO_FONA::AdafruitIO_FONA(const __FlashStringHelper *user, const __FlashStringHelper *key):AdafruitIO(user, key)
2320
{
24-
_apn = (const char*)apn;
25-
_apn_user = (const char*)apn_user;
26-
_apn_pass = (const char*)apn_pass;
2721
_serial = new SoftwareSerial(FONA_TX, FONA_RX);
2822
_fona = new Adafruit_FONA(FONA_RST);
2923
_mqtt = new Adafruit_MQTT_FONA(_fona, _host, _port);
3024
}
3125

26+
void AdafruitIO_FONA::setAPN(FONAFlashStringPtr apn, FONAFlashStringPtr username=0, FONAFlashStringPtr password=0)
27+
{
28+
_fona->setGPRSNetworkSettings(apn, username, password);
29+
}
30+
3231
void AdafruitIO_FONA::_connect()
3332
{
3433

@@ -63,9 +62,6 @@ aio_status_t AdafruitIO_FONA::networkStatus()
6362
if(_fona->getNetworkStatus() != 1)
6463
return AIO_NET_DISCONNECTED;
6564

66-
// set apn info
67-
// _fona->setGPRSNetworkSettings(_apn, _apn_user, _apn_pass);
68-
6965
_fona->enableGPRS(true);
7066
return AIO_NET_CONNECTED;
7167

AdafruitIO_FONA.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626
class AdafruitIO_FONA : public AdafruitIO {
2727

2828
public:
29-
AdafruitIO_FONA(const char *apn, const char *apn_user, const char *apn_pass);
30-
AdafruitIO_FONA(const __FlashStringHelper *apn, const __FlashStringHelper *apn_user, const __FlashStringHelper *apn_pass);
29+
AdafruitIO_FONA(const char *user, const char *key);
30+
AdafruitIO_FONA(const __FlashStringHelper *user, const __FlashStringHelper *key);
31+
32+
void setAPN(FONAFlashStringPtr apn, FONAFlashStringPtr username=0, FONAFlashStringPtr password=0);
33+
3134
aio_status_t networkStatus();
3235

3336
protected:

examples/fona/fona.ino

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
// All text above must be included in any redistribution.
99
//
1010

11-
/************************** Cellular Setup **********************************/
12-
13-
#define APN ""
14-
#define APN_USER ""
15-
#define APN_PASS ""
16-
1711
/************************* Adafruit IO Setup ********************************/
1812

1913
#define IO_USERNAME "your_username"
@@ -22,7 +16,7 @@
2216
/*************************** Client Setup ***********************************/
2317

2418
#include "AdafruitIO_FONA.h"
25-
AdafruitIO_FONA io(APN, APN_USER, APN_PASS);
19+
AdafruitIO_FONA io(IO_USERNAME, IO_KEY);
2620

2721
/************************ Example Starts Here *******************************/
2822

@@ -43,7 +37,7 @@ void setup() {
4337
Serial.print("Connecting to Adafruit IO");
4438

4539
// connect to io.adafruit.com
46-
io.connect(IO_USERNAME, IO_KEY);
40+
io.connect();
4741

4842
// set up a message handler for the count feed.
4943
// the handleMessage function (defined below)

0 commit comments

Comments
 (0)