improve at firmware
This commit is contained in:
@@ -4,17 +4,17 @@
|
||||
#include "esp8266.h"
|
||||
#include "mqttclient.h"
|
||||
|
||||
//#define USE_ESP8266
|
||||
#define USE_ESP8266
|
||||
//#define USE_NB_BC35
|
||||
|
||||
#define USE_NB_BC35
|
||||
|
||||
#ifdef USE_ESP8266
|
||||
static hal_uart_port_t esp8266_port = HAL_UART_PORT_0;
|
||||
|
||||
void mqtt_set_esp8266_port(hal_uart_port_t port) {
|
||||
esp8266_port = port;
|
||||
}
|
||||
#endif
|
||||
/* Tencent IoThub Device Info */
|
||||
#define IOTHUB_MQTT_IP "111.230.189.156"
|
||||
#define IOTHUB_MQTT_PORT "1883"
|
||||
#define IOTHUB_MQTT_CLIENT_ID "KHHIXM0JJ5dev001"
|
||||
#define IOTHUB_MQTT_USERNAME "KHHIXM0JJ5dev001;12010126;9K3WO;1647628324"
|
||||
#define IOTHUB_MQTT_PASSWD "53696f22a061ed2524b1de185815ad2fcae7739afd3f395cb6131521da7f0bb7;hmacsha256"
|
||||
#define IOTHUB_MQTT_PUB_TOPIC "KHHIXM0JJ5/dev001/data"
|
||||
#define IOTHUB_MQTT_SUB_TOPIC "KHHIXM0JJ5/dev001/control"
|
||||
|
||||
static void tos_topic_handler(void* client, message_data_t* msg)
|
||||
{
|
||||
@@ -39,8 +39,8 @@ void mqttclient_task(void)
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
|
||||
#ifdef USE_ESP8266
|
||||
esp8266_sal_init(esp8266_port);
|
||||
esp8266_join_ap("Supowang", "13975428888");
|
||||
esp8266_sal_init(HAL_UART_PORT_0);
|
||||
esp8266_join_ap("Mculover666", "mculover666");
|
||||
#endif
|
||||
|
||||
#ifdef USE_NB_BC35
|
||||
@@ -52,18 +52,18 @@ void mqttclient_task(void)
|
||||
|
||||
client = mqtt_lease();
|
||||
|
||||
mqtt_set_port(client, "1883");
|
||||
mqtt_set_host(client, "111.230.189.156");
|
||||
mqtt_set_client_id(client, "RUAP1R610Vsupowang");
|
||||
mqtt_set_user_name(client, "RUAP1R610Vsupowang;12010126;80LJ2;1621294860");
|
||||
mqtt_set_password(client, "2e90a9f1e604f2f0473355228c3d59276951aa8e6ed4d27f270f05ee8a4d0983;hmacsha256");
|
||||
mqtt_set_port(client, IOTHUB_MQTT_PORT);
|
||||
mqtt_set_host(client, IOTHUB_MQTT_IP);
|
||||
mqtt_set_client_id(client, IOTHUB_MQTT_CLIENT_ID);
|
||||
mqtt_set_user_name(client, IOTHUB_MQTT_USERNAME);
|
||||
mqtt_set_password(client, IOTHUB_MQTT_PASSWD);
|
||||
mqtt_set_clean_session(client, 1);
|
||||
|
||||
error = mqtt_connect(client);
|
||||
|
||||
MQTT_LOG_D("mqtt connect error is %#x", error);
|
||||
|
||||
mqtt_subscribe(client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
|
||||
mqtt_subscribe(client, IOTHUB_MQTT_SUB_TOPIC, QOS0, tos_topic_handler);
|
||||
|
||||
MQTT_LOG_D("mqtt subscribe error is %#x", error);
|
||||
|
||||
@@ -76,7 +76,7 @@ void mqttclient_task(void)
|
||||
msg.qos = QOS0;
|
||||
msg.payload = (void *) buf;
|
||||
|
||||
error = mqtt_publish(client, "RUAP1R610V/supowang/data", &msg);
|
||||
error = mqtt_publish(client, IOTHUB_MQTT_PUB_TOPIC, &msg);
|
||||
|
||||
tos_task_delay(4000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user