2024-08-05 09:18:38 +00:00
|
|
|
|
#include "EC801E.h"
|
|
|
|
|
#include "stdio.h"
|
|
|
|
|
#include "usart.h"
|
|
|
|
|
#include "string.h"
|
|
|
|
|
#include "cJSON.h"
|
2024-08-06 07:33:33 +00:00
|
|
|
|
#include "uart_dev.h"
|
2024-08-06 09:07:23 +00:00
|
|
|
|
#include "anemometer_dev.h"
|
2024-08-05 09:18:38 +00:00
|
|
|
|
|
2024-08-07 09:26:49 +00:00
|
|
|
|
#define USE_UTC 1
|
|
|
|
|
|
|
|
|
|
uint32_t g_time_stamp;
|
|
|
|
|
|
2024-08-16 02:45:39 +00:00
|
|
|
|
void parse_json(uint8_t *json_buff);
|
|
|
|
|
|
|
|
|
|
|
2024-08-05 09:18:38 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϵ粢<CFB5><E7B2A2><EFBFBD><EFBFBD>
|
|
|
|
|
void EC801E_Power_ON()
|
|
|
|
|
{
|
|
|
|
|
// PWR_KEY_4G_Pin<69>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>ϵ<EFBFBD><CFB5>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
HAL_GPIO_WritePin(GPIO_4G_PWR_KEY_GPIO_Port, GPIO_4G_PWR_KEY_Pin, GPIO_PIN_SET);
|
|
|
|
|
//<2F>ϵ<EFBFBD>
|
|
|
|
|
HAL_GPIO_WritePin(GPIO_4G_PWR_CTRL_GPIO_Port, GPIO_4G_PWR_CTRL_Pin, GPIO_PIN_SET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
|
|
|
|
//HAL_OK:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
uint8_t Read_Status()
|
|
|
|
|
{
|
|
|
|
|
uint8_t temp_status = HAL_ERROR;
|
|
|
|
|
temp_status = HAL_GPIO_ReadPin(GPIO_4G_STATUS_GPIO_Port, GPIO_4G_STATUS_Pin) == GPIO_PIN_SET ? HAL_OK : HAL_ERROR;
|
|
|
|
|
return temp_status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>ӡ
|
|
|
|
|
size_t __write(int handle, const unsigned char * buffer, size_t size)
|
|
|
|
|
{
|
|
|
|
|
if(HAL_OK == HAL_UART_Transmit(&huart1,(uint8_t *)buffer,size,100000))
|
|
|
|
|
{
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MQTT<54>ͻ<F2BFAABF><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD>
|
|
|
|
|
void MQTT_Config()
|
|
|
|
|
{
|
|
|
|
|
// ȷ<><C8B7>4Gģ<47><C4A3><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
2024-08-06 07:33:33 +00:00
|
|
|
|
osDelay(5000);
|
2024-08-09 03:03:03 +00:00
|
|
|
|
uart_sendstr(g_ec801_uart_handle, "AT+QMTCFG=\"session\",0,0\r\n");
|
|
|
|
|
osDelay(5000);
|
2024-08-05 09:18:38 +00:00
|
|
|
|
// <20>ͻ<F2BFAABF><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-08-06 07:33:33 +00:00
|
|
|
|
uart_sendstr(g_ec801_uart_handle, "AT+QMTOPEN=0,199.7.140.10,1883\r\n");
|
|
|
|
|
// HAL_UART_Transmit(&huart5, (uint8_t *)"AT+QMTOPEN=0,199.7.140.10,1883\r\n", 30, 0xFFFF);
|
2024-08-05 09:18:38 +00:00
|
|
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-08-06 07:33:33 +00:00
|
|
|
|
osDelay(5000);
|
2024-08-05 09:18:38 +00:00
|
|
|
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD>
|
2024-08-06 07:33:33 +00:00
|
|
|
|
uart_sendstr(g_ec801_uart_handle, "AT+QMTCONN=0,Test_SUB\r\n");
|
|
|
|
|
// HAL_UART_Transmit(&huart5, (uint8_t *)"AT+QMTCONN=0,Test_SUB\r\n", sizeof("AT+QMTCONN=0,Test_SUB\r\n"), 0xFFFF);
|
2024-08-05 09:18:38 +00:00
|
|
|
|
// ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-08-06 07:33:33 +00:00
|
|
|
|
osDelay(5000);
|
2024-08-05 09:18:38 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-08-06 07:33:33 +00:00
|
|
|
|
uart_sendstr(g_ec801_uart_handle, "AT+QMTSUB=0,0,Test_Topic,0\r\n");
|
|
|
|
|
// HAL_UART_Transmit(&huart5, (uint8_t *)"AT+QMTSUB=0,0,Test_Topic,0\r\n", sizeof("AT+QMTSUB=0,0,Test_Topic,0\r\n"), 0xFFFF);
|
2024-08-05 09:18:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-07 09:26:49 +00:00
|
|
|
|
// MQTT<54><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-08-15 01:06:11 +00:00
|
|
|
|
void MQTT_Trans_Data( )
|
2024-08-05 09:18:38 +00:00
|
|
|
|
{
|
2024-08-07 09:26:49 +00:00
|
|
|
|
//<2F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
uint8_t str_len = 0;
|
|
|
|
|
char str_len_str[32];
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
2024-08-06 09:07:23 +00:00
|
|
|
|
float32_t *ptr = (float32_t *)&g_stMcs_Para;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>JSON<4F><4E><EFBFBD>鼰<EFBFBD><E9BCB0><EFBFBD><EFBFBD>
|
2024-08-05 09:18:38 +00:00
|
|
|
|
char *cjson_str = NULL;
|
|
|
|
|
cJSON * JsonRoot = cJSON_CreateObject();
|
2024-08-06 09:07:23 +00:00
|
|
|
|
cJSON * DataArray = cJSON_CreateArray();
|
2024-08-05 09:18:38 +00:00
|
|
|
|
|
2024-08-07 09:26:49 +00:00
|
|
|
|
cJSON_AddStringToObject(JsonRoot, "deviId", "item_id");
|
|
|
|
|
cJSON_AddStringToObject(JsonRoot, "frameType", "item_type");
|
|
|
|
|
cJSON_AddNumberToObject(JsonRoot, "timeStamp", g_time_stamp);
|
2024-08-15 01:06:11 +00:00
|
|
|
|
cJSON_AddNumberToObject(JsonRoot, "version", 10);
|
2024-08-05 09:18:38 +00:00
|
|
|
|
|
2024-08-06 09:07:23 +00:00
|
|
|
|
cJSON_AddItemToObject(JsonRoot, "data", DataArray);//<2F><><EFBFBD><EFBFBD>data<74><61><EFBFBD><EFBFBD>
|
|
|
|
|
|
2024-08-08 02:59:28 +00:00
|
|
|
|
for(int i = 0; i < sizeof(mcs_para)/sizeof(float32_t) - 2; i++)// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仹<EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD>
|
2024-08-06 09:07:23 +00:00
|
|
|
|
{
|
2024-08-08 02:59:28 +00:00
|
|
|
|
cJSON_AddItemToArray(DataArray, cJSON_CreateNumber(((float)((int )(ptr[i] * 100 + 0.5)))/100.0));// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λС<CEBB><D0A1>
|
2024-08-06 09:07:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-07 09:26:49 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ת<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
2024-08-05 09:18:38 +00:00
|
|
|
|
cjson_str = cJSON_Print(JsonRoot);
|
2024-08-07 09:26:49 +00:00
|
|
|
|
|
2024-08-08 02:59:28 +00:00
|
|
|
|
str_len = strlen(cjson_str) + 2 + 4;
|
2024-08-07 09:26:49 +00:00
|
|
|
|
sprintf(str_len_str, "%d", str_len);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
osDelay(2000);
|
|
|
|
|
uart_sendstr(g_ec801_uart_handle, "AT+QMTPUBEX=0,0,0,0,Test_Topic,");
|
|
|
|
|
uart_sendstr(g_ec801_uart_handle, str_len_str);
|
|
|
|
|
uart_sendstr(g_ec801_uart_handle, "\r\n");
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|
|
|
|
osDelay(2000);
|
|
|
|
|
uart_sendstr(g_ec801_uart_handle, cjson_str);
|
2024-08-08 02:59:28 +00:00
|
|
|
|
// uart_sendstr(g_ec801_uart_handle, "\r\n");
|
2024-08-06 09:07:23 +00:00
|
|
|
|
|
2024-08-07 09:26:49 +00:00
|
|
|
|
//<2F>ͷ<EFBFBD>
|
|
|
|
|
vPortFree(cjson_str);
|
2024-08-05 09:18:38 +00:00
|
|
|
|
cJSON_Delete(JsonRoot);
|
2024-08-06 09:07:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-07 09:26:49 +00:00
|
|
|
|
// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>꣬1<EAA3AC><31>0ƽ
|
|
|
|
|
uint16_t fml_leap_year(uint16_t year)
|
2024-08-06 09:07:23 +00:00
|
|
|
|
{
|
2024-08-07 09:26:49 +00:00
|
|
|
|
return (((year % 4 == 0)&&(year % 100 != 0)) || (year % 400 == 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>תʱ<D7AA><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
uint32_t fml_time_to_stamp(int year, int month, int day, int hour, int minute, int second)
|
|
|
|
|
{
|
|
|
|
|
static uint32_t dax = 0;
|
|
|
|
|
static uint32_t day_count = 0;
|
|
|
|
|
uint16_t leap_year_count = 0;
|
|
|
|
|
uint16_t i;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
for (i = 1970; i < year; i++)
|
|
|
|
|
{
|
|
|
|
|
if (fml_leap_year(i))
|
|
|
|
|
{
|
|
|
|
|
leap_year_count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
day_count = leap_year_count * 366 + (year - 1970 - leap_year_count) * 365;
|
|
|
|
|
|
|
|
|
|
uint8_t mouthday[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
|
|
|
|
// <20><><EFBFBD>㵱<EFBFBD>굽<EFBFBD><EAB5BD>ǰ<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < month; i++)
|
|
|
|
|
{
|
|
|
|
|
day_count += mouthday[i];
|
|
|
|
|
}
|
|
|
|
|
if(fml_leap_year(year))
|
|
|
|
|
{
|
|
|
|
|
day_count += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20>ۼӼ<DBBC><D3BC>㵱<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
day_count += (day - 1);
|
|
|
|
|
|
|
|
|
|
dax = (uint32_t)(day_count * 86400) + (uint32_t)((uint32_t)hour * 3600) + (uint32_t)((uint32_t)minute * 60) + (uint32_t)second;
|
|
|
|
|
|
|
|
|
|
return dax;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-08-15 08:35:33 +00:00
|
|
|
|
//ʱ<><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʼMQTT<54><54>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|
|
|
|
uint8_t time_get_ok = 0;
|
2024-08-07 09:26:49 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
2024-08-15 08:35:33 +00:00
|
|
|
|
int EC801_GET_Time()
|
2024-08-07 09:26:49 +00:00
|
|
|
|
{
|
|
|
|
|
int year, month, day, hour, minute, second;
|
|
|
|
|
if(USE_UTC)
|
|
|
|
|
{
|
|
|
|
|
uart_sendstr(g_ec801_uart_handle, "AT+QLTS=0\r\n");
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
uart_sendstr(g_ec801_uart_handle, "AT+QLTS=2\r\n");
|
|
|
|
|
}
|
|
|
|
|
osDelay(1000);
|
|
|
|
|
char time[100] = {0};int index = 0;
|
|
|
|
|
|
|
|
|
|
// <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬ǰ<E4A3AC>治Ҫ
|
|
|
|
|
do{
|
|
|
|
|
time[index] = uart_dev_in_char(g_ec801_uart_handle);
|
2024-08-15 08:35:33 +00:00
|
|
|
|
}while(time[index++] != '"' && uart_dev_char_present(g_ec801_uart_handle));
|
2024-08-07 09:26:49 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
memcpy(time, time + index - 1, index);
|
|
|
|
|
index = 1;
|
|
|
|
|
|
|
|
|
|
// "ǰ<><C7B0><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
do{
|
|
|
|
|
time[index] = uart_dev_in_char(g_ec801_uart_handle);
|
2024-08-15 08:35:33 +00:00
|
|
|
|
}while(time[index++] != '"' && uart_dev_char_present(g_ec801_uart_handle));
|
2024-08-07 09:26:49 +00:00
|
|
|
|
|
|
|
|
|
// <20>ַ<EFBFBD><D6B7><EFBFBD>ȡ<EFBFBD><C8A1>int
|
2024-08-15 08:35:33 +00:00
|
|
|
|
sscanf(time, "\"%d/%d/%d,%d:%d:%d\"", &year, &month, &day, &hour, &minute, &second);
|
2024-08-06 09:07:23 +00:00
|
|
|
|
|
2024-08-15 08:35:33 +00:00
|
|
|
|
if(year)
|
|
|
|
|
{
|
|
|
|
|
time_get_ok = 1;
|
|
|
|
|
}
|
2024-08-07 09:26:49 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
g_time_stamp = fml_time_to_stamp(year, month, day, hour, minute, second);
|
2024-08-15 08:35:33 +00:00
|
|
|
|
return year;
|
2024-08-08 02:59:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-15 08:35:33 +00:00
|
|
|
|
#define JSON_BUFFER_SIZE 200
|
2024-08-15 01:06:11 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>4gģ<67><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void parse_4g_receive_data()
|
2024-08-15 08:35:33 +00:00
|
|
|
|
{
|
|
|
|
|
uint8_t temp_buff[JSON_BUFFER_SIZE];
|
|
|
|
|
int jsonBufferIndex = 0; // <20><><EFBFBD><EFBFBD>
|
2024-08-15 01:06:11 +00:00
|
|
|
|
char c = 0;
|
2024-08-15 08:35:33 +00:00
|
|
|
|
int inJson = 0;
|
2024-08-15 01:06:11 +00:00
|
|
|
|
if(uart_dev_char_present(g_ec801_uart_handle)){
|
2024-08-15 09:42:15 +00:00
|
|
|
|
memset(temp_buff, '\0', sizeof(temp_buff));//ÿ<>ν<EFBFBD><CEBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>BUFF
|
2024-08-15 08:35:33 +00:00
|
|
|
|
for(jsonBufferIndex = 0; uart_dev_char_present(g_ec801_uart_handle);)
|
2024-08-15 01:06:11 +00:00
|
|
|
|
{
|
|
|
|
|
c = uart_dev_in_char(g_ec801_uart_handle);
|
2024-08-15 08:35:33 +00:00
|
|
|
|
if (c == '{') {
|
|
|
|
|
inJson = 1; // <20><><EFBFBD><EFBFBD>JSON<4F>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
jsonBufferIndex = 0; // <20><><EFBFBD><EFBFBD>JSON<4F><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
temp_buff[jsonBufferIndex++] = c;
|
|
|
|
|
} else if (c == '}' && inJson) {
|
|
|
|
|
temp_buff[jsonBufferIndex++] = c;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
|
|
|
|
jsonBufferIndex = 0;
|
|
|
|
|
inJson = 0;
|
|
|
|
|
} else if (inJson) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>JSON<4F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>ַ<EFBFBD>
|
|
|
|
|
if (jsonBufferIndex < JSON_BUFFER_SIZE - 1) { // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>λ<EFBFBD>ø<EFBFBD><C3B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
temp_buff[jsonBufferIndex++] = c;
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
jsonBufferIndex++;//һֱû<D6B1><C3BB>{<7B><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-08-15 01:06:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-16 02:45:39 +00:00
|
|
|
|
// temp_buffΪ<66><CEAA><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>JSON
|
|
|
|
|
// term_printf(temp_buff);
|
|
|
|
|
// <20><>Ϊ<EFBFBD><CEAA><EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD>
|
|
|
|
|
if(temp_buff[0] != '\0')
|
|
|
|
|
{
|
|
|
|
|
parse_json(temp_buff);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void parse_json(uint8_t *json_buff)
|
|
|
|
|
{
|
|
|
|
|
cJSON* cjson_root = cJSON_Parse(json_buff);
|
|
|
|
|
|
|
|
|
|
if(cjson_root == NULL)
|
|
|
|
|
{
|
|
|
|
|
term_printf("parse fail.\n");
|
|
|
|
|
return;
|
2024-08-15 01:06:11 +00:00
|
|
|
|
}
|
2024-08-16 02:45:39 +00:00
|
|
|
|
|
|
|
|
|
cJSON* cjson_id = cJSON_GetObjectItem(cjson_root, "deviId");
|
|
|
|
|
cJSON* cjson_type = cJSON_GetObjectItem(cjson_root, "frameType");
|
|
|
|
|
cJSON* cjson_version = cJSON_GetObjectItem(cjson_root, "version");
|
|
|
|
|
cJSON* cjson_response = cJSON_GetObjectItem(cjson_root, "response");
|
|
|
|
|
cJSON* cjson_time = cJSON_GetObjectItem(cjson_root, "timeStamp");
|
|
|
|
|
|
2024-08-16 07:16:41 +00:00
|
|
|
|
// ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
char *temp_id = cjson_id -> valuestring;
|
|
|
|
|
char *temp_type = cjson_type -> valuestring;
|
|
|
|
|
int temp_version = cjson_version -> valueint;
|
|
|
|
|
int temp_response = cjson_response -> valueint;
|
|
|
|
|
int temp_time = cjson_time -> valueint;
|
2024-08-16 02:45:39 +00:00
|
|
|
|
|
2024-08-16 07:16:41 +00:00
|
|
|
|
// term_printf("deviId=%s\n frameType=%s\n version=%d\n response=%d\n timeStamp=%d\n", temp_id, temp_type, temp_version, temp_response, temp_time);
|
2024-08-16 02:45:39 +00:00
|
|
|
|
|
|
|
|
|
cJSON_Delete(cjson_root);
|
2024-08-16 07:16:41 +00:00
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
|
|
|
|
|
2024-08-15 01:06:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-08-16 02:45:39 +00:00
|
|
|
|
|
2024-08-16 07:16:41 +00:00
|
|
|
|
|