149 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			149 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /****************************************************************************
 | |
| 
 | |
| 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_SWC_API_H
 | |
| #define IOT_SWC_API_H
 | |
| 
 | |
| #include "os_types_api.h"
 | |
| #include "iot_swc_msg_api.h"
 | |
| #include "iot_pkt_api.h"
 | |
| #include "iot_sg_fr.h"
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| #if IOT_SWC_ENABLE
 | |
| 
 | |
| /**
 | |
|  * @brief iot_swc_alloc_msdu() - allocate iot packet for msdu data send.
 | |
|  *                      be notified through iot_swc_recv_func_t callback.
 | |
|  * @param msg_type:     type of the message. see IOT_SWC_MSG_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
 | |
|  * @return              the pointer of iot packet
 | |
|  */
 | |
| iot_pkt_t *iot_swc_alloc_msdu(uint8_t msg_type, uint8_t *dst, uint8_t *src,
 | |
|     uint8_t lid, uint16_t len);
 | |
| 
 | |
| /**
 | |
|  * @brief: send a packet through the swc. there is no
 | |
|  *         guarantee that the packet will be delivered to the
 | |
|  *         final destination as the swc network is unreliable. the
 | |
|  *         pkt must be allocated through iot_swc_alloc_msdu api.
 | |
|  * @param pkt:  pointer to the packet
 | |
|  */
 | |
| void iot_swc_send_msdu(iot_pkt_t *pkt);
 | |
| 
 | |
| /**
 | |
|  * @brief: get a swc msdu from a plc msdu.
 | |
|  * @param msdu: a iot_pkt containing plc msdu
 | |
|  * @retval: a iot_pkt with a swc msdu in it.
 | |
|  *          Or NULL if failed to allocate an iot_pkt.
 | |
|  */
 | |
| iot_pkt_t *iot_plc_msdu_2_swc_msdu(iot_pkt_t *msdu);
 | |
| 
 | |
| /*
 | |
| * @brief: send a packet through the swc. the pkt must be allocated
 | |
|           through iot_plc_alloc_msdu api. This api consumed the iot_pkt.
 | |
|  * @param pkt:  pointer to the packet containing plc msdu.
 | |
|  */
 | |
| void iot_swc_send_plc_msdu(iot_pkt_t *pkt);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_swc_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_swc_query_whitelist(uint8_t req_id, uint16_t start, uint16_t cnt);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_swc_set_whitelist() - set whitelist
 | |
|  * @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_SWC_WL_XXX
 | |
|  * @param count:            number of mac address
 | |
|  * @param mac_addry_array:  array of mac address
 | |
|  */
 | |
| void iot_swc_set_whitelist(uint8_t req_id, uint8_t action, uint16_t count,
 | |
|     uint8_t *mac_addr_array);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_swc_set_cfg() - set configuration of local device
 | |
|  * @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:         mac address to be set. set NULL if mac address
 | |
|  *                      change not required.
 | |
|  * @param dev_type:     device type to be set. set IOT_SWC_DEV_TYPE_INVALID
 | |
|  *                      if device type chage not required.
 | |
|  * @param reset:        reset lower layer to apply the cfg immediately.
 | |
|  */
 | |
| void iot_swc_set_cfg(uint8_t req_id, uint8_t *addr, uint8_t dev_type,
 | |
|     uint8_t reset);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_swc_start_nw_fmt() - start network formation
 | |
|  * @param force:        flag to mark if force start required. if swc network
 | |
|  *                      formation already started, set this flag will restart
 | |
|  *                      the whole process from the very beginning.
 | |
|  */
 | |
| void iot_swc_start_nw_fmt(uint8_t force);
 | |
| 
 | |
| /*
 | |
|  * @brief: init swc library
 | |
|  * @param cb: callback method to receive data from swc link
 | |
|  */
 | |
| void iot_swc_init(iot_swc_lib_cb_t cb);
 | |
| 
 | |
| #else   //IOT_SWC_ENABLE
 | |
| 
 | |
| #define iot_swc_alloc_msdu(msg_type, dst, src, lid, len)
 | |
| 
 | |
| #define iot_swc_send_msdu(pkt)
 | |
| 
 | |
| #define iot_plc_msdu_2_swc_msdu(msdu)
 | |
| 
 | |
| #define iot_swc_send_plc_msdu(pkt)
 | |
| 
 | |
| #define iot_swc_query_whitelist(req_id, start, cnt)
 | |
| 
 | |
| #define iot_swc_set_whitelist(req_id, action, count, mac_addr_array)
 | |
| 
 | |
| #define  iot_swc_set_cfg(req_id, addr, dev_type, reset)
 | |
| 
 | |
| #define iot_swc_start_nw_fmt(force)
 | |
| 
 | |
| #define iot_swc_init(cb)
 | |
| 
 | |
| #endif /* IOT_SWC_ENABLE */
 | |
| 
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif /* IOT_SWC_API_H */
 |