初始提交
This commit is contained in:
676
export/inc/plc_lib/iot_plc_api.h
Executable file
676
export/inc/plc_lib/iot_plc_api.h
Executable file
@@ -0,0 +1,676 @@
|
||||
/****************************************************************************
|
||||
|
||||
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_PLC_API_H
|
||||
#define IOT_PLC_API_H
|
||||
|
||||
#include "os_types_api.h"
|
||||
#include "iot_plc_msg_api.h"
|
||||
#include "iot_pkt_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* application id range definition */
|
||||
#define IOT_PLC_APP_ID_MIN 48
|
||||
#define IOT_PLC_APP_ID_VENDOR_MIN 128
|
||||
#define IOT_PLC_APP_ID_MAX 254
|
||||
|
||||
/* application layer data traffic load level */
|
||||
#define IOT_PLC_APP_LOAD_LIGHT (0)
|
||||
#define IOT_PLC_APP_LOAD_MEDIUM (1)
|
||||
#define IOT_PLC_APP_LOAD_HEAVY (2)
|
||||
#define IOT_PLC_APP_LOAD_MIN IOT_PLC_APP_LOAD_LIGHT
|
||||
#define IOT_PLC_APP_LOAD_MAX IOT_PLC_APP_LOAD_HEAVY
|
||||
#define IOT_PLC_APP_LOAD_DEFAULT IOT_PLC_APP_LOAD_LIGHT
|
||||
|
||||
/* local default retry count */
|
||||
#define IOT_PLC_LOCAL_RETRY_CNT 0
|
||||
/* max retry count */
|
||||
#define IOT_PLC_MAX_RETRY_CNT 5
|
||||
/* whole network broadcast max retry count */
|
||||
#define IOT_PLC_BCAST_ALL_MAX_RETRY_CNT 3
|
||||
|
||||
/** \defgroup PLCLIB_APIs PLCLIB APIs
|
||||
* @brief WQ30x1 PLCLIB APIs
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup PLCLIB_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup PLC_SHARE_APIs PLC SHARE APIs
|
||||
* @brief Share APIs
|
||||
*
|
||||
* APIs can be called by CCO or STA devices
|
||||
*/
|
||||
|
||||
/** @addtogroup PLC_SHARE_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief (*iot_plc_recv_func_t)() - callback to receive event from plc.
|
||||
* @param: parameter registered in iot_plc_register_app
|
||||
* @param: buffer to store the event detail, application should call
|
||||
* iot_free_pkt functio ASAP to free the iot pkt. it's very scarce
|
||||
* resource.
|
||||
*/
|
||||
typedef void (*iot_plc_recv_func_t)(void *param, iot_pkt_t *pkt);
|
||||
|
||||
typedef struct _iot_plc_app {
|
||||
/** application id */
|
||||
uint8_t app_id;
|
||||
/** default priority */
|
||||
uint8_t prio;
|
||||
/** application load */
|
||||
uint8_t load;
|
||||
/** callback to receive event from plc */
|
||||
iot_plc_recv_func_t recv;
|
||||
/** parameter that will be transferred back alone with the callback */
|
||||
void *param;
|
||||
} iot_plc_app_t;
|
||||
|
||||
/** plc application hanlder */
|
||||
typedef void *iot_plc_app_h;
|
||||
|
||||
/**
|
||||
* @brief iot_plc_register_app() - register plc application. the result will
|
||||
* be notified through iot_plc_recv_func_t callback.
|
||||
* @param app: pointer to application descripter
|
||||
*
|
||||
* @return NULL -- for failure case
|
||||
* @return otherwise -- plc application handler
|
||||
*/
|
||||
iot_plc_app_h iot_plc_register_app(iot_plc_app_t *app);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_calc_msdu_len_with_pad_info() - since no matter appdata len,
|
||||
* the PB block size is fixed by 136 264 or 520. we reuse the
|
||||
* padding bytes which transferred by MAC HW. It's
|
||||
* no cost on communication bandwidth.
|
||||
* @param app_len: application data length.
|
||||
* @param is_connless: msdu send by connection or connectionless mode, cared
|
||||
* by head length different.
|
||||
* @param pad_len: padding info len which can be reused.
|
||||
* @return proper msdu length needed apply for mac.
|
||||
*/
|
||||
uint16_t iot_plc_calc_msdu_len_with_pad_info(uint16_t app_len,
|
||||
uint8_t is_connless, uint16_t *pad_len);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_alloc_msdu() - allocate iot packet for msdu data send.
|
||||
* data rx will be notified through iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param msg_type: type of the message. see IOT_PLC_MSG_TYPE_XXX
|
||||
* @param ack_type: required ack type. see IOT_PLC_ACK_TYPE_XXX
|
||||
* @param dst: final destination mac address
|
||||
* @param src: original source mac address
|
||||
* @param lid: link identifier.
|
||||
* 0 - 3 priority,
|
||||
* 4 - 254 business category,
|
||||
* 255 invalid. if set to 255, default
|
||||
* priority registered will be used.
|
||||
* @param len: message length
|
||||
* @param send_cnt: times of sending if remote not acked,
|
||||
* 0 mean default times.
|
||||
* @return the pointer of iot packet
|
||||
*/
|
||||
iot_pkt_t *iot_plc_alloc_msdu(iot_plc_app_h handle, uint8_t msg_type,
|
||||
uint8_t ack_type, uint8_t *dst, uint8_t *src, uint8_t lid, uint16_t len,
|
||||
uint8_t send_cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_alloc_msdu_no_encrypt() - allocate iot packet for msdu data
|
||||
* send. this packet can only be sent in plaintext and cannot be
|
||||
* encrypted, data rx will be notified through iot_plc_recv_func_t
|
||||
* callback.
|
||||
* @param handle: plc application handler
|
||||
* @param msg_type: type of the message. see IOT_PLC_MSG_TYPE_XXX
|
||||
* @param ack_type: required ack type. see IOT_PLC_ACK_TYPE_XXX
|
||||
* @param dst: final destination mac address
|
||||
* @param src: original source mac address
|
||||
* @param lid: link identifier.
|
||||
* 0 - 3 priority,
|
||||
* 4 - 254 business category,
|
||||
* 255 invalid. if set to 255, default
|
||||
* priority registered will be used.
|
||||
* @param len: message length
|
||||
* @param send_cnt: times of sending if remote not acked,
|
||||
* 0 mean default times.
|
||||
* @return the pointer of iot packet
|
||||
*/
|
||||
iot_pkt_t *iot_plc_alloc_msdu_no_encrypt(iot_plc_app_h handle, uint8_t msg_type,
|
||||
uint8_t ack_type, uint8_t *dst, uint8_t *src, uint8_t lid, uint16_t len,
|
||||
uint8_t send_cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_alloc_msdu_by_tei() - allocate iot packet for msdu data send.
|
||||
* data rx will be notified through iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param msg_type: type of the message. see IOT_PLC_MSG_TYPE_XXX
|
||||
* @param ack_type: required ack type. see IOT_PLC_ACK_TYPE_XXX
|
||||
* @param dst: final destination tei, broadcast TEI is not allowed.
|
||||
* @param src: original source mac address
|
||||
* @param lid: link identifier.
|
||||
* 0 - 3 priority,
|
||||
* 4 - 254 business category,
|
||||
* 255 invalid. if set to 255, default
|
||||
* priority registered will be used.
|
||||
* @param len: message length
|
||||
* @param send_cnt: times of sending if remote not acked,
|
||||
* 0 mean default times.
|
||||
* @return the pointer of iot packet
|
||||
*/
|
||||
iot_pkt_t *iot_plc_alloc_msdu_by_tei(iot_plc_app_h handle, uint8_t msg_type,
|
||||
uint8_t ack_type, uint16_t dst, uint8_t *src, uint8_t lid, uint16_t len,
|
||||
uint8_t send_cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_alloc_conn_less_msdu_ext() - allocate iot packet for
|
||||
* connectionless data send with specified ppm fix value.
|
||||
* data rx will be notified through iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param msg_type: type of the connectionless message.
|
||||
* see IOT_PLC_MSG_TYPE_CONN_LESS_XXX
|
||||
* @param dst: final destination mac address
|
||||
* @param src: original source mac address
|
||||
* @param lid: link identifier.
|
||||
* 0 - 3 priority,
|
||||
* 4 - 254 business category,
|
||||
* 255 invalid. if set to 255, default
|
||||
* priority registered will be used.
|
||||
* @param len: message length
|
||||
* @param send_cnt: times of sending if remote not acked,
|
||||
* 0 mean default times.
|
||||
* @param fix_ppm: The ppm value fixed.
|
||||
* @param is_only_tx: flag to mark if rx need to be switched to this ppm.
|
||||
* set 0 if not required.
|
||||
* @param tx_link_type: tx link type, see IOT_PLC_TX_LINK_TYPE_XX.
|
||||
* @return the pointer of iot packet
|
||||
*/
|
||||
iot_pkt_t *iot_plc_alloc_conn_less_msdu_ext(iot_plc_app_h handle,
|
||||
uint8_t msg_type, uint8_t *dst, uint8_t *src, uint8_t lid, uint16_t len,
|
||||
uint8_t send_cnt, int8_t fix_ppm, uint8_t is_only_tx, uint8_t tx_link_type);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_alloc_conn_less_msdu() - allocate iot packet for
|
||||
* connectionless data send. data rx will be notified through
|
||||
* iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param msg_type: type of the connectionless message.
|
||||
* see IOT_PLC_MSG_TYPE_CONN_LESS_XXX
|
||||
* @param dst: final destination mac address
|
||||
* @param src: original source mac address
|
||||
* @param lid: link identifier.
|
||||
* 0 - 3 priority,
|
||||
* 4 - 254 business category,
|
||||
* 255 invalid. if set to 255, default
|
||||
* priority registered will be used.
|
||||
* @param len: message length
|
||||
* @param send_cnt: times of sending if remote not acked,
|
||||
* 0 mean default times.
|
||||
* @return the pointer of iot packet
|
||||
*/
|
||||
#define iot_plc_alloc_conn_less_msdu(handle, msg_type, dst, src, lid, len, \
|
||||
send_cnt) iot_plc_alloc_conn_less_msdu_ext(handle, msg_type, \
|
||||
dst, src, lid, len, send_cnt, 0, 0, IOT_PLC_TX_LINK_TYPE_HPLC)
|
||||
|
||||
/**
|
||||
* @brief iot_plc_rf_alloc_conn_less_msdu() - allocate rf iot packet for
|
||||
* connectionless data send. data rx will be notified through
|
||||
* iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param msg_type: type of the connectionless message.
|
||||
* see IOT_PLC_MSG_TYPE_CONN_LESS_XXX
|
||||
* @param dst: final destination mac address
|
||||
* @param src: original source mac address
|
||||
* @param lid: link identifier.
|
||||
* 0 - 3 priority,
|
||||
* 4 - 254 business category,
|
||||
* 255 invalid. if set to 255, default
|
||||
* priority registered will be used.
|
||||
* @param len: message length
|
||||
* @param send_cnt: times of sending if remote not acked,
|
||||
* 0 mean default times.
|
||||
* @return the pointer of iot packet
|
||||
*/
|
||||
#define iot_plc_rf_alloc_conn_less_msdu(handle, msg_type, dst, src, lid, len, \
|
||||
send_cnt) iot_plc_alloc_conn_less_msdu_ext(handle, msg_type, \
|
||||
dst, src, lid, len, send_cnt, 0, 0, IOT_PLC_TX_LINK_TYPE_RF)
|
||||
|
||||
/**
|
||||
* @brief iot_plc_alloc_ctrl_proto_msdu() - allocate iot packet for Controller
|
||||
* protocol data send. data rx will be notified through
|
||||
* iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param dst: final destination mac address
|
||||
* @param src: original source mac address
|
||||
* @param lid: link identifier.
|
||||
* 0 - 3 priority,
|
||||
* 4 - 254 business category,
|
||||
* 255 invalid. if set to 255, default
|
||||
* priority registered will be used.
|
||||
* @param len: message length
|
||||
* @param send_cnt: times of sending if remote not acked,
|
||||
* 0 mean default times.
|
||||
* @return the pointer of iot packet
|
||||
*/
|
||||
iot_pkt_t *iot_plc_alloc_ctrl_proto_msdu(iot_plc_app_h handle,
|
||||
uint8_t *dst, uint8_t *src, uint8_t lid, uint16_t len, uint8_t send_cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_send_msdu() - send a packet through the plc. there is no
|
||||
* guarantee that the packet will be delivered to the
|
||||
* final destination as the plc network is unreliable. the
|
||||
* pkt must be allocated through iot_plc_alloc_msdu api.
|
||||
* @param handle: plc application handler
|
||||
* @param pkt: pointer to the packet
|
||||
*/
|
||||
void iot_plc_send_msdu(iot_plc_app_h handle, iot_pkt_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_dev_info() - get info of local device
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
*/
|
||||
void iot_plc_query_dev_info(iot_plc_app_h handle, uint8_t req_id);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_nid() - get nid of the current network, a
|
||||
* iot_plc_dev_info_rpt message will be replied
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
*/
|
||||
void iot_plc_query_nid(iot_plc_app_h handle, uint8_t req_id);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_nb_nw_info() - get info of neighbour network
|
||||
* a iot_plc_nb_nw_info_t message will be replied
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
*/
|
||||
void iot_plc_query_nb_nw_info(iot_plc_app_h handle, uint8_t req_id);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_whitelist() - query whitelist
|
||||
* @param start: start index of whitelist entry
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param cnt: count of entries to retrieve
|
||||
*/
|
||||
void iot_plc_query_whitelist(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint16_t start,uint16_t cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_blacklist() - query blacklist
|
||||
* @param start: start index of blacklist entry
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param cnt: count of entries to retrieve
|
||||
*/
|
||||
void iot_plc_query_blacklist(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint16_t start, uint16_t cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_whitelist() - set whitelist
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param action: action of whitelist operation. available
|
||||
* value is IOT_PLC_WL_XXX
|
||||
* @param count: number of mac address
|
||||
* @param mac_addry_array: array of mac address, big endian
|
||||
*/
|
||||
void iot_plc_set_whitelist(iot_plc_app_h handle, uint8_t req_id, uint8_t action,
|
||||
uint16_t count, uint8_t *mac_addr_array);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_whitelist_ex() - set whitelist
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param action: action of whitelist operation. available
|
||||
* value is IOT_PLC_WL_XXX
|
||||
* @param count: number of mac address
|
||||
* @param mac_addry: array of mac address
|
||||
* @param big: flag to mark if the mac address is big endian
|
||||
* in the array
|
||||
*/
|
||||
void iot_plc_set_whitelist_ex(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t action, uint16_t count, uint8_t *mac_addr, uint8_t big);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_blacklist() - set blacklist
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param action: action of blacklist operation. available
|
||||
* value is IOT_PLC_WL_XXX
|
||||
* @param count: number of mac address
|
||||
* @param mac_addry_array: array of mac address
|
||||
*/
|
||||
void iot_plc_set_blacklist(iot_plc_app_h handle, uint8_t req_id, uint8_t action,
|
||||
uint16_t count, uint8_t * mac_addr_array);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_cfg() - set configuration of local device
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param cfg: pointer to detail configuration
|
||||
*/
|
||||
void iot_plc_set_cfg(iot_plc_app_h handle, uint8_t req_id,
|
||||
iot_plc_cfg_set_req_t *cfg);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_freq_band() - set carrier communication frequency band.
|
||||
* if local device is CCO, the band id info will be saved and applied
|
||||
* after each restart.
|
||||
* if local device is STA, the request is only accepted when STA is
|
||||
* not associated with any network. in addition, the band id info will
|
||||
* be lost after each restart or associated with a network.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param freq_band: see PLC_LIB_FREQ_BAND_xxx
|
||||
*/
|
||||
void iot_plc_set_freq_band(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t freq_band);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_rf_channel() - plc set rf channel.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param option: rf option, see IOT_PLC_RF_OPTION_XXX.
|
||||
* @param channel: rf channel, see IOT_PLC_CHANNEL_ID_XXX.
|
||||
* @param rf_cod_enable: flag to mark if enable rf channel coordination,
|
||||
* 0 - disable, 1 - enable, it only valid for CCO device.
|
||||
*/
|
||||
void iot_plc_set_rf_channel(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t option, uint8_t channel, uint8_t rf_cod_enable);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_start_nw_fmt() - start network formation
|
||||
* @param handle: plc application handler
|
||||
* @param force: flag to mark if force start required. if plc network
|
||||
* formation already started, set this flag will restart
|
||||
* the whole process from the very beginning.
|
||||
*/
|
||||
void iot_plc_start_nw_fmt(iot_plc_app_h handle, uint8_t force);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_stop_nw_fmt() - stop network formation
|
||||
* @param handle: plc application handler
|
||||
*/
|
||||
void iot_plc_stop_nw_fmt(iot_plc_app_h handle);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_band_info() - query carrier communication frequency band
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
*/
|
||||
void iot_plc_query_band_info(iot_plc_app_h handle, uint8_t req_id);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_neighbor_by_mac() - query the founded neighbor devices in
|
||||
* the same network by mac. the result will be notified through
|
||||
* iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param node_mac: the node mac array to be queried, big endian
|
||||
* @param node_cnt: count of nodes to be queried
|
||||
*/
|
||||
void iot_plc_query_neighbor_by_mac(iot_plc_app_h handle,
|
||||
uint8_t req_id, uint8_t *node_mac, uint8_t node_cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_neighbor_dev() - query the founded neighbor devices in
|
||||
* the same network. the result will be notified through
|
||||
* iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param start: start tei of the query
|
||||
* @param cnt: requested number of valid entries
|
||||
* @param start_type: start type, see IOT_PLC_QUERY_TOPO_START_AS_XXX
|
||||
*/
|
||||
void iot_plc_query_neighbor_dev(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint16_t start, uint16_t cnt, uint8_t start_type);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_tei_addr_info() - query tei address information
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param start_tei: start tei
|
||||
* @param offset: start query position. bit0 = 0, bit1 = 1, bit2 = 2, ...
|
||||
* @param bm_len: bm len
|
||||
* @param bm: tei bitmap used for query tei addr,
|
||||
* bit0 represent start tei,
|
||||
* bit1 represent start tei + 1 and so on
|
||||
*/
|
||||
void iot_plc_query_tei_addr_info(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint16_t start_tei, uint16_t offset, uint8_t bm_len, uint8_t *bm);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_tx_power_cap() - set carrier communication tx power cap
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to app
|
||||
* in the report. app can define the mean of each id itself.
|
||||
* @param hplc_power: pointer to hplc tx power cap. unit is 1 dbuv,
|
||||
* range 95 - 137, see IOT_PLC_HPLC_TX_POWER_XXX.
|
||||
* @param rf_power: pointer to rf tx power cap. unit is 1 dbm,
|
||||
* range -35 - 20, see IOT_PLC_RF_TX_POWER_XXX.
|
||||
* @return:
|
||||
* ERR_OK -- for success case
|
||||
* otherwise -- error code
|
||||
*/
|
||||
uint32_t iot_plc_set_tx_power_cap(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t *hplc_power, int8_t *rf_power);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_tsfm_state_change() - change the state of transformer detect.
|
||||
*
|
||||
* @param handle: plc application handler.
|
||||
* @param req_id: request id, the request id will be transferred back to app
|
||||
* in the report. app can define the mean of each id itself.
|
||||
* @param status: the status of transformer detect, see
|
||||
* IOT_PLC_TSFM_STATE_XXX.
|
||||
* @param tsfm_addr: transformer mac address. only used in
|
||||
* IOT_PLC_TSFM_STATE_LOCK case.
|
||||
* @param wl_notify_enable: flag to mark if white list notification enable,
|
||||
* invalid for sta role case. 0 - disable, 1 - enable.
|
||||
* @param zc_notify_enable: flag to mark if zc ntb notification enable,
|
||||
* invalid for sta role case. 1 - broadcast, 0 - not.
|
||||
* @param net_lock_time: pointer to the net lock time, NULL mean that the net
|
||||
* lock time is invalid.
|
||||
* @param abn_lock_time: pointer to the lock time of abnormal leave net, NULL
|
||||
* mean that the lock time of abnormal leave net is invalid.
|
||||
* @param unlock_delay: network unlock delay time, unit is 1min.
|
||||
*/
|
||||
void iot_plc_tsfm_state_change(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t status, uint8_t *tsfm_addr, uint8_t wl_notify_enable,
|
||||
uint8_t zc_notify_enable, uint16_t *net_lock_time, uint16_t *abn_lock_time,
|
||||
uint16_t unlock_delay);
|
||||
|
||||
/**
|
||||
* @brief get NTB value of local device. note that, if network
|
||||
* formation is not done, this value is not reliable.
|
||||
*
|
||||
* @param handle: plc application handler.
|
||||
*/
|
||||
uint32_t iot_plc_get_ntb(iot_plc_app_h handle);
|
||||
|
||||
/**
|
||||
* @brief enable/disable watch dog function in PLC. by default, if plc
|
||||
* network formation can't be done within 30 min, system restart
|
||||
* will be triggered.
|
||||
*
|
||||
* @param handle: plc application handler.
|
||||
* @param enable: 1 to enable. 0 to disable.
|
||||
* @param interval: watch dog bite interval, unit is 1 min, less than 30
|
||||
* minutes is disallowed.
|
||||
*/
|
||||
void iot_plc_wdg_set(iot_plc_app_h handle, uint8_t enable, uint16_t interval);
|
||||
|
||||
/**
|
||||
* @brief: get if device is running in sta or cco role
|
||||
*
|
||||
* @retval: return true if device is running in sta role.
|
||||
*/
|
||||
bool_t iot_plc_is_client_mode();
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_local_phase() - query phase information of local device.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
*/
|
||||
void iot_plc_query_local_phase(iot_plc_app_h handle, uint8_t req_id);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_zc_collect() - collect zero-crossing information of
|
||||
* local device.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param start_ntb: time to start collecting, unit is 1 ntb. the actual number
|
||||
* of collection may be less than the required number, because
|
||||
* there is not enough data at the current time, so caller
|
||||
* need to delay the request for a while, caller can delay
|
||||
* 1-5s based on the amount of data and then request again.
|
||||
* @param cnt: collection count, if the local device has 3 phase zc data,
|
||||
* and collecton count is not a multiple of 3, the count of
|
||||
* actual collection returned is a multiple of 3.
|
||||
*/
|
||||
void iot_plc_zc_collect(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint32_t start_ntb, uint8_t cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_band_bitmap() - plc query band bitmap.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param is_scan_band: 0: scan band bitmap; 1: support band bitmap.
|
||||
*/
|
||||
void iot_plc_query_band_bitmap(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t is_scan_band);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_rate_adapt_mode() - set tx adapt mode
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param target_node: see IOT_PLC_RATE_ADAPT_NODE_XXX
|
||||
* @param rate_adapt_mode: see IOT_PLC_RATE_ADAPT_MODE_XXX
|
||||
* @param fixed_rate_level: see IOT_PLC_RATE_ADAPT_RATE_XXX, this value is valid
|
||||
* only when target_node == IOT_PLC_RATE_ADAPT_NODE_LOCAL
|
||||
* and rate_adapt_mode == IOT_PLC_RATE_ADAPT_MODE_FIX.
|
||||
* note that the higher the rate, the weaker the
|
||||
* anti-attenuation ability.
|
||||
* @return: none
|
||||
*/
|
||||
void iot_plc_set_rate_adapt_mode(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t target_node, uint8_t rate_adapt_mode, uint8_t fixed_rate_level);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_authrz_dak() - set authorized DAK/MAC pair info
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param dak: DAK/MAC pair info
|
||||
*/
|
||||
void iot_plc_set_authrz_dak(iot_plc_app_h handle, uint8_t req_id,
|
||||
iot_plc_authrz_dak_set_req_t *dak);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_get_link_load() - get hplc link traffic load
|
||||
* @return: percentage value: 0 - 100. 0 means light, 100 means heavy.
|
||||
*/
|
||||
uint8_t iot_plc_get_link_load();
|
||||
|
||||
/**
|
||||
* @brief iot_plc_get_link_statistics() - get plc link statistics
|
||||
* @param stat: return plc link statistics
|
||||
*/
|
||||
void iot_plc_get_link_statistics(iot_plc_link_statistics_t *stat);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_rf_scan_tbl() - plc set rf scan table.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param rf_scan_tbl: pointer to rf scan table.
|
||||
* @param rf_cnt: count of valid rf entry in rf scan table, and no more
|
||||
* than IOT_PLC_RF_SCAN_TBL_MAX.
|
||||
*/
|
||||
void iot_plc_set_rf_scan_tbl(iot_plc_app_h handle, uint8_t req_id,
|
||||
iot_plc_rf_scan_t *rf_scan_tbl, uint8_t rf_cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_get_comm_type() - get plc communication type
|
||||
* @return: IOT_PLC_COMM_TYPE_XXX
|
||||
*/
|
||||
uint8_t iot_plc_get_comm_type();
|
||||
|
||||
/**
|
||||
* @brief iot_plc_get_local_nf() - get local noise floor.
|
||||
* @return: unit is dBuV, valid value is 20 ~ 117.
|
||||
*/
|
||||
uint8_t iot_plc_get_local_nf();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IOT_PLC_API_H */
|
213
export/inc/plc_lib/iot_plc_cco_api.h
Executable file
213
export/inc/plc_lib/iot_plc_cco_api.h
Executable file
@@ -0,0 +1,213 @@
|
||||
/****************************************************************************
|
||||
|
||||
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_PLC_CCO_API_H
|
||||
#define IOT_PLC_CCO_API_H
|
||||
|
||||
/* os shim includes */
|
||||
#include "os_types_api.h"
|
||||
|
||||
/* common includes */
|
||||
#include "iot_plc_api.h"
|
||||
#include "iot_pkt_api.h"
|
||||
#include "iot_plc_msg_cco_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup PLCLIB_APIs PLCLIB APIs
|
||||
* @brief WQ30x1 PLCLIB APIs
|
||||
*/
|
||||
|
||||
/** @addtogroup PLCLIB_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** \defgroup PLC_CCO_APIs PLC CCO APIs
|
||||
* @brief CCO APIs
|
||||
*
|
||||
* APIs can be called only by CCO device
|
||||
*/
|
||||
|
||||
/** @addtogroup PLC_CCO_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief iot_plc_lid_alloc_req() - request to allocate bandwidth for the
|
||||
* specified lid. the result will be notified through
|
||||
* @param handle: plc application handler
|
||||
* @param lid: the specified lid
|
||||
*/
|
||||
void iot_plc_lid_alloc_req(iot_plc_app_h handle, uint8_t lid);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_lid_rel_req() - request to release bandwidth for the
|
||||
* specified lid.
|
||||
* @param handle: plc application handler
|
||||
* @param lid: the specified lid
|
||||
*/
|
||||
void iot_plc_lid_rel_req(iot_plc_app_h handle, uint8_t lid);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_nw_topo() - Query the plc network topologic. the result
|
||||
* will be notified through iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param req_data_ver: request data type, see IOT_PLC_REQ_DATA_VER_XXX
|
||||
* @param start_type: start type, see IOT_PLC_QUERY_TOPO_START_AS_XXX
|
||||
* @param start: start tei of the query
|
||||
* @param cnt: requested number of valid entries
|
||||
*/
|
||||
void iot_plc_query_nw_topo(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t req_data_ver, uint8_t start_type, uint16_t start, uint16_t cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_nid() - set nid of current network will be
|
||||
* notified through iot_plc_recv_func_t callback.
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param new_ind: new nid to be set to the network
|
||||
*/
|
||||
void iot_plc_set_nid(iot_plc_app_h handle, uint8_t req_id, uint32_t new_nid);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_beacon_data() - set beacon data. beacon data can be
|
||||
* broadcast to whole network in each beacon period.
|
||||
* @param handle: plc application handler
|
||||
* @param data: data to be carried in each beacon
|
||||
* @param len: length of the data. must be qeual ro less than
|
||||
* IOT_PLC_BEACON_DATA_MAX
|
||||
* @return 0 - requst sent to mac successfully
|
||||
* otherwise - error code. see ERR_XXX
|
||||
*/
|
||||
uint32_t iot_plc_set_beacon_data(iot_plc_app_h handle, uint8_t *data,
|
||||
uint8_t len);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_node_info() - query nodes' info by mac
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param ver: request data ver, see IOT_PLC_CCO_NODE_INFOR_REQ_VER_XXX.
|
||||
* @param sta_mac: pointer to nodes' mac.
|
||||
* @param sta_cnt: sta count.
|
||||
*/
|
||||
void iot_plc_query_node_info(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t ver, uint8_t *sta_mac, uint8_t sta_cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_nw_info() - query local network information
|
||||
* @param handle: plc application handler.
|
||||
* @param req_id: request id.
|
||||
*/
|
||||
void iot_plc_query_nw_info(iot_plc_app_h handle, uint8_t req_id);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_query_wl_ext() - query whitelist extended information
|
||||
* @param handle: plc application handler.
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param start: start index of whitelist entry
|
||||
* @param cnt: count of entries to retrieve
|
||||
*/
|
||||
void iot_plc_query_wl_ext(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint16_t start, uint16_t cnt);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_sta_phy_phase() - set STA physical phase info
|
||||
* @param handle: plc application handler.
|
||||
* @param req_id: request id.
|
||||
* @param mac: sta mac address, big endian.
|
||||
* @param phase: physical phase, bit0-2 means phaseA/B/C. set "1"
|
||||
* to indicate which phase the device belongs to.
|
||||
* @param opposite_phase: flag to mark if L/N reversed in Single-phase power
|
||||
* meter or phase sequence reversed in Three-phase
|
||||
* power meter.
|
||||
*/
|
||||
void iot_plc_set_sta_phy_phase(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t mac[], uint8_t phase, uint8_t opposite_phase);
|
||||
/**
|
||||
* @brief iot_plc_set_phy_phase_ident() - set physical phase identification
|
||||
* info
|
||||
* @param handle: plc application handler.
|
||||
* @param req_id: request id.
|
||||
* @param enable: flag to mark if enable physical phase
|
||||
* identification, 0 - disable, 1 - enable
|
||||
*/
|
||||
void iot_plc_set_phy_phase_ident(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t enable);
|
||||
/**
|
||||
* @brief iot_plc_set_app_load() - set application layer data traffic load
|
||||
* @param handle: plc application handler.
|
||||
* @param req_id: request id.
|
||||
* @param load: application layer data traffic load level,
|
||||
* see IOT_PLC_APP_LOAD_XXX.
|
||||
*/
|
||||
void iot_plc_set_app_load(iot_plc_app_h handle, uint8_t req_id, uint8_t load);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_repeater_addr_range() - set repeater addr range.
|
||||
* if the value is valid the repeater in the range
|
||||
* are allowed to join network.
|
||||
* if the value is invalid then all repeater are
|
||||
* allowed to join network.
|
||||
* 00:00:00:00:00:00 and FF:FF:FF:FF:FF:FF are
|
||||
* invalid data.
|
||||
* @param handle: plc application handler.
|
||||
* @param req_id: request id.
|
||||
* @param start_addr: start address, big endian.
|
||||
* @param end_addr: end address, big endian.
|
||||
*/
|
||||
void iot_plc_set_repeater_addr_range(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t *start_addr, uint8_t *end_addr);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_app_sniffer_cmd() - set app sniffer function.
|
||||
* @param handle: plc application handler.
|
||||
* @param req_id: request id.
|
||||
* @param cmd: 0 - disabled, other - enable
|
||||
*/
|
||||
void iot_plc_set_app_sniffer_cmd(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t cmd);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_nw_nego() - set neighbour network negotiation enable.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param enable: flag to mark if enable neighbour network negotiation,
|
||||
* 0 - disable, 1 - enable
|
||||
*/
|
||||
void iot_plc_set_nw_nego(iot_plc_app_h handle, uint8_t req_id, uint8_t enable);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IOT_PLC_CCO_API_H */
|
1279
export/inc/plc_lib/iot_plc_msg_api.h
Executable file
1279
export/inc/plc_lib/iot_plc_msg_api.h
Executable file
File diff suppressed because it is too large
Load Diff
878
export/inc/plc_lib/iot_plc_msg_cco_api.h
Executable file
878
export/inc/plc_lib/iot_plc_msg_cco_api.h
Executable file
@@ -0,0 +1,878 @@
|
||||
/****************************************************************************
|
||||
|
||||
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_PLC_MSG_CCO_API_H
|
||||
#define IOT_PLC_MSG_CCO_API_H
|
||||
|
||||
#include "os_types_api.h"
|
||||
#include "iot_utils_api.h"
|
||||
#include "iot_plc_msg_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
|
||||
|
||||
/* CCO role specific PLC message id definitions */
|
||||
#define IOT_PLC_MSG_LID_REQ 0x80
|
||||
#define IOT_PLC_MSG_LID_CONF 0x81
|
||||
#define IOT_PLC_MSG_LID_REL 0x82
|
||||
#define IOT_PLC_MSG_NW_TOPO_QUERY 0x83
|
||||
#define IOT_PLC_MSG_NW_TOPO_RPT 0x84
|
||||
#define IOT_PLC_MSG_NW_ID_SET 0x85
|
||||
#define IOT_PLC_MSG_NW_ID_SET_RPT 0x86
|
||||
#define IOT_PLC_MSG_STA_JOIN_INFO 0x87
|
||||
#define IOT_PLC_MSG_STA_LEAVE_INFO 0x88
|
||||
#define IOT_PLC_MSG_BEACON_DATA_SET 0x89
|
||||
#define IOT_PLC_MSG_BEACON_DATA_SET_RPT 0x8A
|
||||
#define IOT_PLC_MSG_NODE_INFO_QUERY 0x8B
|
||||
#define IOT_PLC_MSG_NODE_INFO_QUERY_RPT 0x8C
|
||||
#define IOT_PLC_MSG_STA_PHASE_UPDATED 0x8D
|
||||
#define IOT_PLC_MSG_STA_JOIN_REJECTED 0x8E
|
||||
#define IOT_PLC_MSG_STA_PROXY_CHANGED 0x8F
|
||||
#define IOT_PLC_MSG_NW_INFO_QUERY 0x90
|
||||
#define IOT_PLC_MSG_NW_INFO_QUERY_RPT 0x91
|
||||
#define IOT_PLC_MSG_PHY_PHASE_SET_REQ 0x92
|
||||
#define IOT_PLC_MSG_PHY_PHASE_SET_RPT 0x93
|
||||
#define IOT_PLC_MSG_APP_LOAD_SET_REQ 0x94
|
||||
#define IOT_PLC_MSG_APP_LOAD_UPDATED 0x95
|
||||
#define IOT_PLC_MSG_STA_OFFLINE_INFO 0x96
|
||||
#define IOT_PLC_MSG_STA_ONLINE_INFO 0x97
|
||||
#define IOT_PLC_MSG_SET_REPEATER_ADDR_RANGE 0x98
|
||||
#define IOT_PLC_MSG_APP_SNIFFER_CFG 0x99
|
||||
#define IOT_PLC_MSG_APP_SNIFFER_RECV 0x9A
|
||||
#define IOT_PLC_MSG_PHY_PHASE_IDENT_SET 0x9B
|
||||
#define IOT_PLC_MSG_PHY_PHASE_IDENT_SET_RPT 0x9C
|
||||
#define IOT_PLC_MSG_NW_NEGO_SET 0x9D
|
||||
#define IOT_PLC_MSG_NW_NEGO_SET_RPT 0x9E
|
||||
#define IOT_PLC_MSG_NW_WL_EXT_QUERY 0x9F
|
||||
#define IOT_PLC_MSG_NW_WL_EXT_RPT 0xA0
|
||||
|
||||
/* request data version */
|
||||
#define IOT_PLC_CCO_TOPO_REQ_DATA_VER_V0 (0)
|
||||
#define IOT_PLC_CCO_TOPO_REQ_DATA_VER_V1 (1)
|
||||
#define IOT_PLC_CCO_TOPO_REQ_DATA_VER_V2 (2)
|
||||
#define IOT_PLC_CCO_TOPO_REQ_DATA_VER_V3 (3)
|
||||
#define IOT_PLC_CCO_TOPO_REQ_DATA_VER_V4 (4)
|
||||
#define IOT_PLC_CCO_TOPO_REQ_DATA_VER_V5 (5)
|
||||
#define IOT_PLC_CCO_TOPO_REQ_DATA_VER_V6 (6)
|
||||
#define IOT_PLC_CCO_TOPO_REQ_DATA_VER_V7 (7)
|
||||
|
||||
/* query topo data error code */
|
||||
#define IOT_PLC_CCO_TOPO_QR_OK (0) /* query ok */
|
||||
#define IOT_PLC_CCO_TOPO_QR_API_NO_SUPP (1) /* API don't support */
|
||||
#define IOT_PLC_CCO_TOPO_QR_VER_NO_SUPP (2) /* node version don't support */
|
||||
|
||||
#define IOT_PLC_CHIP_ID_SERIAL_NUM_LEN (5)
|
||||
#define IOT_PLC_CHIP_ID_CRC_LEN (8)
|
||||
|
||||
/* start type used for query topo */
|
||||
#define IOT_PLC_QUERY_TOPO_START_AS_TEI (0)
|
||||
#define IOT_PLC_QUERY_TOPO_START_AS_INDEX (1)
|
||||
|
||||
/* boot reason definition */
|
||||
/* normal boot up */
|
||||
#define IOT_PLC_STA_BOOT_REASON_NORMAL 0x00
|
||||
/* power down reboot */
|
||||
#define IOT_PLC_STA_BOOT_REASON_CUT_POWER 0x01
|
||||
/* watch dog reboot */
|
||||
#define IOT_PLC_STA_BOOT_REASON_WATCH_DOG 0x02
|
||||
/* abnormal pointer exception reboot */
|
||||
#define IOT_PLC_STA_BOOT_REASON_POINTER_ERR 0x03
|
||||
|
||||
/** IOT_PLC_MSG_LID_REQ format */
|
||||
typedef struct _iot_plc_lid_alloc_req {
|
||||
/** application layer lid applying for */
|
||||
uint8_t lid;
|
||||
} iot_plc_lid_alloc_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_LID_CONF format */
|
||||
typedef struct _iot_plc_lid_alloc_conf {
|
||||
/** result of the request */
|
||||
uint8_t result;
|
||||
/** application layer lid */
|
||||
uint8_t lid;
|
||||
} iot_plc_lid_alloc_conf_t;
|
||||
|
||||
/** IOT_PLC_MSG_LID_REL format */
|
||||
typedef struct _iot_plc_lid_release_req {
|
||||
/** application layer lid to release */
|
||||
uint8_t lid;
|
||||
} iot_plc_lid_release_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_NW_TOPO_QUERY format */
|
||||
typedef struct _iot_plc_nw_topo_query {
|
||||
/** start tei of the query */
|
||||
uint16_t start;
|
||||
/** requested number of valid entries */
|
||||
uint16_t count;
|
||||
/** request data version, IOT_PLC_CCO_TOPO_REQ_DATA_VER_XXX */
|
||||
uint8_t version;
|
||||
/* start type, see IOT_PLC_QUERY_TOPO_START_AS_XXX */
|
||||
uint8_t start_type;
|
||||
} iot_plc_nw_topo_query_t;
|
||||
|
||||
/** chip id information */
|
||||
typedef struct _iot_plc_chip_id {
|
||||
/** check code */
|
||||
uint8_t check_code[IOT_PLC_CHIP_ID_CRC_LEN];
|
||||
/** equipment serial number */
|
||||
uint8_t dev_code[IOT_PLC_CHIP_ID_SERIAL_NUM_LEN];
|
||||
/** chip mode */
|
||||
uint16_t chip_mode;
|
||||
/** chip vendor code */
|
||||
uint16_t vendor;
|
||||
/** 1 - narrowband, 2 - broadband, 3 - dual_mode */
|
||||
uint8_t dev_type;
|
||||
/** fixed value: 0x01C1FB */
|
||||
uint8_t hd4_3;
|
||||
uint8_t hd4_2;
|
||||
uint8_t hd4_1;
|
||||
/** fixed value: 0x9C */
|
||||
uint8_t hd3;
|
||||
/** fixed value: 0x02 */
|
||||
uint8_t hd2;
|
||||
/** fixed value: 0x01 */
|
||||
uint8_t hd1;
|
||||
} iot_plc_chip_id_t;
|
||||
|
||||
/** plc node info format v0 */
|
||||
typedef struct _iot_plc_node_info_v0 {
|
||||
/** tei of the station */
|
||||
uint16_t sta_tei :12,
|
||||
/** level of the station */
|
||||
level :4;
|
||||
/** tei of the proxy */
|
||||
uint16_t proxy_tei :12,
|
||||
/** role of the station */
|
||||
role :4;
|
||||
/** mtd type of the peer */
|
||||
uint8_t mtd_type:4,
|
||||
/** psram status of the peer */
|
||||
psram :1,
|
||||
/** link type between station and proxy, 0 - hplc, 1 - rf */
|
||||
pco_link_rf :1,
|
||||
/** firmware version type, 0 - release, 1 - debug */
|
||||
ver_type:1,
|
||||
/** reserved for future */
|
||||
rsvd :1;
|
||||
/** uplink traffic success ratio */
|
||||
uint8_t ul_tf_sr;
|
||||
/** downlink traffic success ratio */
|
||||
uint8_t dl_tf_sr;
|
||||
/** rx snr from the node to its pco */
|
||||
int8_t ul_snr;
|
||||
/** rx snr from its pco to the node */
|
||||
int8_t dl_snr;
|
||||
/** mac address of the station */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
/** mac address of the proxy station: big endian */
|
||||
uint8_t proxy_addr[IOT_MAC_ADDR_LEN];
|
||||
/** tsfm address info, big endian */
|
||||
uint8_t tsfm_addr[IOT_MAC_ADDR_LEN];
|
||||
/** device type. See PLC_DEV_TYPE_XXX */
|
||||
uint8_t dev_type;
|
||||
/** logical phase of the station */
|
||||
uint8_t logic_phase1 :2,
|
||||
logic_phase2 :2,
|
||||
logic_phase3 :2,
|
||||
/** mac address type. see IOT_PLC_MAC_ADDR_TYPE_XXX */
|
||||
addr_type :2;
|
||||
/** physical phase of the station */
|
||||
uint8_t phy_phase1 :2,
|
||||
phy_phase2 :2,
|
||||
phy_phase3 :2,
|
||||
/** flag to mark if L/N reversed in Single-phase power meter or phase
|
||||
* sequence reversed in Three-phase power meter.
|
||||
*/
|
||||
opposite_phase :1,
|
||||
/** flag to mark if L/N reversed in Three-phase power meter */
|
||||
opposite_3p :1;
|
||||
/* connection position of N-wire if L/N of three-phase meter is reversed.
|
||||
* see IOT_PLC_PHASE_XXX.
|
||||
* Note: the position refers to the physical phase terminal.
|
||||
*/
|
||||
uint8_t opposite_3p_pos :2,
|
||||
|
||||
/** 1 - hw_reset_cnt changed relative to the last time join net */
|
||||
hw_reset_flag :1,
|
||||
/** 1 - sw_reset_cnt changed relative to the last time join net */
|
||||
sw_reset_flag :1,
|
||||
/** flag to mark if the bonding relationship between the node and TEI
|
||||
* already exists before the node joined the network.
|
||||
*/
|
||||
bonding_flag :1,
|
||||
/** device communication type, see IOT_PLC_COMM_TYPE_XXX */
|
||||
comm_type :2,
|
||||
/** reseved */
|
||||
reserved :1;
|
||||
/** build version of the node */
|
||||
uint32_t build_ver;
|
||||
/** last boot up reason of the node */
|
||||
uint8_t boot_reason;
|
||||
/** boot version */
|
||||
uint8_t boot_ver;
|
||||
/** software version of the node */
|
||||
uint16_t sw_ver;
|
||||
/** software build time */
|
||||
uint16_t build_time_y :7,
|
||||
build_time_m :4,
|
||||
build_time_d :5;
|
||||
/** vendor of the node */
|
||||
uint16_t vendor;
|
||||
/** chip code */
|
||||
uint16_t chip_code;
|
||||
/** how many times received valid assoc request from the node since join
|
||||
* the network.
|
||||
*/
|
||||
uint16_t assoc_rx_cnt;
|
||||
/** how many times the node change proxy accepted since join the network */
|
||||
uint16_t proxy_chg_accept_cnt;
|
||||
/** how many times received valid proxy change request from the node
|
||||
* since join the network.
|
||||
*/
|
||||
uint32_t proxy_chg_rx_cnt;
|
||||
/** how much time the node have been in the network, unit is 1s */
|
||||
uint32_t in_network_time;
|
||||
/** how much time since last assoc request, unit is 1s */
|
||||
uint32_t last_assoc_rx_time;
|
||||
/** how much time since last proxy change, unit is 1s */
|
||||
uint32_t last_proxy_chg_time;
|
||||
/** how much time since last seen this device, unit is 1s */
|
||||
uint32_t inactive_time;
|
||||
/** chip id information of the node */
|
||||
iot_plc_chip_id_t chip_id;
|
||||
} iot_plc_node_info_v0_t;
|
||||
|
||||
/** plc node info format v1 */
|
||||
typedef struct _iot_plc_node_info_v1 {
|
||||
/** tei of the station */
|
||||
uint16_t sta_tei :12,
|
||||
/** level of the station */
|
||||
level :4;
|
||||
/** tei of the proxy */
|
||||
uint16_t proxy_tei :12,
|
||||
/** role of the station */
|
||||
role :4;
|
||||
/** uplink traffic success ratio */
|
||||
uint8_t ul_tf_sr;
|
||||
/** downlink traffic success ratio */
|
||||
uint8_t dl_tf_sr;
|
||||
/** rx snr from the node to its pco */
|
||||
int8_t ul_snr;
|
||||
/** rx snr from its pco to the node */
|
||||
int8_t dl_snr;
|
||||
/** mac address of the station */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
/** device type. See PLC_DEV_TYPE_XXX */
|
||||
uint8_t dev_type;
|
||||
/** logical phase of the station */
|
||||
uint8_t logic_phase1 :2,
|
||||
logic_phase2 :2,
|
||||
logic_phase3 :2,
|
||||
/** mac address type. see IOT_PLC_MAC_ADDR_TYPE_XXX */
|
||||
addr_type :2;
|
||||
/** physical phase of the station */
|
||||
uint8_t phy_phase1 :2,
|
||||
phy_phase2 :2,
|
||||
phy_phase3 :2,
|
||||
/** flag to mark if L/N reversed in Single-phase power meter or phase
|
||||
* sequence reversed in Three-phase power meter.
|
||||
*/
|
||||
opposite_phase :1,
|
||||
/** flag to mark if L/N reversed in Three-phase power meter */
|
||||
opposite_3p :1;
|
||||
/** connection position of N-wire if L/N of three-phase meter is reversed.
|
||||
* see IOT_PLC_PHASE_XXX.
|
||||
* Note: the position refers to the physical phase terminal.
|
||||
*/
|
||||
uint8_t opposite_3p_pos :2,
|
||||
/** link type between station and proxy, 0 - hplc, 1 - rf */
|
||||
pco_link_rf :1,
|
||||
/** reseved */
|
||||
reserved :5;
|
||||
/** boot version */
|
||||
uint8_t boot_ver;
|
||||
/** software version of the node */
|
||||
uint16_t sw_ver;
|
||||
/** module vendor ID */
|
||||
uint16_t vendor;
|
||||
/** chip id information of the node */
|
||||
iot_plc_chip_id_t chip_id;
|
||||
} iot_plc_node_info_v1_t;
|
||||
|
||||
/** plc node info format v2 */
|
||||
typedef struct _iot_plc_node_info_v2 {
|
||||
/** tei of the station */
|
||||
uint16_t sta_tei;
|
||||
/** tei of the proxy */
|
||||
uint16_t proxy_tei :12,
|
||||
/** link type between station and proxy, 0 - hplc, 1 - rf */
|
||||
pco_link_rf :1,
|
||||
/** device communication type, see IOT_PLC_COMM_TYPE_XXX */
|
||||
comm_type :2,
|
||||
/** reserved for future */
|
||||
rsvd :1;
|
||||
/** change count of the proxy */
|
||||
uint16_t proxy_chg_cnt;
|
||||
/** leaving network count of the station */
|
||||
uint16_t leave_cnt;
|
||||
/** level of the station */
|
||||
uint8_t level :4,
|
||||
/** role of the station */
|
||||
role :4;
|
||||
/** mac address of the station */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_node_info_v2_t;
|
||||
|
||||
/* plc node info format v3 */
|
||||
typedef struct _iot_plc_node_info_v3 {
|
||||
/** mac address of the station */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
/** tei of the station */
|
||||
uint16_t sta_tei :12,
|
||||
/** level of the station */
|
||||
level :4;
|
||||
/** tei of the proxy */
|
||||
uint16_t proxy_tei :12,
|
||||
/** role of the station */
|
||||
role :4;
|
||||
/** online flag */
|
||||
uint8_t is_online :1,
|
||||
/* beacon slot arranged flag */
|
||||
is_slot_set :1,
|
||||
/** link type between station and proxy, 0 - hplc, 1 - rf */
|
||||
pco_link_rf :1,
|
||||
/** heart-beat received flag */
|
||||
is_hb_rec :1,
|
||||
/** counter of route period missed since last hb */
|
||||
rt_period_miss :4;
|
||||
|
||||
/** device type. See PLC_DEV_TYPE_XXX */
|
||||
uint8_t dev_type;
|
||||
/** physical phase of the station */
|
||||
uint8_t phy_phase1 :2,
|
||||
phy_phase2 :2,
|
||||
phy_phase3 :2,
|
||||
/** flag to mark if L/N reversed in Single-phase power meter or phase
|
||||
* sequence reversed in Three-phase power meter.
|
||||
*/
|
||||
opposite_phase :1,
|
||||
reserved_2 :1;
|
||||
/** how many times the node change proxy accepted since join the network */
|
||||
uint16_t proxy_chg_accept_cnt;
|
||||
/** how many times sta leaving the network */
|
||||
uint16_t leave_cnt;
|
||||
/** last time span from offline to associated state, unit is 1s */
|
||||
uint32_t last_leave_dur;
|
||||
/** max time span from offline to associated state, unit is 1s */
|
||||
uint32_t max_leave_dur;
|
||||
/** uplink traffic success ratio */
|
||||
uint8_t ul_tf_sr;
|
||||
/** downlink traffic success ratio */
|
||||
uint8_t dl_tf_sr;
|
||||
/** rx snr from the node to its pco */
|
||||
int8_t ul_snr;
|
||||
/** rx snr from its pco to the node */
|
||||
int8_t dl_snr;
|
||||
/** primary version: build version info */
|
||||
uint8_t build_ver[3];
|
||||
/** secondary version: software version of the node */
|
||||
uint16_t sw_ver;
|
||||
/** next hop's tei */
|
||||
uint16_t next_hop;
|
||||
/** transformer status */
|
||||
uint8_t tsfm_status;
|
||||
/** transformer address: big endian */
|
||||
uint8_t tsfm_addr[IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_node_info_v3_t;
|
||||
|
||||
/** plc node info format v4 */
|
||||
typedef struct _iot_plc_node_info_v4 {
|
||||
/** mac address of the station: big endian */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
/** software version */
|
||||
uint16_t sw_ver;
|
||||
/** software build time */
|
||||
uint16_t build_time_y :7,
|
||||
build_time_m :4,
|
||||
build_time_d :5;
|
||||
/** module vendor ID */
|
||||
uint16_t vendor_id;
|
||||
/** chip ID */
|
||||
uint16_t chip_id;
|
||||
} iot_plc_node_info_v4_t;
|
||||
|
||||
/** plc node info format v5 */
|
||||
typedef struct _iot_plc_node_info_v5 {
|
||||
/** tei of the station */
|
||||
uint32_t sta_tei :12,
|
||||
/** tei of the proxy */
|
||||
proxy_tei :12,
|
||||
/** uplink traffic success ratio */
|
||||
ul_tf_sr :8;
|
||||
/** mac address of the station: big endian */
|
||||
uint8_t sta_addr[IOT_MAC_ADDR_LEN];
|
||||
/** mac address of the proxy station: big endian */
|
||||
uint8_t proxy_addr[IOT_MAC_ADDR_LEN];
|
||||
/** downlink traffic success ratio */
|
||||
uint8_t dl_tf_sr;
|
||||
/** rx snr from the node to its pco */
|
||||
int8_t ul_snr;
|
||||
/** tx snr from its pco to the node */
|
||||
int8_t dl_snr;
|
||||
/** physical phase of the station */
|
||||
uint8_t phy_phase1 :2,
|
||||
phy_phase2 :2,
|
||||
phy_phase3 :2,
|
||||
/** link type between station and proxy, 0 - hplc, 1 - rf */
|
||||
pco_link_rf :1,
|
||||
/** online flag */
|
||||
|
||||
is_online :1;
|
||||
} iot_plc_node_info_v5_t;
|
||||
|
||||
/** plc node info format v6 */
|
||||
typedef struct _iot_plc_node_info_v6 {
|
||||
/** tei of the station */
|
||||
uint16_t sta_tei;
|
||||
/** tei of the proxy */
|
||||
uint16_t proxy_tei :12,
|
||||
/** link type between station and proxy, 0 - hplc, 1 - rf */
|
||||
pco_link_rf :1,
|
||||
/** reserved for future */
|
||||
rsvd :3;
|
||||
/** level of the station */
|
||||
uint8_t level :4,
|
||||
/** role of the station */
|
||||
role :4;
|
||||
/** uplink traffic success ratio */
|
||||
uint8_t ul_tf_sr;
|
||||
/** downlink traffic success ratio */
|
||||
uint8_t dl_tf_sr;
|
||||
} iot_plc_node_info_v6_t;
|
||||
|
||||
/** plc node info format v7 for ckb */
|
||||
typedef struct _iot_plc_node_info_v7 {
|
||||
/** tei of the station */
|
||||
uint16_t sta_tei;
|
||||
/** tei of the proxy */
|
||||
uint16_t proxy_tei :12,
|
||||
/** link type between station and proxy, 0 - hplc, 1 - rf */
|
||||
pco_link_rf :1,
|
||||
/** reserved for future */
|
||||
rsvd :3;
|
||||
/** level of the station */
|
||||
uint8_t level : 4,
|
||||
/** role of the station */
|
||||
role : 4;
|
||||
/** device type. See PLC_DEV_TYPE_XXX */
|
||||
uint8_t dev_type;
|
||||
/** mac address of the station: big endian */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
/** software version */
|
||||
uint16_t sw_ver;
|
||||
/** software build time */
|
||||
uint16_t build_time_y : 7,
|
||||
build_time_m : 4,
|
||||
build_time_d : 5;
|
||||
/** module vendor ID */
|
||||
uint16_t vendor_id;
|
||||
/** chip code */
|
||||
uint16_t chip_code;
|
||||
/** build version of the node */
|
||||
uint32_t build_ver;
|
||||
} iot_plc_node_info_v7_t;
|
||||
|
||||
typedef struct _iot_plc_sta_phase_info {
|
||||
/** tei of the station */
|
||||
uint16_t tei;
|
||||
/** mac address of the STA */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
/** physical phase of the station */
|
||||
uint8_t phy_phase1 : 2,
|
||||
phy_phase2 : 2,
|
||||
phy_phase3 : 2,
|
||||
/** flag to mark if L/N reversed in Single-phase power meter or phase
|
||||
* sequence reversed in Three-phase power meter.
|
||||
*/
|
||||
opposite_phase : 1,
|
||||
/* flag to mark if L/N reversed in Three-phase power meter */
|
||||
opposite_3p : 1;
|
||||
/** logical phase of the station */
|
||||
uint8_t logical_phase1 : 2,
|
||||
logical_phase2 : 2,
|
||||
logical_phase3 : 2,
|
||||
/* connection position of N-wire if L/N of three-phase meter is reversed.
|
||||
* see IOT_PLC_PHASE_XXX.
|
||||
* Note: the position refers to the physical phase terminal.
|
||||
*/
|
||||
opposite_3p_pos : 2;
|
||||
} iot_plc_sta_phase_info_t;
|
||||
|
||||
/** IOT_PLC_MSG_STA_PHASE_UPDATED format */
|
||||
typedef struct _iot_plc_sta_phase_update {
|
||||
/** number of STAs that has phase info updated */
|
||||
uint16_t sta_count;
|
||||
/** phase info of STAs */
|
||||
iot_plc_sta_phase_info_t sta[0];
|
||||
} iot_plc_sta_phase_update_t;
|
||||
|
||||
/** IOT_PLC_MSG_STA_JOIN_REJECTED format */
|
||||
typedef struct _iot_plc_sta_join_rejected {
|
||||
/** mac address of the sta */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
/** vendor id of the device */
|
||||
uint16_t vendor_id;
|
||||
/** rejected reason. see IOT_PLC_REASON_XXX */
|
||||
uint8_t reason;
|
||||
/** mac address type. see IOT_PLC_MAC_ADDR_TYPE_XXX */
|
||||
uint8_t addr_type;
|
||||
/** device type. see IOT_PLC_DEV_TYPE_XXX */
|
||||
uint8_t dev_type;
|
||||
} iot_plc_sta_join_rejected_t;
|
||||
|
||||
/** IOT_PLC_MSG_STA_PROXY_CHANGED format
|
||||
* CCo reports this message when a STA changed the proxy
|
||||
*/
|
||||
typedef struct _iot_plc_sta_proxy_changed {
|
||||
/** total pco role node count of this network */
|
||||
uint16_t total_pco_cnt;
|
||||
/** total sta role node count of this network */
|
||||
uint16_t total_sta_cnt;
|
||||
/** tei of the station */
|
||||
uint32_t sta_tei :12,
|
||||
/** tei of the proxy */
|
||||
proxy_tei :12,
|
||||
/** level of the station */
|
||||
level :4,
|
||||
/** role of the station. see IOT_PLC_DEV_ROLE_XXX */
|
||||
role :4;
|
||||
/** logical phase of the station */
|
||||
uint8_t logic_phase1 :2,
|
||||
logic_phase2 :2,
|
||||
logic_phase3 :2,
|
||||
/** link type between station and proxy, 0 - hplc, 1 - rf */
|
||||
pco_link_rf :1,
|
||||
/** reserved for future */
|
||||
rsvd :1;
|
||||
/** mac address of the station */
|
||||
uint8_t sta_addr[IOT_MAC_ADDR_LEN];
|
||||
/** mac address of the proxy */
|
||||
uint8_t proxy_addr[IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_sta_proxy_changed_t;
|
||||
|
||||
/** IOT_PLC_MSG_NW_TOPO_RPT format */
|
||||
typedef struct _iot_plc_nw_topo_rpt {
|
||||
/** total number of valid tei */
|
||||
uint16_t total_count;
|
||||
/** number of valid tei in current message */
|
||||
uint16_t count;
|
||||
/** report data version, see IOT_PLC_CCO_REQ_TOPO_DATA_VER_XXX */
|
||||
uint8_t version;
|
||||
/** report done */
|
||||
uint8_t done :1,
|
||||
/** error code, see IOT_PLC_CCO_QR_TOPO_DATA_XXX */
|
||||
err_code :2,
|
||||
/** reserved for future */
|
||||
reserved :5;
|
||||
/** start type, see IOT_PLC_QUERY_TOPO_START_AS_XXX. The value same as the
|
||||
* query param */
|
||||
uint8_t start_type;
|
||||
/** node info of each valid tei, see iot_plc_node_info_xxx_t */
|
||||
uint8_t data[0];
|
||||
} iot_plc_nw_topo_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_NW_ID_SET format */
|
||||
typedef struct _iot_plc_set_nid_req {
|
||||
/** new nid to be set.
|
||||
* nid takes 3 byte according to SG spec */
|
||||
uint32_t nid;
|
||||
} iot_plc_set_nid_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_NW_WL_SET_RPT format */
|
||||
typedef struct _iot_plc_nw_id_set_rpt {
|
||||
/** result of the nid set request */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_nw_id_set_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_STA_JOIN_INFO format
|
||||
* CCo reports this message when a STA join in a network
|
||||
*/
|
||||
typedef struct _iot_plc_sta_join_info {
|
||||
/** total node count of this network */
|
||||
uint16_t total_node_count;
|
||||
/** info of STA */
|
||||
iot_plc_node_info_v0_t sta_info;
|
||||
} iot_plc_sta_join_info_t;
|
||||
|
||||
/** IOT_PLC_MSG_STA_ONLINE_INFO format
|
||||
*/
|
||||
typedef struct _iot_plc_sta_online_info {
|
||||
/** tei of the station */
|
||||
uint16_t tei;
|
||||
/** tei of the proxy */
|
||||
uint16_t proxy;
|
||||
/** mac address of the device */
|
||||
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_sta_online_info_t;
|
||||
|
||||
typedef struct _iot_plc_sta_info {
|
||||
/** tei of the station */
|
||||
uint16_t tei;
|
||||
/** tei of the proxy */
|
||||
uint16_t proxy;
|
||||
/** mac address of the device */
|
||||
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_sta_info_t;
|
||||
|
||||
/** IOT_PLC_MSG_STA_LEAVE_INFO format
|
||||
* CCo reports this message when a STA disassociated from network
|
||||
*/
|
||||
typedef struct _iot_plc_sta_leave_info {
|
||||
/** left node count of this network */
|
||||
uint16_t total_node_count :12,
|
||||
/** reason of leave this network, see IOT_PLC_KICK_REASON_XXX */
|
||||
reason :4;
|
||||
/** number of STAs leaveing the network */
|
||||
uint8_t sta_count;
|
||||
/** info of STAs */
|
||||
iot_plc_sta_info_t sta[0];
|
||||
} iot_plc_sta_leave_info_t;
|
||||
|
||||
/** IOT_PLC_MSG_STA_OFFLINE_INFO format
|
||||
* CCo reports this message when a STA inactive for 2 * route period.
|
||||
*/
|
||||
typedef struct _iot_plc_sta_offline_info {
|
||||
/** number of STAs those state are offline */
|
||||
uint8_t sta_count;
|
||||
/** info of STAs */
|
||||
iot_plc_sta_info_t sta[0];
|
||||
} iot_plc_sta_offline_info_t;
|
||||
|
||||
/** IOT_PLC_MSG_BEACON_DATA_SET format */
|
||||
typedef struct _iot_plc_beacon_data_set {
|
||||
/** beacon data to be set */
|
||||
uint8_t data[IOT_PLC_BEACON_DATA_MAX];
|
||||
} iot_plc_beacon_data_set_t;
|
||||
|
||||
/** IOT_PLC_MSG_BEACON_DATA_SET_RPT format */
|
||||
typedef struct _iot_plc_beacon_data_set_rpt {
|
||||
/** result of the beacon data set request */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_beacon_data_set_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_NODE_INFO_QUERY format */
|
||||
typedef struct _iot_plc_node_info_query {
|
||||
/** sta's counter */
|
||||
uint8_t node_cnt;
|
||||
/** request data version, IOT_PLC_CCO_NODE_INFOR_REQ_VER_XXX */
|
||||
uint8_t version;
|
||||
/** sta mac address: big endian */
|
||||
uint8_t mac[0][IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_node_info_query_t;
|
||||
|
||||
typedef struct _iot_plc_nw_level_info {
|
||||
/** topo level */
|
||||
uint8_t level;
|
||||
/** station count of current level */
|
||||
uint16_t sta_cnt;
|
||||
} iot_plc_nw_level_info_t;
|
||||
|
||||
/* IOT_PLC_MSG_NW_INFO_QUERY_RPT format */
|
||||
typedef struct _iot_plc_nw_info_query_rpt {
|
||||
/** total station count in network */
|
||||
uint16_t total_sta_cnt;
|
||||
/** station count that are online */
|
||||
uint16_t online_sta_cnt;
|
||||
/** duration from CCO booting up to starting grouping network - unit 1s */
|
||||
uint32_t boot_fmt_time;
|
||||
/** network grouping time - unit 1s */
|
||||
uint16_t fmt_dur;
|
||||
/** route period - uint 1s */
|
||||
uint16_t rt_period;
|
||||
/** topo changing count */
|
||||
uint16_t topo_change_cnt;
|
||||
/** beacon period - unit 1s */
|
||||
uint8_t bc_period;
|
||||
/** maximum topo level */
|
||||
uint8_t max_level;
|
||||
/** info of each level */
|
||||
iot_plc_nw_level_info_t nw_level_info[0];
|
||||
} iot_plc_nw_info_query_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_NODE_INFO_QUERY_RPT format */
|
||||
typedef struct _iot_plc_node_info_rpt {
|
||||
/** total number of valid node */
|
||||
uint16_t total_count;
|
||||
/** number of valid node in current message */
|
||||
uint16_t count;
|
||||
/** report data version, see IOT_PLC_CCO_REQ_NODE_INFOR_VER_XXX */
|
||||
uint8_t version;
|
||||
/** report done */
|
||||
uint8_t done :1,
|
||||
/** error code, see IOT_PLC_CCO_QR_TOPO_DATA_XXX */
|
||||
err_code :2,
|
||||
/** reserved for future */
|
||||
reserved :5;
|
||||
/** node info of each valid tei, see iot_plc_node_info_xxx */
|
||||
uint8_t data[0];
|
||||
} iot_plc_node_info_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_PHY_PHASE_SET_REQ format */
|
||||
typedef struct _iot_plc_phy_phase_set_req {
|
||||
/** sta mac address: big endian */
|
||||
uint8_t mac[IOT_MAC_ADDR_LEN];
|
||||
/** physical phase of the device, bit0-2 means phaseA/B/C, set "1" to
|
||||
* indicate which phase the device belongs to.
|
||||
*/
|
||||
uint8_t phy_phase :3,
|
||||
/* flag to mark if L/N reversed in Single-phase power meter or phase
|
||||
* sequence reversed in Three-phase power meter.
|
||||
*/
|
||||
opposite_phase :1,
|
||||
/** reserved for future */
|
||||
reserved :4;
|
||||
} iot_plc_phy_phase_set_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_PHY_PHASE_SET_RPT format */
|
||||
typedef struct _iot_plc_phy_phase_set_rpt {
|
||||
/** result of the physical phase set request */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_phy_phase_set_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_PHY_PHASE_IDENT_SET format */
|
||||
typedef struct _iot_plc_phy_phase_ident_set_req {
|
||||
/** physical phase identification enable, 0 - disable, 1 - enable */
|
||||
uint8_t enable;
|
||||
} iot_plc_phy_phase_ident_set_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_PHY_PHASE_IDENT_SET_RPT format */
|
||||
typedef struct _iot_plc_phy_phase_ident_set_rpt {
|
||||
/** result of the physical phase identification set request */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_phy_phase_ident_set_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_APP_LOAD_SET_REQ format */
|
||||
typedef struct _iot_plc_app_load_set_req {
|
||||
/** application layer data traffic load level. see IOT_PLC_APP_LOAD_XXX */
|
||||
uint8_t load;
|
||||
} iot_plc_app_load_set_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_APP_LOAD_UPDATED format */
|
||||
typedef struct _iot_plc_app_load_update {
|
||||
/** application layer data traffic load level. see IOT_PLC_APP_LOAD_XXX */
|
||||
uint8_t load;
|
||||
} iot_plc_app_load_update_t;
|
||||
|
||||
/** IOT_PLC_MSG_SET_REPEATER_ADDR_RANGE format */
|
||||
typedef struct _iot_plc_repeater_addr_range_set_req {
|
||||
/** if the value is valid the repeater in the range are allowed to join
|
||||
* network.
|
||||
* if the value is invalid then all repeater are allowed to join network.
|
||||
*
|
||||
* 00:00:00:00:00:00 and FF:FF:FF:FF:FF:FF are invalid data, big endian.
|
||||
*/
|
||||
uint8_t repeater_addr_start[IOT_MAC_ADDR_LEN];
|
||||
uint8_t repeater_addr_end[IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_repeater_addr_range_set_req_t;
|
||||
|
||||
/* IOT_PLC_MSG_APP_SNIFFER_CFG format */
|
||||
typedef struct {
|
||||
/* 0 - disabled, other - enable */
|
||||
uint8_t cmd;
|
||||
} iot_plc_app_sniffer_cfg_t;
|
||||
|
||||
/* IOT_PLC_MSG_APP_SNIFFER_RECV format */
|
||||
typedef struct _iot_plc_msdu_app_sniffer_recv {
|
||||
/** final destion tei */
|
||||
uint16_t dst_tei;
|
||||
/** original source tei */
|
||||
uint16_t src_tei;
|
||||
/* network id */
|
||||
uint32_t nid;
|
||||
/* network addr, the byte order is Big-Endian */
|
||||
uint8_t nw_mac[IOT_MAC_ADDR_LEN];
|
||||
/* SNR of this mpdu */
|
||||
int8_t snr;
|
||||
/* RSSI of this mpdu */
|
||||
uint8_t rssi;
|
||||
/* reboot count */
|
||||
uint8_t reboot_cnt;
|
||||
/* msdu seq number */
|
||||
uint16_t sn;
|
||||
/* payload length */
|
||||
uint16_t len;
|
||||
/* msdu data payload */
|
||||
uint8_t data[0];
|
||||
} iot_plc_msdu_app_sniffer_recv_t;
|
||||
|
||||
/** IOT_PLC_MSG_NW_NEGO_SET format */
|
||||
typedef struct _iot_plc_set_nw_nego {
|
||||
/** neighbour network negotiation enable, 0 - disable, 1 - enable */
|
||||
uint8_t enable;
|
||||
} iot_plc_set_nw_nego_t;
|
||||
|
||||
/** IOT_PLC_MSG_NW_NEGO_SET_RPT format */
|
||||
typedef struct _iot_plc_set_nw_nego_rpt {
|
||||
/** result of network negotiation set request */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_set_nw_nego_rpt_t;
|
||||
|
||||
/** whitelist extended structure */
|
||||
typedef struct _iot_plc_wl_ext {
|
||||
/** mac address of sta device */
|
||||
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
|
||||
/** power line phase of sta device been locked */
|
||||
uint8_t phase : 2,
|
||||
/** reserved for future */
|
||||
rsvd : 6;
|
||||
} iot_plc_wl_ext_t;
|
||||
|
||||
/** IOT_PLC_MSG_NW_WL_EXT_RPT format */
|
||||
typedef struct _iot_plc_wl_ext_rpt {
|
||||
/** total count of whitelist entries */
|
||||
uint16_t total_count;
|
||||
/** count of entries contained in this reply packet */
|
||||
uint16_t count;
|
||||
/** report done */
|
||||
uint16_t done : 1,
|
||||
/** reserved for future */
|
||||
reserved : 15;
|
||||
/** whitelist entries */
|
||||
iot_plc_wl_ext_t wl[0];
|
||||
} iot_plc_wl_ext_rpt_t;
|
||||
|
||||
#pragma pack(pop) /* restore the pack status */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IOT_PLC_MSG_CCO_API_H */
|
258
export/inc/plc_lib/iot_plc_msg_sta_api.h
Executable file
258
export/inc/plc_lib/iot_plc_msg_sta_api.h
Executable file
@@ -0,0 +1,258 @@
|
||||
/****************************************************************************
|
||||
|
||||
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_PLC_MSG_STA_API_H
|
||||
#define IOT_PLC_MSG_STA_API_H
|
||||
|
||||
#include "os_types_api.h"
|
||||
#include "iot_utils_api.h"
|
||||
#include "iot_plc_msg_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
|
||||
|
||||
/** STA role specific PLC message id definitions */
|
||||
#define IOT_PLC_MSG_BEACON_DATA_RPT 0xC0
|
||||
#define IOT_PLC_MSG_ENABLE_DISCOVERY_REQ 0xC1
|
||||
#define IOT_PLC_MSG_ENABLE_DISCOVERY_RPT 0xC2
|
||||
#define IOT_PLC_MSG_DISCOVERY_NODE_RPT 0xC3
|
||||
#define IOT_PLC_MSG_TSFM_STATUS_REQ 0xC4
|
||||
#define IOT_PLC_MSG_TSFM_STATUS_RPT 0xC5
|
||||
#define IOT_PLC_MSG_CTRL_PROTO_CONNECT_REQ 0xC6
|
||||
#define IOT_PLC_MSG_CTRL_PROTO_CONNECT_CONF 0xC7
|
||||
#define IOT_PLC_MSG_SCANBAND_BITMAP_SET 0xC8
|
||||
#define IOT_PLC_MSG_SCANBAND_BITMAP_SET_RPT 0xC9
|
||||
#define IOT_PLC_MSG_PHASE_MASK_SET 0xCA
|
||||
#define IOT_PLC_MSG_PHASE_MASK_SET_CONF 0xCB
|
||||
#define IOT_PLC_MSG_PKT_CAPTURE_SET_REQ 0XCC
|
||||
#define IOT_PLC_MSG_PKT_CAPTURE_SET_RPT 0XCD
|
||||
#define IOT_PLC_MSG_PM_ADDR_SET 0XCE
|
||||
#define IOT_PLC_MSG_PM_ADDR_SET_RPT 0xCF
|
||||
#define IOT_PLC_MSG_RTC_UPDATE_RPT 0xD0
|
||||
|
||||
/** transformer detect feature is disabled */
|
||||
#define IOT_PLC_TSFM_DETECT_OFF 1
|
||||
/** transformer detect is ongoing */
|
||||
#define IOT_PLC_TSFM_DETECT_ONGOING 2
|
||||
/** transformer detect is done */
|
||||
#define IOT_PLC_TSFM_DETECT_DONE 3
|
||||
|
||||
/** IOT_PLC_MSG_BEACON_DATA_RPT format */
|
||||
typedef struct _iot_plc_beacon_data_rpt {
|
||||
/** beacon data to be reported */
|
||||
uint8_t data[IOT_PLC_BEACON_DATA_MAX];
|
||||
} iot_plc_beacon_data_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_ENABLE_DISCOVERY_REQ format */
|
||||
typedef struct _iot_plc_enable_discovery_req {
|
||||
/**
|
||||
* Note that this function is only available when local STA not joined to
|
||||
* any network and in started status.
|
||||
* 1 - enable active report every time local device receive a beacon
|
||||
* or discovery node list MME.
|
||||
* 0 - disable the report. by default, the report disabled.
|
||||
*/
|
||||
uint8_t enable;
|
||||
} iot_plc_enable_discovery_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_ENABLE_DISCOVERY_RPT format */
|
||||
typedef struct _iot_plc_enable_discovery_rpt {
|
||||
/** result of the eanble discovery request */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_enable_discovery_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_DISCOVERY_NODE_RPT format */
|
||||
typedef struct _iot_plc_discovery_node_rpt {
|
||||
/** tei of the discovered node */
|
||||
uint32_t tei :12,
|
||||
/** proxy tei of the discovered node */
|
||||
proxy :12,
|
||||
/** role of the discovered node. see IOT_PLC_DEV_ROLE_XXX */
|
||||
role :4,
|
||||
/** level of the discovered node */
|
||||
level :4;
|
||||
/** minimum traffic success ratio with CCO of the discovered node */
|
||||
uint32_t min_ul_dl_sr:8,
|
||||
/** network ID of the discovered node */
|
||||
nid :24;
|
||||
/** logical phase of the discovered node. see IOT_PLC_PHASE_XXX */
|
||||
uint8_t phase :2,
|
||||
/** flag to mark if the node is from the same vendor as us */
|
||||
same_vendor :1,
|
||||
/** flag to mark if same_vendor flag is valid */
|
||||
vendor_valid:1,
|
||||
/** flag to mark if the node is from rf link */
|
||||
is_rf :1,
|
||||
/** reserved for future */
|
||||
rsvd :3;
|
||||
/** rx snr of the discoverted node */
|
||||
int8_t rx_snr;
|
||||
/** rx band of the node */
|
||||
uint8_t band_id;
|
||||
/** mac address of the discoverted node */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
/** cco mac address of the discoverted node */
|
||||
uint8_t cco_addr[IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_discovery_node_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_RTC_UPDATE_RPT format */
|
||||
typedef struct _iot_plc_rtc_update_rpt {
|
||||
/* stand for the delta between cco rtc and the base timer 2000.1.1 00:00:00,
|
||||
* unit is 1s
|
||||
*/
|
||||
uint32_t cco_date;
|
||||
/* cco ntb of corresponding date, unit is 1NTB */
|
||||
uint32_t cco_ntb;
|
||||
} iot_plc_rtc_update_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_TSFM_STATUS_RPT format */
|
||||
typedef struct _iot_plc_tsfm_status_rpt {
|
||||
/** transformer area detect status. see IOT_PLC_TSFM_DETECT_XXX */
|
||||
uint8_t status;
|
||||
/** flag to mark if local device is in the white list of current network */
|
||||
uint8_t in_cco_wl :1,
|
||||
/** flag to mark if in in_cco_wl flag is valid */
|
||||
in_cco_wl_valid :1,
|
||||
/* flag to mark if physical phase connection is valid */
|
||||
phy_phase_1_valid :1,
|
||||
phy_phase_2_valid :1,
|
||||
phy_phase_3_valid :1,
|
||||
/* flag to mark if L/N reversed in Three-phase power meter
|
||||
* just when all phy_phase_1_valid / phy_phase_2_valid / phy_phase_3_valid
|
||||
* is set, this flag is valid
|
||||
*/
|
||||
opposite_3p :1,
|
||||
/* collection edge type, see IOT_PLC_ZC_CT_XXX_EDGE */
|
||||
zc_type :2;
|
||||
/** current network CCO mac address */
|
||||
uint8_t cco_addr[IOT_MAC_ADDR_LEN];
|
||||
/** mac address of the transformer area that local device possibly
|
||||
* belong to. this value is only available when transformer detect
|
||||
* feature is enabled.
|
||||
*/
|
||||
uint8_t tsfm_addr[IOT_MAC_ADDR_LEN];
|
||||
/** CCO mac address of the transformer area that local device possibly
|
||||
* belong to. this value is only available when transformer detect
|
||||
* feature is enabled.
|
||||
*/
|
||||
uint8_t tsfm_cco_addr[IOT_MAC_ADDR_LEN];
|
||||
/* record the sn of zc status report */
|
||||
uint8_t zc_status_sn;
|
||||
/* app data forward total count */
|
||||
uint32_t app_data_fwd_cnt;
|
||||
} iot_plc_tsfm_status_rpt_t;
|
||||
|
||||
/* IOT_PLC_MSG_CTRL_PROTO_CONNECT_REQ format */
|
||||
typedef struct _iot_plc_ctrl_proto_connect_req {
|
||||
/* target address to be conneted, the byte order is Big-Endian. */
|
||||
uint8_t addr[IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_ctrl_proto_connect_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_CTRL_PROTO_CONNECT_CONF format */
|
||||
typedef struct _iot_plc_ctrl_proto_connect_conf {
|
||||
/* result of handling request */
|
||||
uint8_t result;
|
||||
/* error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_ctrl_proto_connect_conf_t;
|
||||
|
||||
/* IOT_PLC_MSG_SCANBAND_BITMAP_SET format */
|
||||
typedef struct _iot_plc_set_scanband_bitmap {
|
||||
/** support band bitmap */
|
||||
uint8_t band_bitmap[IOT_PLC_BAND_BITMAP_SIZE];
|
||||
} iot_plc_set_scanband_bitmap_t;
|
||||
|
||||
/* IOT_PLC_MSG_SCANBAND_BITMAP_SET_RPT format */
|
||||
typedef struct _iot_plc_set_scanband_bitmap_rpt {
|
||||
/** result of the freq band set request */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_set_scanband_bitmap_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_PHASE_MASK_SET format */
|
||||
typedef struct _iot_plc_set_phase_mask {
|
||||
/* phase to be masked off so that CCO won't be able to get corresponding
|
||||
* phase zero crossing info, bit 0~2 corresponds to phase 1/2/3.
|
||||
*/
|
||||
uint8_t phase_mask;
|
||||
} iot_plc_set_phase_mask_t;
|
||||
|
||||
/** IOT_PLC_MSG_PHASE_MASK_SET_CONF format */
|
||||
typedef struct _iot_plc_set_phase_mask_conf {
|
||||
/** result of the set phase mask */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_set_phase_mask_conf_t;
|
||||
|
||||
/** IOT_PLC_MSG_SET_PKT_CAPTURE_REQ */
|
||||
typedef struct _iot_plc_set_pkt_capture_req {
|
||||
/** enable capture. 0 - disable, 1 - enable. */
|
||||
uint16_t enable :1,
|
||||
/** bitmap len */
|
||||
bm_len :9,
|
||||
/** reserved for future */
|
||||
rsvd :6;
|
||||
/** tei bitmap, if a bit is set, it means that corresponding tei is valid.
|
||||
* bit0 has no meaning, bit1 means tei 1, bit 2 means tei 2.
|
||||
*/
|
||||
uint8_t bm[0];
|
||||
} iot_plc_set_pkt_capture_req_t;
|
||||
|
||||
/** IOT_PLC_MSG_SET_PKT_CAPTURE_RPT format */
|
||||
typedef struct _iot_plc_set_pkt_capture_rpt {
|
||||
/** result of the pkt capture request */
|
||||
uint16_t result :7,
|
||||
/** bitmap len */
|
||||
bm_len :9;
|
||||
/** all valid tei bitmap returned, if a bit is set, it means that
|
||||
* corresponding tei is being captured. bit0 has no meaning, bit1 means
|
||||
* tei 1, bit2 means tei 2.
|
||||
*/
|
||||
uint8_t bm[0];
|
||||
} iot_plc_set_pkt_capture_rpt_t;
|
||||
|
||||
/** IOT_PLC_MSG_PM_ADDR_SET format */
|
||||
typedef struct _iot_plc_set_pm_addr {
|
||||
/* pm cnt */
|
||||
uint8_t cnt;
|
||||
/* pm addr, big-endian */
|
||||
uint8_t addr[0][IOT_MAC_ADDR_LEN];
|
||||
} iot_plc_set_pm_addr_t;
|
||||
|
||||
/* IOT_PLC_MSG_PM_ADDR_SET_RPT format */
|
||||
typedef struct _iot_plc_set_pm_addr_rpt {
|
||||
/** result of pm addr set request */
|
||||
uint8_t result;
|
||||
/** error number */
|
||||
uint8_t err_no;
|
||||
} iot_plc_set_pm_addr_rpt_t;
|
||||
|
||||
#pragma pack(pop) /* restore the pack status */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IOT_PLC_MSG_STA_API_H */
|
168
export/inc/plc_lib/iot_plc_sta_api.h
Executable file
168
export/inc/plc_lib/iot_plc_sta_api.h
Executable file
@@ -0,0 +1,168 @@
|
||||
/****************************************************************************
|
||||
|
||||
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_PLC_STA_API_H
|
||||
#define IOT_PLC_STA_API_H
|
||||
|
||||
#include "os_types_api.h"
|
||||
#include "iot_plc_api.h"
|
||||
#include "iot_pkt_api.h"
|
||||
#include "iot_plc_msg_sta_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief iot_plc_tsfm_state_lock() - lock the state of transformer detect.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
*/
|
||||
#define iot_plc_tsfm_state_lock(handle) \
|
||||
iot_plc_tsfm_state_change(handle, IOT_PLC_API_REQ_ID_DEFAULT, \
|
||||
IOT_PLC_TSFM_STATE_LOCK, NULL, 0, 0, NULL, NULL, 0)
|
||||
|
||||
/**
|
||||
* @brief iot_plc_tsfm_state_unlock() - unlock the state of transformer detect.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param unlock_delay: unlock delay time, unit is 1min.
|
||||
*/
|
||||
#define iot_plc_tsfm_state_unlock(handle, unlock_delay) \
|
||||
iot_plc_tsfm_state_change(handle, IOT_PLC_API_REQ_ID_DEFAULT, \
|
||||
IOT_PLC_TSFM_STATE_UNLOCK, NULL, 0, 0, NULL, NULL, unlock_delay)
|
||||
|
||||
/**
|
||||
* @brief iot_plc_tsfm_set_tsfm_addr() - set transformer address info.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param tsfm_addr: transformer mac address
|
||||
*/
|
||||
#define iot_plc_tsfm_set_tsfm_addr(handle, tsfm_addr) \
|
||||
iot_plc_tsfm_state_change(handle, IOT_PLC_API_REQ_ID_DEFAULT, \
|
||||
IOT_PLC_TSFM_STATE_INVALID, tsfm_addr, 0, 0, NULL, NULL, 0)
|
||||
|
||||
/**
|
||||
* @brief iot_plc_tsfm_set_tsfm_lock_time() - set transformer lock time.
|
||||
* @param handle: plc application handler
|
||||
* @param net_lock_time: pointer to the net lock time.
|
||||
* @param abn_lock_time: pointer to the lock time of abnormal leave net.
|
||||
*/
|
||||
#define iot_plc_tsfm_set_lock_time(handle, net_lock_time, abn_lock_time) \
|
||||
iot_plc_tsfm_state_change(handle, IOT_PLC_API_REQ_ID_DEFAULT, \
|
||||
IOT_PLC_TSFM_STATE_INVALID, NULL, 0, 0, net_lock_time, abn_lock_time, 0)
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_discovery_mode() - enable/disable discovery mode. Note
|
||||
* that this function is only available when local STA not joined to
|
||||
* any network and in started status.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param enable: 0 - disable, otherwise - enable
|
||||
*/
|
||||
void iot_plc_set_discovery_mode(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t enable);
|
||||
|
||||
/**
|
||||
* @brief query transformer area detection status of local device.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
*/
|
||||
void iot_plc_query_tsfm_status(iot_plc_app_h handle, uint8_t req_id);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_ctrl_proto_connect() - connect the specified target device -
|
||||
* STA or CCO, this connection behavior is defined in the controller
|
||||
* protocol.
|
||||
* @param handle: - plc application handler
|
||||
* @param req_id: - request id, the request id will be transferred back
|
||||
* to app in the report. app can define the mean of
|
||||
* each id itself.
|
||||
* @param addr: - target device address to be connected, the byte order is
|
||||
* Big-Endian.
|
||||
*/
|
||||
void iot_plc_ctrl_proto_connect(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t *addr);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_scan_band_bitmap() - plc set band bitmap.
|
||||
*
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param band_bitmap: set scan band bitmap.
|
||||
* e: band_bitmap = b0000 0000 0000 0100
|
||||
* -> enable band PLC_LIB_FREQ_BAND_2
|
||||
* @param size: size of scan bitmap,
|
||||
* need equal to IOT_PLC_BAND_BITMAP_SIZE.
|
||||
*/
|
||||
void iot_plc_set_scan_band_bitmap(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t *band_bitmap, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_phase_mask() - plc set phase mask.
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param phase_mask: phase to be masked off so that CCO won't be able to get
|
||||
* corresponding phase zero crossing info, bit 0~2
|
||||
* corresponds to phase 1/2/3.
|
||||
*/
|
||||
void iot_plc_set_phase_mask(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t phase_mask);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_pkt_capture() - set the tei bitmap to be captured
|
||||
* to capture application layer frames. only supports capture
|
||||
* the packets matching destination tei.
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param bm: tei bitmap. if a bit is set, it means that corresponding
|
||||
* tei is valid. bit0 has no meaning, bit1 means tei 1,
|
||||
* bit 2 means tei 2.
|
||||
* @param bm_len: bitmap len
|
||||
* @param enable: enable capture. 0 - disable, 1 - enable.
|
||||
*/
|
||||
void iot_plc_set_pkt_capture(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t *bm, uint16_t bm_len, uint8_t enable);
|
||||
|
||||
/**
|
||||
* @brief iot_plc_set_pm_addr() - set the address of power meter connected
|
||||
* @param handle: plc application handler
|
||||
* @param req_id: request id, the request id will be transferred back to
|
||||
* app in the report. app can define the mean of each id
|
||||
* itself.
|
||||
* @param addr_array: mac address array of power meter connected, big-endian
|
||||
* @param cnt: count of power meter connected, 0 means clear
|
||||
* mac address of power meter connected
|
||||
*/
|
||||
void iot_plc_set_pm_addr(iot_plc_app_h handle, uint8_t req_id,
|
||||
uint8_t *addr_array, uint8_t cnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IOT_PLC_STA_API_H */
|
Reference in New Issue
Block a user