updated unix format ending
This commit is contained in:
@@ -54,6 +54,7 @@ extern int g_app_id;
|
|||||||
|
|
||||||
// public variable definitions
|
// public variable definitions
|
||||||
int credential_init_retry = 0;
|
int credential_init_retry = 0;
|
||||||
|
int g_runtime_env = RUNTIME_RELEASE;
|
||||||
iris_kit_settings_t iriskit_settings;
|
iris_kit_settings_t iriskit_settings;
|
||||||
bool iris_kit_settings_loaded = false;
|
bool iris_kit_settings_loaded = false;
|
||||||
|
|
||||||
@@ -199,6 +200,7 @@ void setup() {
|
|||||||
// prepare MQTT connection params
|
// prepare MQTT connection params
|
||||||
if (NULL != strstr(iris_server_address, "iris.irext.net")) {
|
if (NULL != strstr(iris_server_address, "iris.irext.net")) {
|
||||||
g_mqtt_server = String(MQTT_HOST_REL);
|
g_mqtt_server = String(MQTT_HOST_REL);
|
||||||
|
g_runtime_env = RUNTIME_RELEASE;
|
||||||
} else {
|
} else {
|
||||||
String iris_server_address_dev = iriskit_settings.server_address;
|
String iris_server_address_dev = iriskit_settings.server_address;
|
||||||
int delim = iris_server_address_dev.indexOf(':');
|
int delim = iris_server_address_dev.indexOf(':');
|
||||||
@@ -207,6 +209,7 @@ void setup() {
|
|||||||
} else {
|
} else {
|
||||||
g_mqtt_server = iris_server_address_dev;
|
g_mqtt_server = iris_server_address_dev;
|
||||||
}
|
}
|
||||||
|
g_runtime_env = RUNTIME_DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mqtt_client_id = g_device_name;
|
g_mqtt_client_id = g_device_name;
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
#ifndef IRIS_KIT_H
|
#ifndef IRIS_KIT_H
|
||||||
#define IRIS_KIT_H
|
#define IRIS_KIT_H
|
||||||
|
|
||||||
|
#define RUNTIME_RELEASE (0)
|
||||||
|
#define RUNTIME_DEBUG (1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
String server_address;
|
String server_address;
|
||||||
String credential_token;
|
String credential_token;
|
||||||
|
|||||||
@@ -39,6 +39,12 @@
|
|||||||
#define TOPIC_DOWNSTREAM_REL "/user/iris_kit_downstream"
|
#define TOPIC_DOWNSTREAM_REL "/user/iris_kit_downstream"
|
||||||
#define TOPIC_UPSTREAM_REL "/user/iris_kit_upstream"
|
#define TOPIC_UPSTREAM_REL "/user/iris_kit_upstream"
|
||||||
|
|
||||||
|
|
||||||
|
// external variable declarations
|
||||||
|
extern int g_runtime_env;
|
||||||
|
|
||||||
|
|
||||||
|
// public variable definitions
|
||||||
String g_mqtt_server = "";
|
String g_mqtt_server = "";
|
||||||
String g_product_key = "";
|
String g_product_key = "";
|
||||||
String g_device_name = "";
|
String g_device_name = "";
|
||||||
@@ -53,9 +59,13 @@ int g_mqtt_port = 1883;
|
|||||||
|
|
||||||
int g_app_id = 0;
|
int g_app_id = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// private variable definitions
|
||||||
static bool downstream_topic_subscribed = false;
|
static bool downstream_topic_subscribed = false;
|
||||||
static ep_state_t endpoint_state = FSM_IDLE;
|
static ep_state_t endpoint_state = FSM_IDLE;
|
||||||
|
|
||||||
|
|
||||||
|
// private function declarations
|
||||||
static int connectToMQTTBroker();
|
static int connectToMQTTBroker();
|
||||||
|
|
||||||
static void irisIrextIoTCallback(char *topic, uint8_t *data, uint32_t length);
|
static void irisIrextIoTCallback(char *topic, uint8_t *data, uint32_t length);
|
||||||
@@ -64,14 +74,16 @@ static int iot_retry = 0;
|
|||||||
|
|
||||||
static PubSubClient mqtt_client(wifi_client);
|
static PubSubClient mqtt_client(wifi_client);
|
||||||
|
|
||||||
|
|
||||||
|
// public function definitions
|
||||||
int connectToIrextIoT() {
|
int connectToIrextIoT() {
|
||||||
downstream_topic_subscribed = false;
|
downstream_topic_subscribed = false;
|
||||||
int conn_ret = -1;
|
int conn_ret = -1;
|
||||||
|
|
||||||
if (g_product_key.equals(IRIS_KIT_PK_DEV)) {
|
if (g_runtime_env == RUNTIME_DEBUG) {
|
||||||
g_upstream_topic = "/" + g_product_key + "/" + g_device_name + TOPIC_UPSTREAM_DEV;
|
g_upstream_topic = "/" + g_product_key + "/" + g_device_name + TOPIC_UPSTREAM_DEV;
|
||||||
g_downstream_topic = "/" + g_product_key + "/" + g_device_name + TOPIC_DOWNSTREAM_DEV;
|
g_downstream_topic = "/" + g_product_key + "/" + g_device_name + TOPIC_DOWNSTREAM_DEV;
|
||||||
} else if (g_product_key.equals(IRIS_KIT_PK_REL)) {
|
} else if (g_runtime_env == RUNTIME_RELEASE) {
|
||||||
g_upstream_topic = "/" + g_product_key + "/" + g_device_name + TOPIC_UPSTREAM_REL;
|
g_upstream_topic = "/" + g_product_key + "/" + g_device_name + TOPIC_UPSTREAM_REL;
|
||||||
g_downstream_topic = "/" + g_product_key + "/" + g_device_name + TOPIC_DOWNSTREAM_REL;
|
g_downstream_topic = "/" + g_product_key + "/" + g_device_name + TOPIC_DOWNSTREAM_REL;
|
||||||
} else {
|
} else {
|
||||||
@@ -125,6 +137,8 @@ void checkIrextIoT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private function definitions
|
||||||
static int connectToMQTTBroker() {
|
static int connectToMQTTBroker() {
|
||||||
int retry_times = 0;
|
int retry_times = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user