fix some bugs--解决了同一批数据,时间戳不一样的问题
This commit is contained in:
parent
3c6b5eec89
commit
080f45620e
|
@ -205,7 +205,7 @@ void poll_mqtt_init(void)
|
|||
{
|
||||
static uint16_t qfc41d_init_count = 0;
|
||||
|
||||
while (drv_qfc41d_init() && qfc41d_init_count < 10)
|
||||
while (drv_qfc41d_init() && qfc41d_init_count < 2)
|
||||
{
|
||||
drv_wdog_feed();
|
||||
kit_time_dly_ms(100);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -932,14 +932,14 @@ const int bms_volt_count = sizeof(bms_volt_points) / sizeof(devCellPointMap);
|
|||
const int bms_temp_count = sizeof(bms_temp_points) / sizeof(devCellPointMap);
|
||||
|
||||
|
||||
void protocol_build_json(uint16_t groupId)
|
||||
void protocol_build_json(uint16_t groupId, uint32_t time)
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
cJSON* root = cJSON_CreateObject();
|
||||
|
||||
// 添加时间戳
|
||||
cJSON_AddNumberToObject(root, "timeStamp", drv_rtc_get_tick());
|
||||
cJSON_AddNumberToObject(root, "timeStamp", time);
|
||||
|
||||
// devData 数组(仅包含一个设备对象)
|
||||
cJSON* devDataArr = cJSON_CreateArray();
|
||||
|
@ -984,14 +984,14 @@ void protocol_build_json(uint16_t groupId)
|
|||
if (json_str)
|
||||
{
|
||||
drv_mqtt_publish_no_respose(json_str, strlen(json_str));
|
||||
bsp_task_delay_ms(100);
|
||||
// bsp_task_delay_ms(100);
|
||||
cJSON_free(json_str);
|
||||
}
|
||||
|
||||
cJSON_Delete(root);
|
||||
}
|
||||
|
||||
void protocol_build_volt_json(uint8_t i)
|
||||
void protocol_build_volt_json(uint8_t i, uint32_t time)
|
||||
{
|
||||
const devCellPointMap* item = &bms_volt_points[i];
|
||||
int val = 0;
|
||||
|
@ -1000,7 +1000,7 @@ void protocol_build_volt_json(uint8_t i)
|
|||
|
||||
cJSON* root = cJSON_CreateObject();
|
||||
|
||||
cJSON_AddNumberToObject(root, "timeStamp", drv_rtc_get_tick());
|
||||
cJSON_AddNumberToObject(root, "timeStamp", time);
|
||||
|
||||
// devData 数组
|
||||
cJSON* devDataArr = cJSON_CreateArray();
|
||||
|
@ -1042,14 +1042,14 @@ void protocol_build_volt_json(uint8_t i)
|
|||
if (json_str)
|
||||
{
|
||||
drv_mqtt_publish_no_respose(json_str, strlen(json_str));
|
||||
bsp_task_delay_ms(100);
|
||||
// bsp_task_delay_ms(100);
|
||||
cJSON_free(json_str);
|
||||
}
|
||||
|
||||
cJSON_Delete(root);
|
||||
}
|
||||
|
||||
void protocol_build_temp_json(uint8_t i)
|
||||
void protocol_build_temp_json(uint8_t i, uint32_t time)
|
||||
{
|
||||
const devCellPointMap* item = &bms_temp_points[i];
|
||||
int val = 0;
|
||||
|
@ -1058,7 +1058,7 @@ void protocol_build_temp_json(uint8_t i)
|
|||
|
||||
cJSON* root = cJSON_CreateObject();
|
||||
|
||||
cJSON_AddNumberToObject(root, "timeStamp", drv_rtc_get_tick());
|
||||
cJSON_AddNumberToObject(root, "timeStamp", time);
|
||||
|
||||
// devData 数组
|
||||
cJSON* devDataArr = cJSON_CreateArray();
|
||||
|
@ -1100,7 +1100,7 @@ void protocol_build_temp_json(uint8_t i)
|
|||
if (json_str)
|
||||
{
|
||||
drv_mqtt_publish_no_respose(json_str, strlen(json_str));
|
||||
bsp_task_delay_ms(100);
|
||||
// bsp_task_delay_ms(100);
|
||||
cJSON_free(json_str);
|
||||
}
|
||||
|
||||
|
@ -1111,6 +1111,9 @@ void publish_all_bms_groups()
|
|||
{
|
||||
uint8_t max_group = 0;
|
||||
uint8_t i = 0;
|
||||
uint32_t timeTemp = 0;
|
||||
|
||||
timeTemp = drv_rtc_get_tick();
|
||||
for (i = 0; i < bms_point_count; i++)
|
||||
{
|
||||
if (bms_points[i].groupId > max_group)
|
||||
|
@ -1121,17 +1124,17 @@ void publish_all_bms_groups()
|
|||
|
||||
for (uint8_t g = 0; g <= max_group; g++)
|
||||
{
|
||||
protocol_build_json(g);
|
||||
protocol_build_json(g, timeTemp);
|
||||
}
|
||||
|
||||
for (i = 0; i < bms_volt_count; i++)
|
||||
{
|
||||
protocol_build_volt_json(i);
|
||||
protocol_build_volt_json(i, timeTemp);
|
||||
}
|
||||
|
||||
for (i = 0; i < bms_temp_count; i++)
|
||||
{
|
||||
protocol_build_temp_json(i);
|
||||
protocol_build_temp_json(i, timeTemp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ void drv_wireless_send_string(const char *str)
|
|||
|
||||
void drv_wireless_send_string_dma(const char *str)
|
||||
{
|
||||
bsp_task_delay_ms(100);
|
||||
bsp_task_delay_ms(250);
|
||||
if (dma_tx_busy) return; // 正在发送,丢弃或排队视情况处理
|
||||
|
||||
uint16_t len = 0;
|
||||
|
|
Loading…
Reference in New Issue