diff --git a/Arduino_MKR1500NB.ino b/Arduino_MKR1500NB.ino index bcb24d8..d42ad06 100644 --- a/Arduino_MKR1500NB.ino +++ b/Arduino_MKR1500NB.ino @@ -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 #include #include +#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}}}"; @@ -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); @@ -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"); diff --git a/arduino_secrets.h b/arduino_secrets.h index 7fa7b9a..0b116cb 100644 --- a/arduino_secrets.h +++ b/arduino_secrets.h @@ -1,2 +1,11 @@ -#define SECRET_MQTTUSER "json+device" -#define SECRET_MQTTPASS "...put your API key here..." \ No newline at end of file +//// 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).