fix bug in esp8266_tc driver
This commit is contained in:
@@ -60,13 +60,15 @@ int esp8266_tencent_firmware_module_mqtt_publ(const char *topic, qos_t qos, char
|
|||||||
at_echo_t echo;
|
at_echo_t echo;
|
||||||
|
|
||||||
tos_at_echo_create(&echo, NULL, 0, ">");
|
tos_at_echo_create(&echo, NULL, 0, ">");
|
||||||
|
|
||||||
|
strcat(payload, "\r\n");
|
||||||
|
|
||||||
tos_at_cmd_exec_until(&echo, 1000, "AT+TCMQTTPUBL=\"%s\",%d,%d\r\n", topic, qos, strlen(payload)-2);
|
tos_at_cmd_exec_until(&echo, 1000, "AT+TCMQTTPUBL=\"%s\",%d,%d\r\n", topic, qos, strlen(payload)-2);
|
||||||
if (echo.status != AT_ECHO_STATUS_EXPECT) {
|
if (echo.status != AT_ECHO_STATUS_EXPECT) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tos_at_echo_create(&echo, NULL, 0, "+TCMQTTPUB:OK");
|
tos_at_echo_create(&echo, NULL, 0, "+TCMQTTPUBL:OK");
|
||||||
tos_at_raw_data_send_until(&echo, 1000, (uint8_t *)payload, strlen(payload));
|
tos_at_raw_data_send_until(&echo, 1000, (uint8_t *)payload, strlen(payload));
|
||||||
if (echo.status != AT_ECHO_STATUS_EXPECT) {
|
if (echo.status != AT_ECHO_STATUS_EXPECT) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -165,10 +167,11 @@ int esp8266_tencent_firmware_join_ap(const char *ssid, const char *pwd)
|
|||||||
|
|
||||||
tos_at_echo_create(&echo, NULL, 0, NULL);
|
tos_at_echo_create(&echo, NULL, 0, NULL);
|
||||||
while (try++ < 10) {
|
while (try++ < 10) {
|
||||||
tos_at_cmd_exec(&echo, 15000, "AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, pwd);
|
tos_at_cmd_exec(&echo, 30000, "AT+CWJAP=\"%s\",\"%s\"\r\n", ssid, pwd);
|
||||||
if (echo.status == AT_ECHO_STATUS_OK) {
|
if (echo.status == AT_ECHO_STATUS_OK) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
tos_sleep_ms(2000);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -93,7 +93,7 @@ typedef struct mqtt_message_handlers_st {
|
|||||||
|
|
||||||
extern k_mail_q_t mqtt_message_mail;
|
extern k_mail_q_t mqtt_message_mail;
|
||||||
|
|
||||||
#define DEFAULT_MQTT_PARAMS { TLS_MODE_PSK, MQTT_COMMAND_TIMEOUT, 240, 1, 1 }
|
#define DEFAULT_MQTT_PARAMS { TLS_MODE_PSK, MQTT_COMMAND_TIMEOUT, 240, 1, 0 }
|
||||||
|
|
||||||
typedef struct device_info_st {
|
typedef struct device_info_st {
|
||||||
char product_id[PRODUCT_ID_MAX_SIZE + 1];
|
char product_id[PRODUCT_ID_MAX_SIZE + 1];
|
||||||
|
Reference in New Issue
Block a user