fix mqttclient sample compilation error of board-TencentOS_tiny_EVB_MX_Plus ...
This commit is contained in:
@@ -16,16 +16,13 @@ void mqtt_set_esp8266_port(hal_uart_port_t port) {
|
||||
}
|
||||
#endif
|
||||
|
||||
mqtt_client_t client;
|
||||
client_init_params_t init_params;
|
||||
|
||||
static void tos_topic_handler(void* client, message_data_t* msg)
|
||||
{
|
||||
(void) client;
|
||||
LOG_I("-----------------------------------------------------------------------------------");
|
||||
LOG_I("%s:%d %s()...\ntopic: %s, qos: %d. \nmessage:\n\t%s\n", __FILE__, __LINE__, __FUNCTION__,
|
||||
MQTT_LOG_I("-----------------------------------------------------------------------------------");
|
||||
MQTT_LOG_I("%s:%d %s()...\ntopic: %s, qos: %d. \nmessage:\n\t%s\n", __FILE__, __LINE__, __FUNCTION__,
|
||||
msg->topic_name, msg->message->qos, (char*)msg->message->payload);
|
||||
LOG_I("-----------------------------------------------------------------------------------\n");
|
||||
MQTT_LOG_I("-----------------------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +32,8 @@ void mqttclient_task(void)
|
||||
|
||||
char buf[100] = { 0 };
|
||||
|
||||
mqtt_client_t *client = NULL;
|
||||
|
||||
mqtt_message_t msg;
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
@@ -49,33 +48,24 @@ void mqttclient_task(void)
|
||||
bc35_28_95_sal_init(HAL_UART_PORT_0);
|
||||
#endif
|
||||
|
||||
init_params.read_buf_size = 256;
|
||||
init_params.write_buf_size = 256;
|
||||
|
||||
#ifdef MQTT_NETWORK_TYPE_TLS
|
||||
init_params.connect_params.network_params.network_ssl_params.ca_crt = test_ca_get();
|
||||
init_params.connect_params.network_params.port = "8883";
|
||||
#else
|
||||
init_params.connect_params.network_params.port = "1883";
|
||||
#endif
|
||||
init_params.connect_params.network_params.addr = "111.230.189.156"; //"47.95.164.112";//"jiejie01.top"; //"129.204.201.235"; //"192.168.1.101";
|
||||
mqtt_log_init();
|
||||
|
||||
init_params.connect_params.user_name = "RUAP1R610Vsupowang;12010126;80LJ2;1621294860"; // random_string(10); //"jiejietop-acer1";
|
||||
init_params.connect_params.password = "2e90a9f1e604f2f0473355228c3d59276951aa8e6ed4d27f270f05ee8a4d0983;hmacsha256"; //random_string(10); // "123456";
|
||||
init_params.connect_params.client_id = "RUAP1R610Vsupowang";; //random_string(10); // "clientid-acer1";
|
||||
init_params.connect_params.clean_session = 1;
|
||||
|
||||
log_init();
|
||||
|
||||
mqtt_init(&client, &init_params);
|
||||
|
||||
error = mqtt_connect(&client);
|
||||
client = mqtt_lease();
|
||||
|
||||
LOG_D("mqtt connect error is %#x", error);
|
||||
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_clean_session(client, 1);
|
||||
|
||||
error = mqtt_connect(client);
|
||||
|
||||
mqtt_subscribe(&client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
|
||||
MQTT_LOG_D("mqtt connect error is %#x", error);
|
||||
|
||||
LOG_D("mqtt subscribe error is %#x", error);
|
||||
mqtt_subscribe(client, "RUAP1R610V/supowang/data", QOS0, tos_topic_handler);
|
||||
|
||||
MQTT_LOG_D("mqtt subscribe error is %#x", error);
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
|
||||
@@ -86,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, "RUAP1R610V/supowang/data", &msg);
|
||||
|
||||
tos_task_delay(4000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user