Browse Source

设备状态变化主动上报

master
zwsd 3 years ago
parent
commit
e4b9edc307
  1. 12
      main/gatts_demo.c

12
main/gatts_demo.c

@ -231,7 +231,8 @@ bool bluetooth_rx_buffer_processing = false;
bool flag = true;
uint32_t total = 0;
#define timer_interval_num 10000
#define timer_group0_interval_num 10000
// #define timer_group1_interval_num 5
#define timer_interval_s (uint32_t)1000000
#define timer_interval_ms (uint32_t)1000
#define timer_interval_us (uint32_t)1
@ -259,6 +260,7 @@ void start_receive_data_to_buffer(uint16_t length, uint8_t *value);
bool parse_rxbuffer_and_validation_data(cJSON **json_tmp);
bool parse_json_to_struct(cJSON *ch);
void receipt_json_set_position();
void receipt_json_get_status();
void gatts_profile_a_constructor(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
bluetooth_processer_t s_bluetooth_processer = {
@ -820,7 +822,7 @@ void app_main(void)
esp_err_t ret;
// timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_interval_num, timer_interval_ms);
timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_interval_num, timer_interval_ms);
timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_group0_interval_num, timer_interval_ms);
// Initialize NVS.
ret = nvs_flash_init();
@ -900,6 +902,11 @@ void app_main(void)
while (true)
{
bluetooth_gatts_try_process_data();
if (s_bluetooth_processer.actively_report_flag)
{
receipt_json_get_status();
s_bluetooth_processer.actively_report_flag = false;
}
}
return;
@ -974,6 +981,7 @@ void bluetooth_gatts_try_process_data()
// {
// ESP_LOGI(GATTS_TAG, "deviceStatusReport");
// }
s_bluetooth_processer.actively_report_flag = true;
}
}

Loading…
Cancel
Save