@@ -309,173 +309,4 @@ esp_err_t zb_ota_upgrade_status_handler(esp_zb_zcl_ota_upgrade_value_message_t m
309
309
}
310
310
311
311
return ret ;
312
- }
313
-
314
- // esp_err_t
315
- // zb_ota_upgrade_status_handler(esp_zb_zcl_ota_upgrade_value_message_t
316
- // message){
317
- // static uint32_t total_size = 0;
318
- // static uint32_t offset = 0;
319
- // static int64_t start_time = 0;
320
- // esp_err_t ret = ESP_OK;
321
- // if (message.info.status == ESP_ZB_ZCL_STATUS_SUCCESS) {
322
- // switch (message.upgrade_status) {
323
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_START:
324
- // ESP_LOGI(TAG, "-- OTA upgrade start");
325
- // ota_upgrade_subelement_ = false;
326
- // ota_data_len_ = 0;
327
- // ota_header_len_ = 0;
328
- // start_time = esp_timer_get_time();
329
- // s_ota_partition = esp_ota_get_next_update_partition(NULL);
330
- // assert(s_ota_partition);
331
- // ret = esp_ota_begin(s_ota_partition, OTA_WITH_SEQUENTIAL_WRITES,
332
- // &s_ota_handle); ESP_RETURN_ON_ERROR(ret, TAG, "Failed to begin
333
- // OTA partition, status: %s", esp_err_to_name(ret)); break;
334
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_RECEIVE:
335
- // size_t payload_size = message.payload_size;
336
- // const uint8_t *payload = message.payload;
337
-
338
- // total_size = message.ota_header.image_size;
339
- // offset += payload_size;
340
-
341
- // ESP_LOGI(TAG, "-- OTA Client receives data: progress [%ld/%ld]",
342
- // offset, total_size);
343
-
344
- // /* Read and process the first sub-element, ignoring everything
345
- // else */
346
- // while (ota_header_len_ < 6 && payload_size > 0) {
347
- // ota_header_[ota_header_len_] = payload[0];
348
- // ota_header_len_++;
349
- // payload++;
350
- // payload_size--;
351
- // }
352
-
353
- // if (!ota_upgrade_subelement_ && ota_header_len_ == 6) {
354
- // if (ota_header_[0] == 0 && ota_header_[1] == 0)
355
- // { ota_upgrade_subelement_ = true; ota_data_len_ =
356
- // (((int)ota_header_[5] & 0xFF)
357
- // << 24) | (((int)ota_header_[4] & 0xFF) << 16) | (((int)ota_header_[3] & 0xFF)
358
- // << 8 ) | ((int)ota_header_[2] & 0xFF); ESP_LOGD(TAG, "OTA sub-element size
359
- // %zu", ota_data_len_); } else { ESP_LOGE(TAG, "OTA sub-element type %02x%02x
360
- // not supported", ota_header_[0], ota_header_[1]); return ESP_FAIL;
361
- // }
362
- // }
363
-
364
- // if (ota_data_len_) {
365
- // if (payload_size > ota_data_len_)
366
- // payload_size = ota_data_len_;
367
- // // payload_size = min(ota_data_len_, payload_size);
368
- // ota_data_len_ -= payload_size;
369
-
370
- // if (message.payload_size && message.payload) {
371
- // ret = esp_ota_write(s_ota_handle, payload, payload_size);
372
- // ESP_RETURN_ON_ERROR(ret, TAG, "Failed to write OTA data
373
- // to partition, status: %s", esp_err_to_name(ret));
374
- // }
375
- // }
376
- // break;
377
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_APPLY:
378
- // ESP_LOGI(TAG, "-- OTA upgrade apply");
379
- // break;
380
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_CHECK:
381
- // ret = offset == total_size ? ESP_OK : ESP_FAIL;
382
- // ESP_LOGI(TAG, "-- OTA upgrade check status: %s",
383
- // esp_err_to_name(ret)); break;
384
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_FINISH:
385
- // ESP_LOGI(TAG, "-- OTA Finish");
386
- // ESP_LOGI(TAG,
387
- // "-- OTA Information: version: 0x%lx, manufactor code:
388
- // 0x%x, image type: 0x%x, total size: %ld bytes, cost
389
- // time: %lld ms,", message.ota_header.file_version,
390
- // message.ota_header.manufacturer_code,
391
- // message.ota_header.image_type,
392
- // message.ota_header.image_size, (esp_timer_get_time() -
393
- // start_time) / 1000);
394
- // ret = esp_ota_end(s_ota_handle);
395
- // ESP_RETURN_ON_ERROR(ret, TAG, "Failed to end OTA partition,
396
- // status: %s", esp_err_to_name(ret)); ret =
397
- // esp_ota_set_boot_partition(s_ota_partition);
398
- // ESP_RETURN_ON_ERROR(ret, TAG, "Failed to set OTA boot partition,
399
- // status: %s", esp_err_to_name(ret)); ESP_LOGW(TAG, "Prepare to
400
- // restart system"); esp_restart(); break;
401
- // default:
402
- // ESP_LOGI(TAG, "OTA status: %d", message.upgrade_status);
403
- // break;
404
- // }
405
- // }
406
- // return ret;
407
- // }
408
-
409
- // esp_err_t
410
- // zb_ota_upgrade_status_handler(esp_zb_zcl_ota_upgrade_value_message_t message)
411
- // {
412
- // static uint32_t total_size = 0;
413
- // static uint32_t offset = 0;
414
- // static int64_t start_time = 0;
415
- // esp_err_t ret = ESP_OK;
416
-
417
- // if (message.info.status == ESP_ZB_ZCL_STATUS_SUCCESS) {
418
- // switch (message.upgrade_status) {
419
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_START:
420
- // ESP_LOGI(TAG, "-- OTA upgrade start");
421
- // start_time = esp_timer_get_time();
422
- // s_ota_partition = esp_ota_get_next_update_partition(NULL);
423
- // assert(s_ota_partition);
424
- // #if CONFIG_ZB_DELTA_OTA
425
- // ret = esp_delta_ota_begin(s_ota_partition, 0, &s_ota_handle);
426
- // #else
427
- // ret = esp_ota_begin(s_ota_partition, 0, &s_ota_handle);
428
- // #endif
429
- // ESP_RETURN_ON_ERROR(ret, TAG, "Failed to begin OTA partition, status:
430
- // %s", esp_err_to_name(ret)); break;
431
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_RECEIVE:
432
- // total_size = message.ota_header.image_size;
433
- // offset += message.payload_size;
434
- // ESP_LOGI(TAG, "-- OTA Client receives data: progress [%ld/%ld]",
435
- // offset, total_size); if (message.payload_size && message.payload) {
436
- // #if CONFIG_ZB_DELTA_OTA
437
- // ret = esp_delta_ota_write(s_ota_handle, message.payload,
438
- // message.payload_size);
439
- // #else
440
- // ret = esp_ota_write(s_ota_handle, (const void *)message.payload,
441
- // message.payload_size);
442
- // #endif
443
- // ESP_RETURN_ON_ERROR(ret, TAG, "Failed to write OTA data to
444
- // partition, status: %s", esp_err_to_name(ret));
445
- // }
446
- // break;
447
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_APPLY:
448
- // ESP_LOGI(TAG, "-- OTA upgrade apply");
449
- // break;
450
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_CHECK:
451
- // ret = offset == total_size ? ESP_OK : ESP_FAIL;
452
- // ESP_LOGI(TAG, "-- OTA upgrade check status: %s",
453
- // esp_err_to_name(ret)); break;
454
- // case ESP_ZB_ZCL_OTA_UPGRADE_STATUS_FINISH:
455
- // ESP_LOGI(TAG, "-- OTA Finish");
456
- // ESP_LOGI(TAG, "-- OTA Information: version: 0x%lx, manufacturer code:
457
- // 0x%x, image type: 0x%x, total size: %ld bytes, cost time: %lld ms,",
458
- // message.ota_header.file_version,
459
- // message.ota_header.manufacturer_code,
460
- // message.ota_header.image_type,
461
- // message.ota_header.image_size, (esp_timer_get_time() -
462
- // start_time) / 1000);
463
- // #if CONFIG_ZB_DELTA_OTA
464
- // ret = esp_delta_ota_end(s_ota_handle);
465
- // #else
466
- // ret = esp_ota_end(s_ota_handle);
467
- // #endif
468
- // ESP_RETURN_ON_ERROR(ret, TAG, "Failed to end OTA partition, status:
469
- // %s", esp_err_to_name(ret)); ret =
470
- // esp_ota_set_boot_partition(s_ota_partition); ESP_RETURN_ON_ERROR(ret,
471
- // TAG, "Failed to set OTA boot partition, status: %s",
472
- // esp_err_to_name(ret)); ESP_LOGW(TAG, "Prepare to restart system");
473
- // esp_restart();
474
- // break;
475
- // default:
476
- // ESP_LOGI(TAG, "OTA status: %d", message.upgrade_status);
477
- // break;
478
- // }
479
- // }
480
- // return ret;
481
- // }
312
+ }
0 commit comments