esp_idf  1.1.1
esp_idf
com_espressif_esp_idf_esp_ota_ops.c
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2018-2020 MicroEJ Corp. All rights reserved.
5  * This library is provided in source code for use, modification and test, subject to license terms.
6  * Any modification of the source code will break MicroEJ Corp. warranties on the whole library.
7  */
8 
17 #include <stdint.h>
18 #include <stddef.h>
20 #include "esp_err.h"
21 #include "esp_ota_ops.h"
22 
23 static esp_ota_handle_t handle;
24 
25 int32_t Java_com_espressif_esp_1idf_esp_1ota_1ops_esp_1ota_1begin(int32_t partition, int32_t image_size) {
26  return esp_ota_begin((const esp_partition_t *)partition, (size_t)image_size, &handle);
27 }
28 
29 int32_t Java_com_espressif_esp_1idf_esp_1ota_1ops_esp_1ota_1end() {
30  return esp_ota_end(handle);
31 }
32 
33 int32_t Java_com_espressif_esp_1idf_esp_1ota_1ops_esp_1ota_1get_1boot_1partition(void) {
34  return (int32_t)esp_ota_get_boot_partition();
35 }
36 
37 int32_t Java_com_espressif_esp_1idf_esp_1ota_1ops_esp_1ota_1get_1next_1update_1partition(int32_t start_from) {
38  return (int32_t)esp_ota_get_next_update_partition((const esp_partition_t *)start_from);
39 }
40 
41 int32_t Java_com_espressif_esp_1idf_esp_1ota_1ops_esp_1ota_1get_1running_1partition(void) {
42  return (int32_t)esp_ota_get_running_partition();
43 }
44 
45 int32_t Java_com_espressif_esp_1idf_esp_1ota_1ops_esp_1ota_1set_1boot_1partition(int32_t partition) {
46  return esp_ota_set_boot_partition((const esp_partition_t*)partition);
47 }
48 
49 int32_t Java_com_espressif_esp_1idf_esp_1ota_1ops_esp_1ota_1write(uint8_t* data, int32_t offset, int32_t size) {
50  return esp_ota_write(handle, (const void*)(data+offset), (size_t)size);
51 }