- Timestamp:
- Sep 25, 2020, 7:28:35 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub_riscv/trunk/app_iothub_client/src/esp_at_socket.c
r458 r459 61 61 #include "azure_c_shared_utility/optimize_size.h" 62 62 63 #ifdef _MSC_VER 64 extern int sprintf_s(char* dst, size_t dstSizeInBytes, const char* format, ...); 65 #endif // _MSC_VER 66 63 67 //#define AT_DEBUG 64 68 time_t MINIMUM_YEAR; … … 306 310 { 307 311 struct tm tm = { 308 309 310 311 312 313 312 0, /* tm_sec */ 313 0, /* tm_min */ 314 0, /* tm_hour */ 315 1, /* tm_mday */ 316 0, /* tm_mon */ 317 2020 - 1900, /* tm_year */ 314 318 }; 315 319 MINIMUM_YEAR = mktime(&tm); … … 426 430 return false; 427 431 } 432 #ifdef AT_DEBUG 433 else{ 434 append_char(esp_state, '\0'); 435 printf("\"%s\"\r\n", esp_state->string); 436 } 437 #endif 428 438 } 429 439 else if (isalpha(c) || isdigit(c) || c == ' ') { … … 432 442 return false; 433 443 } 444 #ifdef AT_DEBUG 445 else{ 446 append_char(esp_state, '\0'); 447 printf("\"%s\"\r\n", esp_state->string); 448 } 449 #endif 434 450 break; 435 451 case at_link_id: … … 634 650 #ifdef AT_DEBUG 635 651 if (esp_state->parse_state != at_none) 636 printf("\033[35mparse error. state:%d \033[0m\r\n", esp_state->parse_state);652 printf("\033[35mparse error. state:%d, char:%d\033[0m\r\n", esp_state->parse_state, c); 637 653 #endif 638 654 esp_state->parse_state = at_none; … … 1487 1503 } 1488 1504 1489 sprintf (temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", esp_state->ssid, esp_state->pwd);1505 sprintf_s(temp, sizeof(temp), "AT+CWJAP=\"%s\",\"%s\"\r\n", esp_state->ssid, esp_state->pwd); 1490 1506 ret = esp_serial_write(esp_state, temp, &res_kind, 20000); 1491 1507 if ((ret != E_OK) || (res_kind != at_response_kind_ok)) { … … 1495 1511 esp_state->esp_state = esp_state_update_time; 1496 1512 case esp_state_update_time: 1497 sprintf (temp, "AT+CIPSNTPCFG=%d,%d,\"%s\"\r\n", 1, 9, "ntp.nict.jp");1513 sprintf_s(temp, sizeof(temp), "AT+CIPSNTPCFG=%d,%d,\"%s\"\r\n", 1, 9, "ntp.nict.jp"); 1498 1514 ret = esp_serial_write(esp_state, temp, &res_kind, 10000); 1499 1515 if ((ret != E_OK) || (res_kind != at_response_kind_ok)) { … … 1591 1607 1592 1608 ER ret; 1593 char temp[ 64];1594 sprintf (temp, "AT+CIPSTART=%d,\"%s\",\"%s\",%d\r\n", connection->link_id, connection->ssl, host, port);1609 char temp[128]; 1610 sprintf_s(temp, sizeof(temp), "AT+CIPSTART=%d,\"%s\",\"%s\",%d\r\n", connection->link_id, connection->ssl, host, port); 1595 1611 ret = esp_serial_write(connection->esp_state, temp, &res_kind, 10000); 1596 1612 if ((ret != E_OK) || (res_kind != at_response_kind_connect)) { … … 1630 1646 ER ret; 1631 1647 char temp[64]; 1632 sprintf (temp, "AT+CIPCLOSE=%d\r\n", connection->link_id);1648 sprintf_s(temp, sizeof(temp), "AT+CIPCLOSE=%d\r\n", connection->link_id); 1633 1649 ret = esp_serial_write(connection->esp_state, temp, &res_kind, 10000); 1634 1650 if (ret == E_OK) { … … 1656 1672 ER ret; 1657 1673 char temp[64]; 1658 sprintf (temp, "AT+CIPSEND=%d,%d\r\n", connection->link_id, length);1674 sprintf_s(temp, sizeof(temp), "AT+CIPSEND=%d,%d\r\n", connection->link_id, length); 1659 1675 ret = esp_serial_write(connection->esp_state, temp, &res_kind, 10000); 1660 1676 if ((ret != E_OK) || (res_kind != at_response_kind_ok)) {
Note:
See TracChangeset
for help on using the changeset viewer.