Skip to content

Commit 748d2ab

Browse files
committed
Define IP address of MQTT_LOCALBROKER
Signed-off-by: John Walicki <[email protected]>
1 parent 402f84d commit 748d2ab

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

firmware/WatsonIoT/src/config.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,3 @@
2323
#define RECONNECTION_TO 10000 //ms
2424

2525
#define PRODUCTION_BOARD 1
26-
27-
// Run this firmware with a MQTT Broker on a local subnet
28-
//#define LOCALNET

firmware/WatsonIoT/src/main.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020
#define OPENEEW_ACTIVATION_ENDPOINT "https://openeew-devicemgmt.mybluemix.net/activation?ver=1"
2121
#define OPENEEW_FIRMWARE_VERSION "1.4.0"
2222

23+
// Run this firmware with a MQTT Broker on a local subnet
24+
// Comment this Define to send data to the Cloud
25+
#define MQTT_LOCALBROKER "192.168.1.101"
26+
2327
// Watson IoT connection details
2428
static char MQTT_HOST[48]; // ORGID.messaging.internetofthings.ibmcloud.com
2529
static char MQTT_DEVICEID[30]; // Allocate a buffer large enough for "d:orgid:devicetype:deviceid"
2630
static char MQTT_ORGID[7]; // Watson IoT 6 character orgid
27-
#ifdef LOCALNET
31+
#ifdef MQTT_LOCALBROKER
2832
#define MQTT_PORT 1883 // Secure MQTT 8883 / Insecure MQTT 1883
2933
#else
3034
#define MQTT_PORT 8883 // Secure MQTT 8883 / Insecure MQTT 1883
@@ -50,7 +54,7 @@ char deviceID[13];
5054

5155
// MQTT objects
5256
void callback(char* topic, byte* payload, unsigned int length);
53-
#ifdef LOCALNET
57+
#ifdef MQTT_LOCALBROKER
5458
WiFiClient wifiClient; // Insecure MQTT
5559
#else
5660
WiFiClientSecure wifiClient; // Secure MQTT
@@ -737,8 +741,8 @@ void setup() {
737741
sprintf(MQTT_DEVICEID,"d:%s:%s:%02X%02X%02X%02X%02X%02X",MQTT_ORGID,MQTT_DEVICETYPE,mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
738742
Serial.println(MQTT_DEVICEID);
739743

740-
#ifdef LOCALNET
741-
sprintf(MQTT_HOST,"192.168.1.101"); // Enter the IP address of the MQTT broker on your local subnet
744+
#ifdef MQTT_LOCALBROKER
745+
sprintf(MQTT_HOST,MQTT_LOCALBROKER); // Enter the IP address of the MQTT broker on your local subnet
742746
#else
743747
sprintf(MQTT_HOST,"%s.messaging.internetofthings.ibmcloud.com",MQTT_ORGID); // Centrally managed
744748
#endif

0 commit comments

Comments
 (0)