677 lines
29 KiB
C
Executable File
677 lines
29 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_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 */
|