347 lines
11 KiB
C
Executable File
347 lines
11 KiB
C
Executable File
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef IOT_OEM_API_H
|
|
#define IOT_OEM_API_H
|
|
|
|
/* os shim includes */
|
|
#include "os_types_api.h"
|
|
|
|
/* common includes */
|
|
#include "iot_utils_api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* pack for the structures in the whole file */
|
|
#pragma pack(push) // save the pack status
|
|
#pragma pack(1) // 1 byte align
|
|
|
|
#define MODULE_TYPE_STA 0
|
|
#define MODULE_TYPE_CCO 1
|
|
#define MODULE_TYPE_COLLECTOR_II 2
|
|
#define MODULE_TYPE_STA_TEST 3
|
|
#define MODULE_TYPE_3_PHASE_STA 4
|
|
#define MODULE_TYPE_MAX_NUM MODULE_TYPE_3_PHASE_STA
|
|
|
|
#define USER_TYPE_STATE_GRID 0
|
|
#define USER_TYPE_OVERSEAS 1
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_YUNNAN 2
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_GX 3
|
|
#define USER_TYPE_STATE_GRID_XIAN 4
|
|
#define USER_TYPE_STATE_GRID_BJ 5
|
|
#define USER_TYPE_STATE_GRID_HLJ 6
|
|
#define USER_TYPE_STATE_GRID_MENGDONG 7
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_GUANGZHOU 8
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_GUANGDONG 9
|
|
#define USER_TYPE_JIANGSU_PEIWANG 10
|
|
#define USER_TYPE_BRM_PEIWANG 11
|
|
#define USER_TYPE_MME_CRC 12
|
|
#define USER_TYPE_STATE_GRID_HUNAN 13
|
|
#define USER_TYPE_STATE_GRID_ZHEJIANG 14
|
|
#define USER_TYPE_STATE_GRID_JIANGSU 15
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_POLL_EVENT_STATE 16
|
|
#define USER_TYPE_STATE_GRID_HEBEI 17
|
|
#define USER_TYPE_STATE_GRID_JIANGXI 18
|
|
#define USER_TYPE_STATE_GRID_SHANDONG 19
|
|
#define USER_TYPE_STATE_GRID_SHANGHAI 20
|
|
#define USER_TYPE_BRM_PEIWANG_DUAL_NET 21
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_HAINAN 22
|
|
#define USER_TYPE_STATE_GRID_FUJIAN 23
|
|
#define USER_TYPE_STATE_GRID_GANSU 24
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_SHENZHEN 25
|
|
#define USER_TYPE_STATE_GRID_CQ 26
|
|
#define USER_TYPE_STATE_GRID_TAIYUAN 27
|
|
#define USER_TYPE_STATE_GRID_TIANJIN 28
|
|
#define USER_TYPE_STATE_GRID_OVERSEAS_SX 29
|
|
#define USER_TYPE_STATE_GRID_OVERSEAS_SW 30
|
|
#define USER_TYPE_STATE_GRID_LIAONING 31
|
|
#define USER_TYPE_STATE_GRID_XINJIANG 32
|
|
#define USER_TYPE_SOUTHEN_NEW_POWER_GRID 33
|
|
#define USER_TYPE_STATE_GRID_HENAN 34
|
|
#define USER_TYPE_SOUTHEN_CSMA_1MS 35
|
|
#define USER_TYPE_STATE_GRID_OVERSEAS_HY 36
|
|
#define USER_TYPE_STATE_GRID_JIBEI 37
|
|
#define USER_TYPE_STATE_GRID_JL 38
|
|
#define USER_TYPE_STATE_GRID_ANHUI 39
|
|
#define USER_TYPE_STATE_GRID_MENGDONG_LC 40
|
|
#define USER_TYPE_STATE_GRID_CERT 41
|
|
#define USER_TYPE_STATE_GRID_MENGXI 42
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_GX_NW21 43
|
|
#define USER_TYPE_SOUTHEN_POWER_GRID_GUIZHOU 44
|
|
#define USER_TYPE_YNS 128
|
|
#define USER_TYPE_FLX 129
|
|
#define USER_TYPE_TM 130
|
|
#define USER_TYPE_BRM_SMALL_LOAD_GOLDEN 131
|
|
#define USER_TYPE_SUNSOLAR1 132
|
|
|
|
#define IOT_OEM_DEVICE_ID_LEN 11
|
|
|
|
#define IOT_OEM_BASE_DUMMY_LEN 18
|
|
|
|
#define IOT_CHIP_MMID_LEN 24
|
|
|
|
/* define module version length */
|
|
#define IOT_OEM_MOD_VER_LEN 2
|
|
/* define chip version length */
|
|
#define IOT_OEM_CHIP_VER_LEN 4
|
|
|
|
typedef struct _iot_oem_base_cfg {
|
|
uint8_t oem_crc;
|
|
uint8_t oem_valid;
|
|
uint8_t module_mac[IOT_MAC_ADDR_LEN];
|
|
uint32_t module_type; //see MODULE_TYPE_XXX
|
|
uint8_t iotapp_mode; //default 0 - GE mode
|
|
uint8_t host_port; //default 0 - UART port
|
|
uint8_t dev_id[IOT_OEM_DEVICE_ID_LEN];
|
|
uint8_t user_type; //default 0 - see USER_TYPE_XXX
|
|
uint8_t base_dummy[IOT_OEM_BASE_DUMMY_LEN];
|
|
} iot_oem_base_cfg_t;
|
|
|
|
typedef struct _iot_oem_hw_ver_info {
|
|
/* module_version, use BCD code to represent, little-endian */
|
|
uint8_t module_version[IOT_OEM_MOD_VER_LEN];
|
|
/* use BCD code to represent */
|
|
uint8_t module_version_day;
|
|
/* use BCD code to represent */
|
|
uint8_t module_version_month;
|
|
/* use BCD code to represent */
|
|
uint8_t module_version_year;
|
|
/* chip version, use ASCII code to represent, little-endian */
|
|
uint8_t chip_ver[IOT_OEM_CHIP_VER_LEN];
|
|
/* use BCD code to represent */
|
|
uint8_t chip_day;
|
|
/* use BCD code to represent */
|
|
uint8_t chip_month;
|
|
/* use BCD code to represent */
|
|
uint8_t chip_year;
|
|
} iot_oem_hw_ver_info_t;
|
|
|
|
enum iot_oem_ip4_method_e {
|
|
IOT_OEM_IP_METHOD_TEI,
|
|
IOT_OEM_IP_METHOD_CUSTOMER,
|
|
};
|
|
|
|
enum iot_oem_ip_enable_e {
|
|
IOT_OEM_IP_DISABLE,
|
|
IOT_OEM_IP_ENABLE,
|
|
};
|
|
|
|
enum iot_oem_ip_version_e {
|
|
IOT_OEM_IP_VERSION_IP4,
|
|
IOT_OEM_IP_VERSION_IP6,
|
|
};
|
|
|
|
enum iot_oem_ip4_validity_e {
|
|
IOT_OEM_IP4_IS_INVALID,
|
|
IOT_OEM_IP4_IS_VALID,
|
|
IOT_OEM_IP4_MASK_IS_INVALID,
|
|
IOT_OEM_IP4_MASK_IS_VALID,
|
|
};
|
|
|
|
/**
|
|
* @brief iot_oem_get_cfg() - read oem cfg from flash oem info section.
|
|
* @param oemcfg: pointer to receive oem cfg
|
|
* @retval 0 success; others fail
|
|
*/
|
|
uint32_t iot_oem_get_base_cfg(iot_oem_base_cfg_t** oemcfg);
|
|
|
|
/**
|
|
* @brief iot_oem_burned_mac() - check chip burned oem mac or not.
|
|
* @retval 1 if burned mac , 0 not burned.
|
|
*/
|
|
uint32_t iot_oem_check_burned_mac(void);
|
|
|
|
/**
|
|
* @brief iot_oem_get_module_mac() - read local mac from flash oem info section.
|
|
* @params mac: pointer to the buffer for mac addr
|
|
* @retval 0 success; others fail
|
|
*/
|
|
uint32_t iot_oem_get_module_mac(uint8_t *mac);
|
|
|
|
/**
|
|
* @brief iot_oem_get_bcd_mac() - read bcd mac address generated by each chip
|
|
* @params mac: pointer to the buffer for mac addr
|
|
*/
|
|
void iot_oem_get_bcd_mac(uint8_t *mac);
|
|
|
|
/**
|
|
* @brief iot_oem_set_chip_mmid() - set oem chip management id to flash
|
|
* oem info section.
|
|
* @param buff: pointer to receive buff.
|
|
* @param len: buff len, must be greater than or equal to IOT_CHIP_MMID_LEN.
|
|
* @param force: whether to force write, 1: force write, 0: write when no mmid
|
|
* @retval see ERR_XXX.
|
|
*/
|
|
uint32_t iot_oem_set_chip_mmid(uint8_t *buff, uint32_t len, uint8_t force);
|
|
|
|
/**
|
|
* @brief iot_oem_get_chip_mmid() - read oem chip management id from flash
|
|
* oem info section.
|
|
* @param buff: pointer to receive buff.
|
|
* @param len: buff len, must be greater than or equal to IOT_CHIP_MMID_LEN.
|
|
* @retval chip management id len.
|
|
*/
|
|
uint32_t iot_oem_get_chip_mmid(uint8_t *buff, uint32_t len);
|
|
|
|
/**
|
|
* @brief iot_oem_set_base_cfg() - read oem base cfg from flash oem info section.
|
|
* @param oemcfg: pointer to receive oem base cfg
|
|
* @retval 0 success; others fail
|
|
*/
|
|
uint32_t iot_oem_set_base_cfg(iot_oem_base_cfg_t* oemcfg);
|
|
|
|
/**
|
|
* @brief iot_oem_get_vendor_id() - read vendor id from flash.
|
|
* @param null
|
|
* @retval vendor id success; 0 fail
|
|
*/
|
|
uint16_t iot_oem_get_vendor_id();
|
|
|
|
/**
|
|
* @brief iot_oem_get_chip_code() - get chip code from flash.
|
|
* @param null
|
|
* @retval chip code
|
|
*/
|
|
uint16_t iot_oem_get_chip_code();
|
|
|
|
/**
|
|
* @brief: get module id
|
|
* @retval: id of current module.
|
|
*/
|
|
uint16_t iot_oem_get_module_id();
|
|
|
|
/**
|
|
* @brief: get user type.
|
|
* @retval - see USER_TYPE_XXX.
|
|
*/
|
|
uint8_t iot_oem_get_user_type();
|
|
|
|
/**
|
|
* @brief iot_oem_get_local_ip4_addr() - get local ip4 addr from flash.
|
|
* @param ip4_addr: pointer to store ip4_addr.
|
|
* @retval none.
|
|
*/
|
|
void iot_oem_get_local_ip4_addr(uint8_t *ip4_addr);
|
|
|
|
/**
|
|
* @brief iot_oem_get_local_ip4_netmask() - get local ip4 netmask from flash.
|
|
* @param ip4_addr: pointer to store ip4_netmask.
|
|
* @retval none.
|
|
*/
|
|
void iot_oem_get_local_ip4_netmask(uint8_t *ip4_mask);
|
|
|
|
/**
|
|
* @brief iot_oem_set_local_ip4_info() - set local ip4 addr and netmask to flash.
|
|
* @param ip4_addr: pointer to store ip4_addr.
|
|
* @param ip4_mask: pointer to store ip4_mask.
|
|
* @retval see ERR_XXX.
|
|
*/
|
|
uint32_t iot_oem_set_local_ip4_info(uint8_t *ip4_addr,
|
|
uint8_t *ip4_mask);
|
|
|
|
/**
|
|
* @brief iot_oem_get_local_port() - get local port from flash.
|
|
* @param none.
|
|
* @retval local port number.
|
|
*/
|
|
uint16_t iot_oem_get_local_port();
|
|
|
|
/**
|
|
* @brief iot_oem_get_is_ip6_flag() - get value of is_ip6 flag .
|
|
* @param none.
|
|
* @retval bool value of is_ip6.
|
|
*/
|
|
bool_t iot_oem_get_is_ip6();
|
|
|
|
/**
|
|
* @brief iot_oem_get_ip_method_flag() - get value of ip_method flag .
|
|
* @param none.
|
|
* @retval enum value of ip_method.
|
|
*/
|
|
uint8_t iot_oem_get_ip_method();
|
|
|
|
/**
|
|
* @brief iot_oem_ip_is_enabled() - if the ip info of the oem is valid .
|
|
* @param none.
|
|
* @retval see IOT_OEM_IP_XXX.
|
|
*/
|
|
uint8_t iot_oem_ip_is_enabled();
|
|
|
|
/**
|
|
* @brief iot_oem_ip4_addr_is_valid() - if the ip4 addr is valid .
|
|
* @param none.
|
|
* @retval see iot_oem_ip4_validity_e.
|
|
*/
|
|
uint32_t iot_oem_ip4_addr_is_valid(uint8_t *ip_addr);
|
|
|
|
/**
|
|
* @brief iot_oem_ip4_netmask_is_valid() - if the ip4 netmask addr is valid .
|
|
* @param none.
|
|
* @retval see iot_oem_ip4_validity_e.
|
|
*/
|
|
uint32_t iot_oem_ip4_netmask_is_valid(uint8_t *ip4_mask);
|
|
|
|
/**
|
|
* @brief get hardware version info.
|
|
* @param info: pointer to version info buff.
|
|
* @retval 0 success; others fail.
|
|
*/
|
|
uint32_t iot_oem_get_hw_ver_info(iot_oem_hw_ver_info_t *info);
|
|
|
|
/**
|
|
* @brief iot_oem_get_board_id() - get board id to flash.
|
|
* @param none.
|
|
* @retval board id;
|
|
*/
|
|
uint32_t iot_oem_get_board_id();
|
|
|
|
/**
|
|
* @brief iot_oem_get_cert_baund() - get oem cert baund.
|
|
* @param none.
|
|
* @retval cert baund;
|
|
*/
|
|
uint32_t iot_oem_get_cert_baund();
|
|
|
|
/**
|
|
* @brief iot_oem_get_cert_uart_parity() - get oem cert uart parity.
|
|
* @param none.
|
|
* @retval uart parity, see IOT_UART_PARITY_XXX.
|
|
*/
|
|
uint8_t iot_oem_get_cert_uart_parity();
|
|
|
|
/**
|
|
* @brief iot_oem_get_module_type() - get module type.
|
|
* @param none
|
|
* @retval module type
|
|
*/
|
|
uint32_t iot_oem_get_module_type(void);
|
|
|
|
/**
|
|
* @brief iot_oem_set_module_mac() - set module mac to flash oem info section.
|
|
* @param mac: mac address to be set
|
|
* @retval see ERR_XXX.
|
|
*/
|
|
uint32_t iot_oem_set_module_mac(uint8_t *mac);
|
|
|
|
#pragma pack(pop) // restore the pack status
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* IOT_OEM_API_H */
|