{
if(common_setting.mcu_info_got_flag)
{
+ //无serial_number wifi info 并且蓝牙关闭状态开启蓝牙配网功能
if(common_storage.net_info.serial_number_flag == 0 && common_storage.net_info.wifi_info_flag == 0 && common_setting.ble_status.ble_state == 0)
{
// Ble_Queue_Send(0xFF, 0x01);
xEventGroupSetBits(ble_event_group, BLE_ON_BIT);
- ESP_LOGI(BLE_TAG, "[APP] Free memory device_id_flag1 on: %" PRIu32 " bytes", esp_get_free_heap_size());
+ ESP_LOGI(BLE_TAG, "[APP] Free memory no serial_number on: %" PRIu32 " bytes", esp_get_free_heap_size());
}
- else if(common_storage.net_info.serial_number_flag && common_storage.net_info.wifi_info_flag && common_setting.ble_status.ble_state != 0)
- {
- // Ble_Queue_Send(0xFF, 0xFF);
- xEventGroupSetBits(ble_event_group, BLE_OFF_BIT);
- ESP_LOGI(BLE_TAG, "[APP] Free memory device_id_flag2 on: %" PRIu32 " bytes", esp_get_free_heap_size());
+ else if(common_storage.net_info.serial_number_flag == 1 && common_storage.net_info.wifi_info_flag == 1){
+ //有serial_number wifi信息
+ ESP_LOGI(BLE_TAG, "[APP] Free memory have serial_number on: %" PRIu32 " bytes", esp_get_free_heap_size());
+ //还要查询是否有订阅地址和证书 没有订阅地址 或者 没有密码 没有wifi名称 没有证书长度
+ if(common_storage.net_info.mqtt_url_len != 0 || common_storage.net_info.wifi_ssid_len != 0 || common_storage.net_info.wifi_pwd_len != 0 || \
+ common_storage.ssl_cert[SSL_CLIENT_CRT].length != 0 || common_storage.ssl_cert[SSL_CLIENT_KEY].length != 0 || common_storage.ssl_cert[SSL_SERVER_CRT].length != 0)
+ {
+ ESP_LOGI(BLE_TAG, "[APP] Free memory have mqtt_sub_url on: %d %d %d %d %d %d\n", common_storage.net_info.mqtt_url_len,common_storage.net_info.wifi_ssid_len,\
+ common_storage.net_info.wifi_pwd_len,common_storage.ssl_cert[SSL_SERVER_CRT].length,common_storage.ssl_cert[SSL_CLIENT_KEY].length,\
+ common_storage.ssl_cert[SSL_CLIENT_CRT].length);
+ //直连mqtts
+ xEventGroupSetBits(common_event_group, COMMON_MQTT_CONNECT_BIT);
+ }else
+ {
+ xEventGroupSetBits(ble_event_group, BLE_ON_BIT);//开启配网模式
+ ESP_LOGI(BLE_TAG, "[APP] Free memory have not mqtt_sub_url on: on: %" PRIu32 " bytes", esp_get_free_heap_size());
+ }
}
+ //只有配网后设备主动关闭蓝牙配网 或者开始配网之后30分钟后没有进行配网则关闭 其他条件无需关闭配网
+ // else if(common_storage.net_info.serial_number_flag && common_storage.net_info.wifi_info_flag && common_setting.ble_status.ble_state != 0)
+ // {
+ // // Ble_Queue_Send(0xFF, 0xFF);
+ // xEventGroupSetBits(ble_event_group, BLE_OFF_BIT);
+ // ESP_LOGI(BLE_TAG, "[APP] Free memory device_id_flag2 on: %" PRIu32 " bytes", esp_get_free_heap_size());
+ // }
}
// static uint8_t ble_queue_read[BLE_QUEUE_ITEM_SIZE] = {0}; // byte0:0:串口 1:蓝牙 0xFF:本地 byte1:1:打开BLE 0xFF:关闭
xEventGroupClearBits(ble_event_group, BLE_OFF_BIT);
if(common_setting.ble_status.ble_state > 0)
{
- #if (IS_CLOSE_BLE)
- common_setting.ble_status.ble_state = 0;
- common_setting.ble_enable_tick = 0;
- stop_advertising();//停止广播
- #endif
// 停止配网
int ret = nimble_port_stop();
if (ret == 0)
vTaskDelete(ble_task_handler);
}
nimble_port_deinit();
-
common_setting.ble_status.ble_state = 0;
common_setting.ble_enable_tick = 0;
-
+
+ // xEventGroupSetBits(ble_event_group, BLE_ON_BIT);
ESP_LOGI(BLE_TAG, "nimble_port_stop\n");
}
else
}
return ESP_OK;
}
-
+#define HTTP_DOWNLOAD_CER_FUNC_ENABLE 0
+#if HTTP_DOWNLOAD_CER_FUNC_ENABLE
static char http_download_cache[sizeof(common_storage.ssl_cert[0].content)] = {0};
+#endif
// esp_err_t http_get_cert(uint8_t cert_type, esp_http_client_handle_t http_client)
// {
// esp_err_t err = 0;
// return err;
// }
-
+#define HTTP_RETRY_NUMBER_MAX (5) //HTTP请求失败重试次数最大值
+#define HTTP_GET 0
+#define HTTP_POST 0
+#define HTTP_GET_MQTT_URL_CER_ENABLE 1 //设备请求下发mqtt地址 证书
+#define HTTP_GET_DEVICEID_ENBALE 0 //设备上报serialNumber 服务器返回deviceID等信息 本产品暂时不用deviceID,所以这个功能先关闭,后续如果需要可以打开
+#define HTTP_PUT_REPORT_MAC_RSSI_ENABLE 1 //PUT请求上报mac和rssi信息
+#define HTTP_GET_SERIAL_NUMBER_ENBALE 1 //GET请求获取serialNumber,服务器根据设备token mac pid等信息返回对应的serialNumber=deviceID等信息
+#define HTTP_GET_URL_MAX_SIZE NET_PAIRING_INFO_MAX_LEN+128
+char output_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};
+#define DOWNLOAD_BLOCK_SIZE 512
HTTP_GET_CERT_TASK_PARAM_T http_get_cert_task_param;
+static const char *HTTP_DOWNLOAD_TASK_TAG = "http_download_task";
+
void http_download_task(void *pvParameters)
{
uint8_t success_bit = 0;
// .disable_auto_redirect = true,
};
// mbedtls_ssl_conf_authmode(&ssl_config, MBEDTLS_SSL_VERIFY_NONE);
- ESP_LOGI(HTTP_TAG, "downloading %d", cert_type);
+ ESP_LOGI(HTTP_DOWNLOAD_TASK_TAG, "downloading %d", cert_type);
esp_err_t err = ESP_FAIL;
esp_http_client_handle_t http_client = NULL; // 提前定义
- for(uint8_t retry=0;retry<3;retry++)
+ for(uint8_t retry=0;retry<HTTP_RETRY_NUMBER_MAX;retry++)
{
- ESP_LOGI(HTTP_TAG, "[APP] Free memory get cer on: %" PRIu32 " bytes", esp_get_free_heap_size());
+ ESP_LOGI(HTTP_DOWNLOAD_TASK_TAG, "[APP] Free memory get cer on: %" PRIu32 " bytes", esp_get_free_heap_size());
// printf("剩余堆内存: %" PRIu32, esp_get_free_heap_size());
http_client = esp_http_client_init(&http_config);
if(http_client == NULL)
{
- ESP_LOGE(HTTP_TAG, "client init fail");
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "client init fail");
vTaskDelay(50);
continue;
}
- ESP_LOGI(HTTP_TAG, "esp_http_client_init");
+ ESP_LOGI(HTTP_DOWNLOAD_TASK_TAG, "esp_http_client_init");
err = esp_http_client_open(http_client, 0);
- ESP_LOGI(HTTP_TAG, "esp_http_client_init err%d\n",err);
+ ESP_LOGI(HTTP_DOWNLOAD_TASK_TAG, "esp_http_client_init err%d\n",err);
if (err == ESP_OK)
{
ESP_LOGI(HTTP_TAG, "esp_http_client_open");
ESP_LOGI(HTTP_TAG, "esp_http_client_fetch_headers = %d", header_ret);
int code = esp_http_client_get_status_code(http_client);
- if(code == 200)
+ int total_size = esp_http_client_get_content_length(http_client);
+ if(code == 200 && total_size > 0 && total_size <= (sizeof(common_storage.ssl_cert[cert_type].content)))
{
- ESP_LOGI(HTTP_TAG, "esp_http_client_get_status_code");
- int file_size = esp_http_client_get_content_length(http_client);
- if(file_size <= (sizeof(common_storage.ssl_cert[0].content)))
+ ESP_LOGI(HTTP_DOWNLOAD_TASK_TAG, "esp_http_client_get_status_code");
+
+ if(total_size <= (sizeof(common_storage.ssl_cert[cert_type].content)))
{
+ #if (!HTTP_DOWNLOAD_CER_FUNC_ENABLE)
+ int total_read = 0;
+ uint8_t flash_buf[DOWNLOAD_BLOCK_SIZE] = {0};
+ uint8_t download_ok = 1;
+
+ // 先清空对应证书存储区
+ memset(common_storage.ssl_cert[cert_type].content, 0, sizeof(common_storage.ssl_cert[cert_type].content));
+ common_storage.ssl_cert[cert_type].length = total_size;
+
+ memset(flash_buf,0,512);
+
+ // 0 890
+ // 512
+ // 512+
+ uint32_t crc_download =0xffffffff;
+ while (total_read < total_size) //0
+ {
+
+ // 每次读 512 字节
+ int read_len = esp_http_client_read(http_client, (char*)flash_buf, DOWNLOAD_BLOCK_SIZE);
+
+ if (read_len <= 0)
+ {
+ download_ok = false;
+ break;
+ }
+
+ crc_download =Crc32_JAMCRC_Cal_Continue(crc_download,flash_buf,read_len);//读出来的数据 和实际读出来的size_len计算crc32校验
+ // 直接写入 RAM 结构体(分段写)
+ printf(HTTP_DOWNLOAD_TASK_TAG, "flash_buf %s crc_download:%08X",flash_buf,crc_download);
+ memcpy(common_storage.ssl_cert[cert_type].content + total_read, flash_buf, read_len);
+
+ total_read += read_len;
+
+ // 防止溢出
+ if (total_read >= sizeof(common_storage.ssl_cert[cert_type].content))
+ break;
+ }
+
+ // 下载完成校验
+ if (download_ok && total_read == total_size)
+ {
+ //写完之后校验 crc
+ uint32_t crc_value =0xffffffff;
+
+ crc_value =Crc32_JAMCRC_Cal_Continue(crc_value,common_storage.ssl_cert[cert_type].content,total_size);
+ ESP_LOGI(HTTP_TAG, "Cert %d download success, size=%d", cert_type, total_read);
+ if(crc_value == crc_download)
+ {
+ if(common_storage.net_info.wifi_pwd_len != 0 && common_storage.net_info.wifi_ssid_len != 0)
+ {
+ if(User_Flash_Write_With_Flag(UF_OFFSET_USER_CONFIG_INFO_ADDR, UF_OFFSET_USER_CONFIG_INFO_FLAG, &common_storage.net_info, sizeof(NET_INFO_T)) == ESP_OK)
+ {
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "flash write wifi pwd ssid success: \n");
+ // 写入 Flash(一次性写整个证书,因为已经在 RAM 里了)
+ if (User_Flash_Write_With_Flag(
+ UF_OFFSET_CERT_CLIENT_CRT_ADDR + FLASH_SEC_SIZE * cert_type,
+ UF_OFFSET_CERT_CERT_FLAG + cert_type,
+ &common_storage.ssl_cert[cert_type],
+ sizeof(SSL_CERT_T)) == ESP_OK)
+ {
+ err = ESP_OK;
+ success_bit |= (1 << cert_type);
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "flash write cer success: %d\n",common_storage.ssl_cert[cert_type].length);
+ if(User_Flash_Read_Check(UF_OFFSET_CERT_CLIENT_CRT_ADDR, UF_OFFSET_CERT_CERT_FLAG+cert_type, &common_storage.ssl_cert[cert_type], sizeof(SSL_CERT_T)) != ESP_OK)
+ {
+ common_storage.ssl_cert[cert_type].length = 0;
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG,"read cer failed");
+ }else{
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG,"read client_ssl_cer success");
+ }
+ }
+ else
+ {
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "flash write cer failed:%d\n",cert_type);
+ err = ESP_FAIL;
+ }
+ }
+ else{
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "flash write wifi pwd ssid failed: \n");
+ err = ESP_FAIL;
+ }
+ }
+ else{
+ ESP_LOGI(HTTP_TAG, "device have not ssid or pwd\n");
+ }
+ }else{
+ ESP_LOGI(HTTP_TAG, "Cert %d download failed, size=%d", cert_type, total_read);
+ err = ESP_FAIL;
+ }
+
+ }
+ else
+ {
+ err = ESP_FAIL;
+ }
+ #endif
+ #if HTTP_DOWNLOAD_CER_FUNC_ENABLE
int read_len = 0;
memset(http_download_cache, 0x00, sizeof(http_download_cache));
- read_len = esp_http_client_read(http_client, http_download_cache, file_size);
- if(read_len == file_size)
+ read_len = esp_http_client_read(http_client, http_download_cache, total_size);
+ if(read_len == total_size)
{
// 成功
- ESP_LOGI(HTTP_TAG, "\nrecv data len%d: %s\n", file_size, http_download_cache);
- if(common_storage.ssl_cert[cert_type].length == file_size && memcmp(http_download_cache, common_storage.ssl_cert[cert_type].content, file_size) == 0)
+
+ ESP_LOGI(HTTP_DOWNLOAD_TASK_TAG, "\nrecv data len%d: %s\n", total_size, http_download_cache);
+
+ if(common_storage.ssl_cert[cert_type].length == total_size && memcmp(http_download_cache, common_storage.ssl_cert[cert_type].content, total_size) == 0)
{
- ESP_LOGI(HTTP_TAG, "cert same: %d", cert_type);
+ ESP_LOGI(HTTP_DOWNLOAD_TASK_TAG, "cert same: %d", cert_type);
err = ESP_OK;
success_bit |= (1 << cert_type);
}
else{
- common_storage.ssl_cert[cert_type].length = file_size;
+ common_storage.ssl_cert[cert_type].length = total_size;
memset(common_storage.ssl_cert[cert_type].content, 0x00, sizeof(common_storage.ssl_cert[0].content));
- memcpy(common_storage.ssl_cert[cert_type].content, http_download_cache, file_size);
+ memcpy(common_storage.ssl_cert[cert_type].content, http_download_cache, total_size);
if(common_storage.net_info.wifi_pwd_len != 0 && common_storage.net_info.wifi_ssid_len != 0)
{
- if(User_Flash_Write_With_Flag(UF_OFFSET_USER_CONFIG_INFO_ADDR, UF_OFFSET_USER_CONFIG_INFO_FLAG, &common_storage.net_info.wifi_ssid, sizeof(NET_INFO_T)) == ESP_OK)
+ if(User_Flash_Write_With_Flag(UF_OFFSET_USER_CONFIG_INFO_ADDR, UF_OFFSET_USER_CONFIG_INFO_FLAG, &common_storage.net_info, sizeof(NET_INFO_T)) == ESP_OK)
{
- err = ESP_OK;
- ESP_LOGE(HTTP_TAG, "flash write wifi ssid success: \n");
- }
- else
- {
- ESP_LOGE(HTTP_TAG, "flash write wifi ssid failed: \n");
- err = ESP_FAIL;
-
- }
-
- if(User_Flash_Write_With_Flag(UF_OFFSET_USER_CONFIG_INFO_ADDR, UF_OFFSET_USER_CONFIG_INFO_FLAG, &common_storage.net_info.wifi_pwd, sizeof(NET_INFO_T)) == ESP_OK)
- {
- err = ESP_OK;
- ESP_LOGE(HTTP_TAG, "flash write wifi pwd success: \n");
+ //
+ if(User_Flash_Write_With_Flag(UF_OFFSET_CERT_CLIENT_CRT_ADDR+FLASH_SEC_SIZE*cert_type, UF_OFFSET_CERT_CERT_FLAG, &common_storage.ssl_cert[cert_type], sizeof(SSL_CERT_T)) == ESP_OK)
+ {
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "flash write cer key server_crt success: %d\n", cert_type);
+ err = ESP_OK;
+ }
+ else
+ {
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "flash write cer key server_crt error: %d\n", cert_type);
+ err = ESP_FAIL;
+ }
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "flash write wifi pwd ssid success: \n");
}
else
{
- ESP_LOGE(HTTP_TAG, "flash write wifi pwd failed: \n");
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "flash write wifi pwd ssid failed: \n");
err = ESP_FAIL;
-
}
}
- if(User_Flash_Write_With_Flag(UF_OFFSET_CERT_CLIENT_CRT_ADDR+FLASH_SEC_SIZE*cert_type, UF_OFFSET_CERT_CERT_FLAG, &common_storage.ssl_cert[cert_type], sizeof(SSL_CERT_T)) == ESP_OK)
- {
- err = ESP_OK;
- }
- else
- {
- ESP_LOGE(HTTP_TAG, "flash write error: %d\n", cert_type);
- err = ESP_FAIL;
- }
+
}
}
else
{
- ESP_LOGE(HTTP_TAG, "http read size low = %d", read_len);
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "http read size low = %d", read_len);
err = ESP_FAIL;
}
+ #endif
}
- else
- {
- ESP_LOGE(HTTP_TAG, "file_size too large");
+ else{
err = ESP_FAIL;
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "http filed size too large\n");
}
}
else
{
- ESP_LOGE(HTTP_TAG, "http req failed");
+ ESP_LOGE(HTTP_DOWNLOAD_TASK_TAG, "http req failed");
err = ESP_FAIL;
}
if(err != ESP_OK)
{
- ESP_LOGI(HTTP_TAG, "download fail %d", cert_type);
+ ESP_LOGI(HTTP_DOWNLOAD_TASK_TAG, "download fail %d", cert_type);
break;
}
vTaskDelay(50 / portTICK_PERIOD_MS);
{
//成功
// Ble_Queue_Send(0xFF, 0xFF);
+ #if (USER_TEST_ENABLE) //开机直连测试使用
+ common_storage.net_info.serial_number_flag = 1;
+ common_storage.net_info.wifi_info_flag = 1;
+ #endif
xEventGroupSetBits(ble_event_group, BLE_OFF_BIT);//关闭蓝牙配网
ESP_LOGI(HTTP_TAG, "download clientcer clientkey mqtt \n");
- xEventGroupSetBits(common_event_group, COMMON_MQTT_CONNECT_BIT);//
+ xEventGroupSetBits(common_event_group, COMMON_MQTT_CONNECT_BIT);
}
vTaskDelete(NULL);
return;
}
-#define HTTP_RETRY_NUMBER_MAX (3) //HTTP请求失败重试次数最大值
-#define HTTP_GET 0
-#define HTTP_POST 0
-#define HTTP_GET_MQTT_URL_CER_ENABLE 1 //设备请求下发mqtt地址 证书
-#define HTTP_GET_DEVICEID_ENBALE 0 //设备上报serialNumber 服务器返回deviceID等信息 本产品暂时不用deviceID,所以这个功能先关闭,后续如果需要可以打开
-#define HTTP_PUT_REPORT_MAC_RSSI_ENABLE 1 //PUT请求上报mac和rssi信息
-#define HTTP_GET_SERIAL_NUMBER_ENBALE 1 //GET请求获取serialNumber,服务器根据设备token mac pid等信息返回对应的serialNumber=deviceID等信息
-#define HTTP_GET_URL_MAX_SIZE NET_PAIRING_INFO_MAX_LEN+128
-char output_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};
+
void http_get_url_task(void *pvParameters)
{
if(common_setting.net_pairing_info.http_url_flag == 0 || common_setting.net_pairing_info.http_token_flag == 0 || common_setting.net_pairing_info.user_id_flag == 0 || common_setting.mcu_info_got_flag == 0 || common_setting.net_pairing_info.http_url_length == 0 || common_setting.net_pairing_info.http_token_length == 0 || common_setting.net_pairing_info.http_url_length > NET_PAIRING_INFO_MAX_LEN || common_setting.net_pairing_info.http_token_length > NET_PAIRING_INFO_MAX_LEN)
// Get(Send:PID/Get:serialNumber) deviceID
ESP_LOGI(HTTP_TAG, "\nHTTP STEP 1.......GET serialNumber=deviceID.................\n");
esp_http_client_handle_t http_client = NULL;
- for(uint8_t retry=0;retry<3;retry++)
+ for(uint8_t retry=0;retry<HTTP_RETRY_NUMBER_MAX;retry++)
{
result = 0;
common_setting.net_pairing_info.serial_number[serial_number_len] = '\0';
common_setting.net_pairing_info.serial_number_length = serial_number_len;
common_setting.net_pairing_info.serial_number_flag = 1;
-
+
//真正需要存储的flash数据
memset(common_storage.net_info.serial_number, 0x00, SERIAL_NUMBER_MAX_LEN+1);
memccpy(common_storage.net_info.serial_number, str_serialNumber, 0, serial_number_len);
common_storage.net_info.serial_number[serial_number_len] = '\0';
-
+ common_storage.net_info.serial_number_flag=1;
//保存flash后,
if(User_Flash_Write_With_Flag(UF_OFFSET_USER_CONFIG_INFO_ADDR, UF_OFFSET_USER_CONFIG_INFO_FLAG, &common_storage.net_info, sizeof(NET_INFO_T)) == ESP_OK)
{
// }
- for(uint8_t retry=0;retry<3;retry++)
+ for(uint8_t retry=0;retry<HTTP_RETRY_NUMBER_MAX;retry++)
{
result = 0;
http_client=NULL;
#if HTTP_GET_MQTT_URL_CER_ENABLE
ESP_LOGI(HTTP_TAG, "\nHTTP STEP 3........GET MQTT CER................\n");
- for(uint8_t retry=0;retry<3;retry++)
+ for(uint8_t retry=0;retry<HTTP_RETRY_NUMBER_MAX;retry++)
{
result = 0;
http_client = NULL;
memcpy(&http_get_cert_task_param.url[SSL_CLIENT_KEY][0], pClientkey->valuestring, strlen((const char*)pClientkey->valuestring));
memcpy(&http_get_cert_task_param.url[SSL_SERVER_CRT][0], pServerCrt->valuestring, strlen((const char*)pServerCrt->valuestring));
+ uint16_t mqtt_url_len = strlen((const char*)pMqttSubUrl->valuestring);
+ if(mqtt_url_len > MQTT_SUB_URL_MAX_LEN)
+ {
+ mqtt_url_len=MQTT_SUB_URL_MAX_LEN;
+ }
+
memset(common_setting.net_pairing_info.mqtt_sub_url, 0x00, sizeof(common_setting.net_pairing_info.mqtt_sub_url));
- memcpy(common_setting.net_pairing_info.mqtt_sub_url, pMqttSubUrl->valuestring, strlen((const char*)pMqttSubUrl->valuestring));
- common_setting.net_pairing_info.mqtt_sub_url_length = strlen((const char*)pMqttSubUrl->valuestring);
+ memcpy(common_setting.net_pairing_info.mqtt_sub_url, pMqttSubUrl->valuestring, mqtt_url_len);
+ common_setting.net_pairing_info.mqtt_sub_url_length = mqtt_url_len;
common_setting.net_pairing_info.mqtt_sub_url_flag = 1;
+
+
+ memset(common_storage.net_info.mqtt_sub_url, 0x00, sizeof(common_storage.net_info.mqtt_sub_url));
+ memcpy(common_storage.net_info.mqtt_sub_url, pMqttSubUrl->valuestring,mqtt_url_len);
+ common_storage.net_info.mqtt_url_len=mqtt_url_len;
+ //保存mqtt 地址
+ //UF_OFFSET_USER_CONFIG_INFO_ADDR, UF_OFFSET_USER_CONFIG_INFO_FLAG, &common_storage.net_info, sizeof(NET_INFO_T)) != ESP_OK
+ if(User_Flash_Write_With_Flag(UF_OFFSET_USER_CONFIG_INFO_ADDR, UF_OFFSET_USER_CONFIG_INFO_FLAG, &common_storage.net_info, sizeof(NET_INFO_T)) == ESP_OK)
+ {
+ ESP_LOGE(HTTP_TAG, "flash write mqtt_sub_url success: %s\n",common_storage.net_info.mqtt_sub_url);
+ err = ESP_OK;
+ }
+ else
+ {
+ ESP_LOGE(HTTP_TAG, "flash write mqtt_sub_url fail: %s\n",common_storage.net_info.mqtt_sub_url);
+ err = ESP_FAIL;
+ }
+
}
else
{