Skip to content

Commit

Permalink
Adding the possibility to specify APN settings in the SECRETS file
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelain authored Mar 30, 2020
1 parent dd27d59 commit ce38c7a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
21 changes: 16 additions & 5 deletions Arduino_MKR1500NB.ino
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
#define DEFAULT_TX_FREQUENCY 60
#define DEFAULT_TX_FREQUENCY 60 // message rate by default
// (can be updated over the air from Live Objects platform)

#include "arduino_secrets.h"
#include <ArduinoMqttClient.h>
#include <ArduinoJson.h>
#include <MKRNB.h>

#define sw_revision "1.0.1"

NB nbAccess;
//GPRS gprs;
NBClient nbClient;
MqttClient mqttClient(nbClient);

const char mqtt_user[] = SECRET_MQTTUSER;
const char mqtt_pass[] = SECRET_MQTTPASS;
const char mqtt_user[] = "json+device";
const char mqtt_pass[] = SECRET_LIVEOBJECTS_API_KEY;
const char mqtt_id[] = "MKRNB1500";
const char mqtt_broker[] = "liveobjects.orange-business.com";
const char mqtt_pubdata[] = "dev/data";
const char mqtt_pubcfg[] = "dev/cfg";
const char mqtt_subcfg[] = "dev/cfg/upd";

const char pin[] = SECRET_PINNUMBER;
const char apn[] = SECRET_APN;
const char apn_user[] = SECRET_APN_USER;
const char apn_pass[] = SECRET_APN_PASS;

const char* JSONdata = "{\"model\":\"github_sample_MKR\",\"value\":{\"uptime\":0}}";
const char* JSONcfg= "{\"cfg\":{\"transmit frequency (s)\":{\"t\":\"u32\",\"v\":0}}}";

Expand All @@ -33,6 +41,9 @@ void connectionManager(bool _way);
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.print("\n\n***\nUsing Arduino LTE-M with Live Objects\nversion ");
Serial.println(sw_revision);
Serial.println("***\n");

mqttClient.setId(mqtt_id);
mqttClient.setUsernamePassword(mqtt_user, mqtt_pass);
Expand Down Expand Up @@ -66,8 +77,8 @@ void connectionManager(bool _way = 1) {
case 1:
Serial.print("Connecting to cellular network");
//while ((nbAccess.begin() != NB_READY) || (gprs.attachGPRS() != GPRS_READY))
while (nbAccess.begin() != NB_READY)
Serial.print(".");
while (nbAccess.begin(pin, apn, apn_user, apn_pass) != NB_READY)
Serial.print(".");

Serial.println("\nYou're connected to the network");

Expand Down
13 changes: 11 additions & 2 deletions arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
#define SECRET_MQTTUSER "json+device"
#define SECRET_MQTTPASS "...put your API key here..."
//// cellular connection cerdentials
#define SECRET_PINNUMBER "" // unless PIN is deactivated, specify your SIM card PIN number
#define SECRET_APN "" // specify the APN name (if needed)
#define SECRET_APN_USER "" // specify the username for your APN (if needed)
#define SECRET_APN_PASS "" // specify the password for your APN (if needed)


//// your Live Objects credential
#define SECRET_LIVEOBJECTS_API_KEY "..." // paste here the Live Objects API key for your device.
// You API key must have the predefined 'MQTT Device' right (alternatively: 'Device Access' read + write rights).
// If your API key has more important rights, you *need* to use a TLS connection (MQTTS).

0 comments on commit ce38c7a

Please sign in to comment.