125 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			125 lines
		
	
	
		
			3.4 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 BEACON_FRAME_H
 | ||
|  | #define BEACON_FRAME_H
 | ||
|  | 
 | ||
|  | #include "plc_fr.h"
 | ||
|  | #include "os_types.h"
 | ||
|  | 
 | ||
|  | #include "plc_beacon.h"
 | ||
|  | #include "iot_pkt_api.h"
 | ||
|  | #include "plc_utils.h"
 | ||
|  | #include "iot_utils_api.h"
 | ||
|  | #include "mac_vdev.h"
 | ||
|  | #include "mac_bcm_api.h"
 | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | extern "C" { | ||
|  | #endif
 | ||
|  | 
 | ||
|  | /**
 | ||
|  | * beacon fixd pload header message | ||
|  | */ | ||
|  | typedef struct _bcn_pld_hdr { | ||
|  |     uint8_t  beacon_type; | ||
|  |     uint8_t  cco_addr[IOT_MAC_ADDR_LEN]; | ||
|  |     uint32_t beacon_seq_num; | ||
|  | } bcn_pld_hdr_t; | ||
|  | 
 | ||
|  | typedef struct _mac_bc_ent_str_info { | ||
|  |     uint8_t plh_str_size; | ||
|  |     uint8_t sta_cap_str_size; | ||
|  |     uint8_t rt_param_str_size; | ||
|  |     uint8_t simple_param_str_size; | ||
|  |     void *plh_str_ptr; | ||
|  |     void *sta_cap_str_ptr; | ||
|  |     void *rt_param_str_ptr; | ||
|  |     void *simple_param_str_ptr; | ||
|  | } mac_bc_ent_str_info_t; | ||
|  | 
 | ||
|  | /* This file contains the beacon structure definition
 | ||
|  |  * and function to get/set the related field for packed | ||
|  |  * structure | ||
|  |  */ | ||
|  | 
 | ||
|  | #define MAC_BEACON_IS_DETECT     0xFF
 | ||
|  | #define MAC_BEACON_IS_NORMAL     0
 | ||
|  | 
 | ||
|  | /* pack for the structures in the whole file */ | ||
|  | #pragma pack(push)   // save the pack status
 | ||
|  | #pragma pack(1)      // 1 byte align
 | ||
|  | 
 | ||
|  | 
 | ||
|  | #if SUPPORT_SMART_GRID
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | /* api definition */ | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | #elif SUPPORT_SOUTHERN_POWER_GRID
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | /* api definition */ | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | #elif SUPPORT_GREEN_PHY
 | ||
|  | #else
 | ||
|  | #error("no PLC network type defined.")
 | ||
|  | #endif
 | ||
|  | 
 | ||
|  | #pragma pack(pop)   // restore the pack status
 | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief           calculate beacon tx fl time | ||
|  |  * @param proto:            mpdu data protocol, eg. | ||
|  |  *                              PLC_PROTO_TYPE_SG 0 | ||
|  |  *                              PLC_PROTO_TYPE_GP 1 | ||
|  |  *                              PLC_PROTO_TYPE_AV 2 | ||
|  |  *                              PLC_PROTO_TYPE_SPG 3 | ||
|  |  * @param rate_mode:        0: SR, 1:QR, 2:XR, 3: FSK | ||
|  |  * @param proto_band_id:    proto band id | ||
|  |  * @param tmi:              tmi mode | ||
|  |  * @param ext_tmi:          ext tmi mode | ||
|  |  * @return:                 frame tx time(unit: us) | ||
|  |  * | ||
|  |  */ | ||
|  | uint32_t mac_tx_fl_cal_bcn(uint8_t proto, uint8_t rate_mode, \ | ||
|  |     uint32_t proto_band_id, uint8_t tmi, uint8_t ext_tmi); | ||
|  | 
 | ||
|  | uint32_t mac_send_bcn(uint32_t proto, uint32_t proto_band_id, \ | ||
|  |     pdevid_t pdev_id, iot_pkt_t* bcn_buf, \ | ||
|  |     uint32_t rate_mode, uint8_t phase, uint8_t retry_cnt, uint32_t tx_power); | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @brief mac_beacon_fill_pld_icv    - mac beacon fill icv(crc). | ||
|  |  * @param proto:                     - protocal. | ||
|  |  * @param data:                      - the point of data. | ||
|  |  * @param bcn_buf:                   - the point of beacon buf. | ||
|  |  * @return void:                     - void. | ||
|  |  */ | ||
|  | void mac_beacon_fill_pld_icv(uint32_t proto, uint8_t *data, | ||
|  |     iot_pkt_t* bcn_buf); | ||
|  | 
 | ||
|  | #ifdef __cplusplus
 | ||
|  | } | ||
|  | #endif
 | ||
|  | 
 | ||
|  | #endif
 |