Skip to content

Commit df2b98e

Browse files
author
Jarkko Paso
authored
Merge pull request ARMmbed#1979 from ARMmbed/IOTTHD-3233
Iotthd 3233
2 parents 2b356e0 + f2ba36d commit df2b98e

File tree

7 files changed

+45
-7
lines changed

7 files changed

+45
-7
lines changed

source/6LoWPAN/ws/ws_neighbor_class.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ uint8_t ws_neighbor_class_rssi_from_dbm_calculate(int8_t dbm_heard)
138138
{
139139
if (DEVICE_MIN_SENS > dbm_heard) {
140140
// We are hearing packet with lower than min_sens dynamically learn the sensitivity
141-
tr_info("heard packet below min sensitivity");
142141
DEVICE_MIN_SENS = dbm_heard;
143142
}
144143
return dbm_heard - DEVICE_MIN_SENS;

source/MAC/IEEE802_15_4/mac_mcps_sap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ int8_t mcps_generic_ack_build(protocol_interface_rf_mac_setup_s *rf_ptr, const m
17401740
rf_ptr->dev_driver->phy_driver->extension(PHY_EXTENSION_SET_CSMA_PARAMETERS, (uint8_t *) &csma_params);
17411741
if (rf_ptr->active_pd_data_request) {
17421742
timer_mac_stop(rf_ptr);
1743-
mac_pd_sap_set_phy_tx_time(rf_ptr, 0, false);
1743+
mac_pd_abort_active_tx(rf_ptr);
17441744
}
17451745
return mcps_pd_data_cca_trig(rf_ptr, buffer);
17461746
}

source/MAC/IEEE802_15_4/mac_mlme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ static int8_t mac_mlme_8bit_set(protocol_interface_rf_mac_setup_s *rf_mac_setup,
582582
break;
583583

584584
case macMinBE:
585-
if (value > rf_mac_setup->macMaxBE) {
585+
if (value < rf_mac_setup->macMaxBE) {
586586
rf_mac_setup->macMinBE = value;
587587
}
588588
break;

source/MAC/IEEE802_15_4/mac_pd_sap.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,20 @@ int8_t mac_pd_sap_req(protocol_interface_rf_mac_setup_s *rf_mac_setup)
199199
}
200200

201201

202+
/**
203+
* Abort active PHY transmission.
204+
*
205+
* \param rf_mac_setup pointer to MAC.
206+
*
207+
*/
208+
void mac_pd_abort_active_tx(protocol_interface_rf_mac_setup_s *rf_mac_setup)
209+
{
210+
phy_csma_params_t csma_params;
211+
// Set TX time to 0 to abort current transmission
212+
csma_params.backoff_time = 0;
213+
rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_SET_CSMA_PARAMETERS, (uint8_t *) &csma_params);
214+
}
215+
202216
/**
203217
* Set PHY TX time.
204218
*

source/MAC/IEEE802_15_4/mac_pd_sap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ int8_t mac_pd_sap_req(struct protocol_interface_rf_mac_setup *rf_mac_setup);
3939

4040
int8_t mac_plme_cca_req(struct protocol_interface_rf_mac_setup *rf_mac_setup);
4141

42+
void mac_pd_abort_active_tx(struct protocol_interface_rf_mac_setup *rf_mac_setup);
43+
4244
void mac_pd_sap_set_phy_tx_time(struct protocol_interface_rf_mac_setup *rf_mac_setup, uint32_t tx_time, bool cca_enabled);
4345

4446
void mac_pd_sap_rf_low_level_function_set(void *mac_ptr, void *driver);

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ static int32_t fhss_ws_calc_bc_channel(fhss_structure_t *fhss_structure)
202202
return next_channel;
203203
}
204204

205+
static uint8_t calc_own_tx_trig_slot(uint8_t own_hop)
206+
{
207+
if (own_hop == 0xff) {
208+
return 0;
209+
}
210+
if (own_hop & 1) {
211+
own_hop--;
212+
}
213+
own_hop /= 2;
214+
return (own_hop & 1);
215+
}
216+
205217
static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
206218
{
207219
int32_t next_channel;
@@ -236,13 +248,20 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
236248
// Should return to own (unicast) listening channel after broadcast channel
237249
next_channel = fhss_structure->rx_channel;
238250
/* Start timer with random timeout to trigger unicast TX queue poll event.
239-
* Min random is 1/30 of the TX slot length.
251+
* For hops 0,1,4,5,8,9,...
252+
* Min random is 1/100 of the TX slot length.
240253
* Max random is 1/10 of the TX slot length.
254+
*
255+
* For hops 2,3,6,7,10,11,...
256+
* Min random is 1/100 of the TX slot length plus 0.5*TX slot length.
257+
* Max random is 1/10 of the TX slot length plus 0.5*TX slot length.
241258
* Event timer resolution is 50us.
242259
*/
260+
// returns 1 if polling of TX queue is done on latter half of the TX slot
261+
uint8_t own_tx_trig_slot = calc_own_tx_trig_slot(fhss_structure->own_hop);
243262
uint32_t txrx_slot_length_us = MS_TO_US(fhss_structure->ws->txrx_slot_length_ms);
244-
uint16_t uc_min_random = (txrx_slot_length_us / 30) / 50;
245-
uint16_t uc_max_random = (txrx_slot_length_us / 10) / 50;
263+
uint16_t uc_min_random = (((txrx_slot_length_us / 2) * own_tx_trig_slot) / 50) + ((txrx_slot_length_us / 100) / 50);
264+
uint16_t uc_max_random = (((txrx_slot_length_us / 2) * own_tx_trig_slot) / 50) + ((txrx_slot_length_us / 10) / 50);
246265
bool tx_allowed = fhss_ws_check_tx_allowed(fhss_structure);
247266
if (!tx_allowed) {
248267
uc_min_random += (txrx_slot_length_us) / 50;

test/nanostack/unittest/stub/mac_pd_sap_stub.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ void mac_pd_sap_rf_low_level_function_set(void *mac_ptr, void *driver)
5353
{
5454
}
5555

56+
void mac_pd_abort_active_tx(protocol_interface_rf_mac_setup_s *rf_mac_setup)
57+
{
58+
59+
}
60+
5661
void mac_pd_sap_set_phy_tx_time(struct protocol_interface_rf_mac_setup *rf_mac_setup, uint32_t tx_time, bool cca_enabled)
5762
{
5863

@@ -77,4 +82,3 @@ void mac_csma_backoff_start(protocol_interface_rf_mac_setup_s *rf_mac_setup)
7782
{
7883

7984
}
80-

0 commit comments

Comments
 (0)