Skip to content

Commit 85ab8fd

Browse files
author
Juha Heiskanen
committed
Extented Frame exchange support
Added support send Extented frame exchange when MAC ack functionality is disabled and mac user handle those. MAC-API have new API for enable new feature and add Callback for detect Extented Data flow packet and send responses. MAC support only 1 active EDFE Data request. Wi-sun DSN duplicate check is disabled for EFDE frames. Wi-sun EFDE TX process do allways full handshake which not add data to initial frame. Fix unit test's.
1 parent 86b1f27 commit 85ab8fd

21 files changed

+635
-44
lines changed

nanostack/mac_api.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ typedef void mcps_data_indication_ext(const mac_api_t *api, const mcps_data_ind_
183183
typedef void mcps_ack_data_req_ext(const mac_api_t *api, mcps_ack_data_payload_t *data, int8_t rssi, uint8_t lqi);
184184

185185

186+
/**
187+
* @brief mcps_edfe_handler Callback for handle and detect edfe frame
188+
* @param api The API which handled the response
189+
* @param response_message Enhanced message response data and status
190+
*/
191+
typedef void mcps_edfe_handler(const mac_api_t *api, mcps_edfe_response_t *response_message);
192+
193+
186194
/**
187195
* @brief mcps_purge_confirm MCPS-PURGE confirm is called as a response to MCPS-PURGE request
188196
* @param api The API which handled the request
@@ -254,6 +262,15 @@ typedef int8_t mac_api_enable_mcps_ext(mac_api_t *api,
254262
mcps_data_confirm_ext *data_cnf_cb,
255263
mcps_ack_data_req_ext *ack_data_req_cb);
256264

265+
/**
266+
* @brief mac_api_enable_mcps_edfe_ext Initialises MAC 2015 extension for EDFE handler callbacks must be non-NULL.
267+
* @param api mac_api_t pointer, which is created by application.
268+
* @param edfe_ind_cb Upper layer function to handle and detect EDFE's
269+
* @return -1 if error, -2 if OOM, 0 otherwise
270+
*/
271+
typedef int8_t mac_api_enable_mcps_edfe_ext(mac_api_t *api,
272+
mcps_edfe_handler *edfe_ind_cb);
273+
257274
/**
258275
* \brief Struct mac_api_s defines functions for two-way communications between external MAC and Upper layer.
259276
* Application creates mac_api_t object by calling external MAC's creator function.
@@ -263,17 +280,18 @@ typedef int8_t mac_api_enable_mcps_ext(mac_api_t *api,
263280
struct mac_api_s {
264281
mac_api_initialize *mac_initialize; /**< MAC initialize function to use */
265282
mac_api_enable_mcps_ext *mac_mcps_extension_enable; /**< MAC MCPS IE extension enable function, optional feature */
283+
mac_api_enable_mcps_edfe_ext *mac_mcps_edfe_enable; /**< MAC MCPS MCPS EDFE frame extension enable function, optional feature */
266284
//External MAC callbacks
267285
mlme_request *mlme_req; /**< MAC MLME request function to use */
268286
mcps_data_request *mcps_data_req; /**< MAC MCPS data request function to use */
269287
mcps_data_request_ext *mcps_data_req_ext; /**< MAC MCPS data request with Information element extension function to use */
270288
mcps_purge_request *mcps_purge_req; /**< MAC MCPS purge request function to use */
271-
272289
//Upper layer callbacksMLME_ASSOCIATE
273290
mcps_data_confirm *data_conf_cb; /**< MAC MCPS data confirm callback function */
274291
mcps_data_confirm_ext *data_conf_ext_cb; /**< MAC MCPS data confirm with payload callback function */
275292
mcps_data_indication *data_ind_cb; /**< MAC MCPS data indication callback function */
276293
mcps_data_indication_ext *data_ind_ext_cb; /**< MAC MCPS data indication with IE extension's callback function */
294+
mcps_edfe_handler *edfe_ind_cb; /**< MAC MCPS EDFE detection extension's callback function */
277295
mcps_ack_data_req_ext *enhanced_ack_data_req_cb; /**< Enhanced ACK IE element and payload request from MAC user */
278296
mcps_purge_confirm *purge_conf_cb; /**< MAC MCPS purge confirm callback function */
279297
mlme_confirm *mlme_conf_cb; /**< MAC MLME confirm callback function */

nanostack/mac_mcps.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ typedef struct mcps_data_req_s {
4444
bool PendingBit: 1; /**< Specifies whether more fragments are to be sent or not */
4545
bool SeqNumSuppressed: 1; /**< True suppress sequence number from frame. This will be only checked when 2015 extension is enabled */
4646
bool PanIdSuppressed: 1; /**< True suppress PAN-id is done when possible from frame. This will be only checked when 2015 extension is enabled */
47+
bool ExtendedFrameExchange: 1; /**< True for Extended Frame change. This will be only checked when 2015 extension and enhanced frame is enabled */
4748
mlme_security_t Key; /**< Security key */
4849
} mcps_data_req_t;
4950

@@ -86,6 +87,7 @@ typedef struct mcps_data_ind_s {
8687
uint16_t SrcPANId; /**< Source PAN ID */
8788
uint8_t SrcAddr[8]; /**< Source address */
8889
unsigned DstAddrMode: 2; /**< Destination address mode */
90+
bool DSN_suppressed: 1; /**< Indicate when DSN not include valid sequency id */
8991
uint16_t DstPANId; /**< Destination PAN ID */
9092
uint8_t DstAddr[8]; /**< Destination address */
9193
uint8_t mpduLinkQuality; /**< LQI value measured during reception of the MPDU */
@@ -164,5 +166,31 @@ typedef struct mcps_purge_conf_s {
164166
uint8_t status; /**< Status of the purge performed */
165167
} mcps_purge_conf_t;
166168

169+
#define MCPS_EDFE_NORMAL_FRAME 0 /**< Normal Data message normal behaviour */
170+
#define MCPS_EDFE_MALFORMED_FRAME 1 /**< Drop whole packet */
171+
#define MCPS_EDFE_TX_FRAME 2 /**< Tx message send data if pending in 1ms -5ms time window */
172+
#define MCPS_EDFE_RESPONSE_FRAME 3 /**< Response message send data if pending in 1ms -5ms time window */
173+
#define MCPS_EDFE_FINAL_FRAME_TX 4 /**< Final response message send in 1ms -5ms time window */
174+
#define MCPS_EDFE_FINAL_FRAME_RX 5 /**< EDFE session can be close at MAC side and drop this packet */
175+
176+
/**
177+
* @brief struct mcps_edfe_response_t EDFE detetction and response structure
178+
*
179+
*/
180+
typedef struct mcps_edfe_response_s {
181+
struct mcps_data_ie_list ie_elements; /**< IE hader and payload's elements from Packet */
182+
struct mcps_data_req_ie_list ie_response; /**< IE hader and payload's elements for Response Packet */
183+
uint8_t edfe_message_status; /**< Indicate Packet handler status */
184+
uint8_t message_handle; /**< EDFE Data request message ID for detect pending data at LLC layer*/
185+
int8_t rssi; /**< Received packet signal streng in dbm */
186+
unsigned SrcAddrMode: 2; /**< Source address mode: used for RX validation and TX purpose */
187+
unsigned DstAddrMode: 2; /**< Destination address mode: used for RX validation and TX purpose */
188+
uint8_t Address[8]; /**< RX: Packet Address Src & TX Response Destination address */
189+
bool SeqNumSuppressed: 1; /**< True suppress sequence number from frame. This will be only checked when 2015 extension is enabled */
190+
bool PanIdSuppressed: 1; /**< True suppress PAN-id is done when possible from frame. */
191+
bool wait_response: 1; /**< True enable response wait timer and re-send operation. */
192+
bool use_message_handle_to_discover: 1; /**< EDFE Data request message ID is valid at message_handle. */
193+
} mcps_edfe_response_t;
194+
167195

168196
#endif // MAC_MCPS_H

source/6LoWPAN/adaptation_interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ static void lowpan_data_request_to_mac(protocol_interface_info_entry_t *cur, buf
938938
}
939939

940940
if (interface_ptr->mpx_api) {
941+
dataReq.ExtendedFrameExchange = buf->options.edfe_mode;
941942
interface_ptr->mpx_api->mpx_data_request(interface_ptr->mpx_api, &dataReq, interface_ptr->mpx_user_id);
942943
} else {
943944
cur->mac_api->mcps_data_req(cur->mac_api, &dataReq);

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ typedef struct ws_bt_ie {
130130
uint_fast24_t broadcast_interval_offset;
131131
} ws_bt_ie_t;
132132

133+
/**
134+
* @brief ws_fc_ie_t WS FC-IE element
135+
*/
136+
typedef struct ws_fc_ie {
137+
uint8_t tx_flow_ctrl;
138+
uint8_t rx_flow_ctrl;
139+
} ws_fc_ie_t;
133140

134141
/**
135142
* @brief ws_channel_plan_zero_t WS channel plan 0 define domain and class

source/6LoWPAN/ws/ws_ie_lib.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ uint8_t *ws_wh_bt_write(uint8_t *ptr)
110110
}
111111

112112

113-
uint8_t *ws_wh_fc_write(uint8_t *ptr, uint8_t flow_ctrl)
113+
uint8_t *ws_wh_fc_write(uint8_t *ptr, ws_fc_ie_t *fc_ie)
114114
{
115-
ptr = ws_wh_header_base_write(ptr, 1, WH_IE_FC_TYPE);
116-
*ptr++ = flow_ctrl;
115+
ptr = ws_wh_header_base_write(ptr, 2, WH_IE_FC_TYPE);
116+
*ptr++ = fc_ie->tx_flow_ctrl;
117+
*ptr++ = fc_ie->rx_flow_ctrl;
117118
return ptr;
118119
}
119120

@@ -341,6 +342,19 @@ bool ws_wh_bt_read(uint8_t *data, uint16_t length, struct ws_bt_ie *bt_ie)
341342
return true;
342343
}
343344

345+
bool ws_wh_fc_read(uint8_t *data, uint16_t length, struct ws_fc_ie *fc_ie)
346+
{
347+
mac_header_IE_t fc_ie_data;
348+
fc_ie_data.id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID;
349+
if (2 != mac_ie_header_sub_id_discover(data, length, &fc_ie_data, WH_IE_FC_TYPE)) {
350+
return false;
351+
}
352+
data = fc_ie_data.content_ptr;
353+
fc_ie->tx_flow_ctrl = *data++;
354+
fc_ie->rx_flow_ctrl = *data;
355+
return true;
356+
}
357+
344358
bool ws_wh_rsl_read(uint8_t *data, uint16_t length, int8_t *rsl)
345359
{
346360
mac_header_IE_t rsl_ie_data;

source/6LoWPAN/ws/ws_ie_lib.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct ws_utt_ie;
2323
struct ws_bt_ie;
2424
struct ws_us_ie;
2525
struct ws_hopping_schedule_s;
26+
struct ws_fc_ie;
2627

2728
/**
2829
* @brief ws_wp_network_name_t WS nested payload network name
@@ -35,13 +36,14 @@ typedef struct ws_wp_network_name {
3536
/* WS_WH HEADER IE */
3637
uint8_t *ws_wh_utt_write(uint8_t *ptr, uint8_t message_type);
3738
uint8_t *ws_wh_bt_write(uint8_t *ptr);
38-
uint8_t *ws_wh_fc_write(uint8_t *ptr, uint8_t flow_ctrl);
39+
uint8_t *ws_wh_fc_write(uint8_t *ptr, struct ws_fc_ie *fc_ie);
3940
uint8_t *ws_wh_rsl_write(uint8_t *ptr, uint8_t rsl);
4041
uint8_t *ws_wh_vh_write(uint8_t *ptr, uint8_t *vendor_header, uint8_t vendor_header_length);
4142
uint8_t *ws_wh_ea_write(uint8_t *ptr, uint8_t *eui64);
4243

4344
bool ws_wh_utt_read(uint8_t *data, uint16_t length, struct ws_utt_ie *utt_ie);
4445
bool ws_wh_bt_read(uint8_t *data, uint16_t length, struct ws_bt_ie *bt_ie);
46+
bool ws_wh_fc_read(uint8_t *data, uint16_t length, struct ws_fc_ie *fc_ie);
4547
bool ws_wh_rsl_read(uint8_t *data, uint16_t length, int8_t *rsl);
4648
bool ws_wh_ea_read(uint8_t *data, uint16_t length, uint8_t *eui64);
4749

0 commit comments

Comments
 (0)