Ignore:
Timestamp:
Sep 25, 2020, 7:28:35 PM (4 years ago)
Author:
coas-nagasima
Message:

Azure IoT への送信内容を、検出したpersonとcarの数を送信するよう変更。
Azure IoT CentralからLEDのON/OFFが出来るよう更新。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • azure_iot_hub_riscv/trunk/app_iothub_client/src/esp_at_socket.c

    r458 r459  
    6161#include "azure_c_shared_utility/optimize_size.h"
    6262
     63#ifdef _MSC_VER
     64extern int sprintf_s(char* dst, size_t dstSizeInBytes, const char* format, ...);
     65#endif // _MSC_VER
     66
    6367//#define AT_DEBUG
    6468time_t MINIMUM_YEAR;
     
    306310{
    307311        struct tm tm = {
    308                 0,  /* tm_sec */
    309                 0,  /* tm_min */
    310                 0,  /* tm_hour */
    311                 1,  /* tm_mday */
    312                 0,  /* tm_mon */
    313                 2020 - 1900,  /* tm_year */
     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 */
    314318        };
    315319        MINIMUM_YEAR = mktime(&tm);
     
    426430                                return false;
    427431                        }
     432#ifdef AT_DEBUG
     433                        else{
     434                                append_char(esp_state, '\0');
     435                                printf("\"%s\"\r\n", esp_state->string);
     436                        }
     437#endif
    428438                }
    429439                else if (isalpha(c) || isdigit(c) || c == ' ') {
     
    432442                        return false;
    433443                }
     444#ifdef AT_DEBUG
     445                else{
     446                        append_char(esp_state, '\0');
     447                        printf("\"%s\"\r\n", esp_state->string);
     448                }
     449#endif
    434450                break;
    435451        case at_link_id:
     
    634650#ifdef AT_DEBUG
    635651        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);
    637653#endif
    638654        esp_state->parse_state = at_none;
     
    14871503                }
    14881504
    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);
    14901506                ret = esp_serial_write(esp_state, temp, &res_kind, 20000);
    14911507                if ((ret != E_OK) || (res_kind != at_response_kind_ok)) {
     
    14951511                esp_state->esp_state = esp_state_update_time;
    14961512        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");
    14981514                ret = esp_serial_write(esp_state, temp, &res_kind, 10000);
    14991515                if ((ret != E_OK) || (res_kind != at_response_kind_ok)) {
     
    15911607
    15921608        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);
    15951611        ret = esp_serial_write(connection->esp_state, temp, &res_kind, 10000);
    15961612        if ((ret != E_OK) || (res_kind != at_response_kind_connect)) {
     
    16301646        ER ret;
    16311647        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);
    16331649        ret = esp_serial_write(connection->esp_state, temp, &res_kind, 10000);
    16341650        if (ret == E_OK) {
     
    16561672        ER ret;
    16571673        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);
    16591675        ret = esp_serial_write(connection->esp_state, temp, &res_kind, 10000);
    16601676        if ((ret != E_OK) || (res_kind != at_response_kind_ok)) {
Note: See TracChangeset for help on using the changeset viewer.