1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: log OAM ota producer interface 15 * Author: 16 * Create: 17 */ 18 #ifndef LOG_OAM_OTA_H 19 #define LOG_OAM_OTA_H 20 21 #include "log_oam_logger.h" 22 23 #pragma pack(push, 1) 24 25 #define OTA_DATA_MAX_SIZE 1200 26 27 #ifdef DEBUG_MODE 28 #define bt_ota_write(msgId, length, msg_buffer) log_oml_ota_write(OM_BT, msgId, length, msg_buffer) 29 #else 30 #define bt_ota_write(msgId, length, msg_buffer) 31 #endif 32 33 typedef enum { 34 OM_OTA_OPEN, 35 OM_OTA_CLOSED, 36 } om_ota_config_t; 37 38 typedef struct { 39 om_msg_header_stru_t header; 40 uint16_t msg_id; 41 uint16_t data_len; 42 } om_ota_header_t; 43 44 typedef struct { 45 om_ota_header_t st_ota_header; 46 uint8_t data[OTA_DATA_MAX_SIZE]; 47 uint8_t msg_tail; 48 } om_ota_data_t; 49 50 51 typedef void(*log_oml_ota_write_handler)(uint8_t mode_id, uint16_t msg_id, uint16_t length, const uint8_t *msg_buffer); 52 void log_oml_ota_init(void); 53 void log_oml_ota_write(uint8_t mode_id, uint16_t msg_id, uint16_t length, const uint8_t *msg_buffer); 54 void log_oml_ota_switch(uint8_t on); 55 void log_oml_ota_set(om_ota_config_t value); 56 uint32_t log_oml_ota_get(void); 57 void log_oml_ota_write_deal(uint8_t mode_id, uint16_t msg_id, uint16_t length, const uint8_t *msg_buffer); 58 void log_oml_ota_write_register_callback(log_oml_ota_write_handler callback); 59 void log_oml_ota_write_unregister_callback(void); 60 void log_oml_ota_write_trigger_callback(uint8_t mode_id, uint16_t msg_id, uint16_t length, const uint8_t *msg_buffer); 61 62 #pragma pack(pop) 63 64 #endif 65