Skip to content

Commit 4802aae

Browse files
author
Jarkko Paso
authored
Merge pull request ARMmbed#1930 from ARMmbed/IOTTHD-3027
Iotthd 3027
2 parents 2b8c846 + cff6f0b commit 4802aae

File tree

10 files changed

+129
-34
lines changed

10 files changed

+129
-34
lines changed

nanostack/mlme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ typedef enum {
264264
macAutoRequestKeyIndex = 0x7b, /*<The index of the key used for automatic data*/
265265
macDefaultKeySource = 0x7c, /*<Default key source*/
266266
//NON standard extension
267+
macRfConfiguration = 0xfb, /*<RF channel configuration parameters*/
267268
macAcceptByPassUnknowDevice = 0xfc, /*< Accept data trough MAC if packet is data can be authenticated by group key nad MIC. Security enforsment point must be handled carefully these packets */
268269
macLoadBalancingBeaconTx = 0xfd, /*< Trig Beacon from load balance module periodic */
269270
macLoadBalancingAcceptAnyBeacon = 0xfe, /*<Beacon accept state control from other network. Value size bool, data true=Enable, false=disable .*/

nanostack/platform/arm_hal_phy.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ typedef enum {
6464
PHY_EXTENSION_GET_TIMESTAMP, /**< Read 32-bit constant monotonic time stamp in us */
6565
PHY_EXTENSION_SET_CSMA_PARAMETERS, /**< CSMA parameter's are given by phy_csma_params_t structure remember type cast uint8_t pointer to structure type*/
6666
PHY_EXTENSION_GET_SYMBOLS_PER_SECOND, /**< Read Symbols per seconds which will help to convert symbol time to real time */
67+
PHY_EXTENSION_SET_RF_CONFIGURATION /**< Set RF configuration using phy_rf_channel_parameters_s structure */
6768
} phy_extension_type_e;
6869

6970
/** Address types */
@@ -130,6 +131,7 @@ typedef enum phy_modulation_e {
130131
M_OQPSK, ///< OQPSK
131132
M_BPSK, ///< BPSK
132133
M_GFSK, ///< GFSK
134+
M_2FSK, ///< 2FSK
133135
M_UNDEFINED ///< UNDEFINED
134136
} phy_modulation_e;
135137

@@ -146,13 +148,21 @@ typedef enum {
146148
CHANNEL_PAGE_10 = 10 ///< Page 10
147149
} channel_page_e;
148150

151+
/** Modulation index */
152+
typedef enum {
153+
MODULATION_INDEX_0_5 = 0, ///< Modulation index 0.5
154+
MODULATION_INDEX_1_0 = 1, ///< Modulation index 1.0
155+
MODULATION_INDEX_UNDEFINED ///< Modulation index undefined
156+
} phy_modulation_index_e;
157+
149158
/** Channel configuration */
150159
typedef struct phy_rf_channel_configuration_s {
151-
uint32_t channel_0_center_frequency; ///< Center frequency
152-
uint32_t channel_spacing; ///< Channel spacing
153-
uint32_t datarate; ///< Data rate
154-
uint16_t number_of_channels; ///< Number of channels
155-
phy_modulation_e modulation; ///< Modulation scheme
160+
uint32_t channel_0_center_frequency; ///< Center frequency
161+
uint32_t channel_spacing; ///< Channel spacing
162+
uint32_t datarate; ///< Data rate
163+
uint16_t number_of_channels; ///< Number of channels
164+
phy_modulation_e modulation; ///< Modulation scheme
165+
phy_modulation_index_e modulation_index; ///< Modulation index
156166
} phy_rf_channel_configuration_s;
157167

158168
/** Channel page configuration */

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,23 @@ int ws_bootstrap_restart(int8_t interface_id)
15231523
return 0;
15241524
}
15251525

1526+
int ws_bootstrap_set_rf_config(protocol_interface_info_entry_t *cur, phy_rf_channel_configuration_s rf_configs)
1527+
{
1528+
mlme_set_t set_request;
1529+
// Set RF configuration
1530+
set_request.attr = macRfConfiguration;
1531+
set_request.value_pointer = &rf_configs;
1532+
set_request.value_size = sizeof(phy_rf_channel_configuration_s);
1533+
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_request);
1534+
// Set Ack wait duration
1535+
uint16_t ack_wait_symbols = WS_ACK_WAIT_SYMBOLS + (WS_TACK_MAX_MS * (rf_configs.datarate / 1000));
1536+
set_request.attr = macAckWaitDuration;
1537+
set_request.value_pointer = &ack_wait_symbols;
1538+
set_request.value_size = sizeof(ack_wait_symbols);
1539+
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_request);
1540+
return 0;
1541+
}
1542+
15261543
int ws_bootstrap_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
15271544
{
15281545
tr_warn("ARO registration Failure %s", trace_ipv6(ll_address));

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur);
3737

3838
int ws_bootstrap_restart(int8_t interface_id);
3939

40+
int ws_bootstrap_set_rf_config(protocol_interface_info_entry_t *cur, phy_rf_channel_configuration_s rf_configs);
41+
4042
int ws_bootstrap_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8_t *ll_address);
4143

4244
/*State machine transactions*/

source/6LoWPAN/ws/ws_common.c

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,60 @@ int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_chann
7575
return 0;
7676
}
7777

78+
static uint32_t ws_decode_channel_spacing(uint8_t channel_spacing)
79+
{
80+
if (CHANNEL_SPACING_100 == channel_spacing) {
81+
return 100000;
82+
} else if (CHANNEL_SPACING_200 == channel_spacing) {
83+
return 200000;
84+
} else if (CHANNEL_SPACING_250 == channel_spacing) {
85+
return 250000;
86+
} else if (CHANNEL_SPACING_400 == channel_spacing) {
87+
return 400000;
88+
} else if (CHANNEL_SPACING_600 == channel_spacing) {
89+
return 600000;
90+
}
91+
return 0;
92+
}
93+
94+
static uint32_t ws_get_datarate_using_operating_mode(uint8_t operating_mode)
95+
{
96+
if ((OPERATING_MODE_1a == operating_mode) || (OPERATING_MODE_1b == operating_mode)) {
97+
return 50000;
98+
} else if ((OPERATING_MODE_2a == operating_mode) || (OPERATING_MODE_2b == operating_mode)) {
99+
return 100000;
100+
} else if (OPERATING_MODE_3 == operating_mode) {
101+
return 150000;
102+
} else if ((OPERATING_MODE_4a == operating_mode) || (OPERATING_MODE_4b == operating_mode)) {
103+
return 200000;
104+
} else if (OPERATING_MODE_5 == operating_mode) {
105+
return 300000;
106+
}
107+
return 0;
108+
}
109+
110+
static phy_modulation_index_e ws_get_modulation_index_using_operating_mode(uint8_t operating_mode)
111+
{
112+
if ((OPERATING_MODE_1b == operating_mode) || (OPERATING_MODE_2b == operating_mode) || (OPERATING_MODE_4b == operating_mode)) {
113+
return MODULATION_INDEX_1_0;
114+
} else {
115+
return MODULATION_INDEX_0_5;
116+
}
117+
}
118+
119+
static int ws_set_domain_rf_config(protocol_interface_info_entry_t *cur)
120+
{
121+
phy_rf_channel_configuration_s rf_configs;
122+
rf_configs.channel_0_center_frequency = (uint32_t)cur->ws_info->hopping_schdule.ch0_freq * 100000;
123+
rf_configs.channel_spacing = ws_decode_channel_spacing(cur->ws_info->hopping_schdule.channel_spacing);
124+
rf_configs.datarate = ws_get_datarate_using_operating_mode(cur->ws_info->hopping_schdule.operating_mode);
125+
rf_configs.modulation_index = ws_get_modulation_index_using_operating_mode(cur->ws_info->hopping_schdule.operating_mode);
126+
rf_configs.modulation = M_2FSK;
127+
rf_configs.number_of_channels = cur->ws_info->hopping_schdule.number_of_channels;
128+
ws_bootstrap_set_rf_config(cur, rf_configs);
129+
return 0;
130+
}
131+
78132
int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur)
79133
{
80134
cur->ws_info->hopping_schdule.channel_plan = 0;
@@ -103,11 +157,11 @@ int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur)
103157
} else if (cur->ws_info->hopping_schdule.operating_class == 3) {
104158
cur->ws_info->hopping_schdule.ch0_freq = 8701;
105159
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_100;
106-
cur->ws_info->hopping_schdule.number_of_channels = 59;
160+
cur->ws_info->hopping_schdule.number_of_channels = 55;
107161
} else if (cur->ws_info->hopping_schdule.operating_class == 4) {
108-
cur->ws_info->hopping_schdule.ch0_freq = 8701;
162+
cur->ws_info->hopping_schdule.ch0_freq = 8702;
109163
cur->ws_info->hopping_schdule.channel_spacing = CHANNEL_SPACING_200;
110-
cur->ws_info->hopping_schdule.number_of_channels = 30;
164+
cur->ws_info->hopping_schdule.number_of_channels = 27;
111165
} else {
112166
return -1;
113167
}
@@ -160,13 +214,7 @@ int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur)
160214
}
161215
// Note: doesn't work for Brazil region
162216
ws_generate_channel_list(cur->ws_info->hopping_schdule.channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
163-
164-
uint16_t ack_wait_symbols = WS_ACK_WAIT_SYMBOLS;
165-
mlme_set_t set_request;
166-
set_request.attr = macAckWaitDuration;
167-
set_request.value_pointer = &ack_wait_symbols;
168-
set_request.value_size = sizeof(ack_wait_symbols);
169-
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_request);
217+
ws_set_domain_rf_config(cur);
170218
return 0;
171219
}
172220

@@ -188,9 +236,9 @@ int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur)
188236
cur->ws_info->pan_information.rpl_routing_method = true;
189237
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_0;
190238

191-
cur->ws_info->hopping_schdule.regulatory_domain = REG_DOMAIN_KR;
192-
cur->ws_info->hopping_schdule.operating_mode = OPERATING_MODE_1a;
193-
cur->ws_info->hopping_schdule.operating_class = 1;
239+
cur->ws_info->hopping_schdule.regulatory_domain = REG_DOMAIN_EU;
240+
cur->ws_info->hopping_schdule.operating_mode = OPERATING_MODE_3;
241+
cur->ws_info->hopping_schdule.operating_class = 2;
194242
ws_common_regulatory_domain_config(cur);
195243
ws_common_network_size_configure(cur, 10); // defaults to small network size
196244

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ typedef struct ws_bs_ie {
220220
*/
221221
#define WS_ACK_WAIT_SYMBOLS 800
222222

223+
/*
224+
* Tack max time in milliseconds.
225+
*/
226+
#define WS_TACK_MAX_MS 5
227+
223228
/* Default FHSS timing information
224229
*
225230
*/

source/MAC/IEEE802_15_4/mac_mlme.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static int8_t mac_mlme_rf_channel_set(struct protocol_interface_rf_mac_setup *rf
6868
static void mac_mlme_timer_cb(int8_t timer_id, uint16_t slots);
6969
static void mac_mlme_start_confirm_handler(protocol_interface_rf_mac_setup_s *rf_ptr, const mlme_start_conf_t *conf);
7070
static void mac_mlme_scan_confirm_handler(protocol_interface_rf_mac_setup_s *rf_ptr, const mlme_scan_conf_t *conf);
71+
static int mac_mlme_set_symbol_rate(protocol_interface_rf_mac_setup_s *rf_mac_setup);
7172

7273
static void mac_mlme_energy_scan_start(protocol_interface_rf_mac_setup_s *rf_mac_setup, uint8_t channel)
7374
{
@@ -748,6 +749,10 @@ int8_t mac_mlme_set_req(protocol_interface_rf_mac_setup_s *rf_mac_setup, const m
748749
memcpy(rf_mac_setup->coord_long_address, set_req->value_pointer, 8);
749750
}
750751
return 0;
752+
case macRfConfiguration:
753+
rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_SET_RF_CONFIGURATION, (uint8_t *) set_req->value_pointer);
754+
mac_mlme_set_symbol_rate(rf_mac_setup);
755+
return 0;
751756
default:
752757
return mac_mlme_handle_set_values(rf_mac_setup, set_req);
753758
}
@@ -1034,6 +1039,17 @@ static uint8_t mac_backoff_ticks_calc(phy_device_driver_s *phy_driver)
10341039
return (uint8_t) ticks;
10351040
}
10361041

1042+
static int mac_mlme_set_symbol_rate(protocol_interface_rf_mac_setup_s *rf_mac_setup)
1043+
{
1044+
if (rf_mac_setup->rf_csma_extension_supported) {
1045+
rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_GET_SYMBOLS_PER_SECOND, (uint8_t *) &rf_mac_setup->symbol_rate);
1046+
rf_mac_setup->symbol_time_us = 1000000 / rf_mac_setup->symbol_rate;
1047+
tr_debug("SW-MAC driver support rf extension %"PRIu32" symbol/seconds %"PRIu32" us symbol time length", rf_mac_setup->symbol_rate, rf_mac_setup->symbol_time_us);
1048+
return 0;
1049+
}
1050+
return -1;
1051+
}
1052+
10371053
protocol_interface_rf_mac_setup_s *mac_mlme_data_base_allocate(uint8_t *mac64, arm_device_driver_list_s *dev_driver, mac_description_storage_size_t *storage_sizes)
10381054
{
10391055
uint16_t total_length = 0;
@@ -1124,11 +1140,7 @@ protocol_interface_rf_mac_setup_s *mac_mlme_data_base_allocate(uint8_t *mac64, a
11241140
bool rf_support = false;
11251141
dev_driver->phy_driver->extension(PHY_EXTENSION_DYNAMIC_RF_SUPPORTED, (uint8_t *)&rf_support);
11261142
entry->rf_csma_extension_supported = rf_support;
1127-
if (entry->rf_csma_extension_supported) {
1128-
entry->dev_driver->phy_driver->extension(PHY_EXTENSION_GET_SYMBOLS_PER_SECOND, (uint8_t *) &entry->symbol_rate);
1129-
entry->symbol_time_us = 1000000 / entry->symbol_rate;
1130-
tr_debug("SW-MAC driver support rf extension %"PRIu32" symbol/seconds %"PRIu32" us symbol time length", entry->symbol_rate, entry->symbol_time_us);
1131-
}
1143+
mac_mlme_set_symbol_rate(entry);
11321144

11331145
//How many 10us ticks backoff period is for waiting 20symbols which is typically 10 bytes time
11341146
entry->backoff_period_in_10us = mac_backoff_ticks_calc(dev_driver->phy_driver);

source/MAC/virtual_rf/virtual_rf_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
static phy_device_driver_s device_driver;
3333
static int8_t rf_driver_id = (-1);
34-
static const phy_rf_channel_configuration_s phy_2_4ghz = {2405000000, 5000000, 250000, 16, M_OQPSK};
34+
static const phy_rf_channel_configuration_s phy_2_4ghz = {.channel_0_center_frequency = 2405000000, .channel_spacing = 5000000, .datarate = 250000, .number_of_channels = 16, .modulation = M_OQPSK};
3535
static const phy_device_channel_page_s phy_channel_pages = { CHANNEL_PAGE_0, &phy_2_4ghz};
3636

3737
static int8_t phy_rf_rx(const uint8_t *data_ptr, uint16_t data_len, uint8_t link_quality, int8_t dbm, int8_t driver_id)

source/MAC/virtual_rf/virtual_rf_driver.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ static int8_t rf_driver_id = (-1);
3838
static bool data_request_pending_flag = false;
3939

4040
/** XXX: dummy values copied from Atmel RF driver */
41-
static const phy_rf_channel_configuration_s phy_2_4ghz = {2405000000, 5000000, 250000, 16, M_OQPSK};
42-
static const phy_rf_channel_configuration_s phy_subghz = {868300000, 2000000, 250000, 11, M_OQPSK};
43-
44-
static const phy_rf_channel_configuration_s phy_subghz_8_ch = {868300000, 2000000, 250000, 8, M_OQPSK};
45-
static const phy_rf_channel_configuration_s phy_subghz_11_ch = {868300000, 2000000, 250000, 11, M_OQPSK};
46-
static const phy_rf_channel_configuration_s phy_subghz_16_ch = {868300000, 2000000, 250000, 16, M_OQPSK};
47-
static const phy_rf_channel_configuration_s phy_2_4ghz_14_ch = {2405000000, 1000000, 250000, 14, M_OQPSK};
48-
static const phy_rf_channel_configuration_s phy_2_4ghz_5_ch = {2405000000, 1000000, 250000, 5, M_OQPSK}; //For FHSS testing only
49-
static const phy_rf_channel_configuration_s phy_2_4ghz_256_ch = {2405000000, 1000000, 250000, 256, M_OQPSK}; //For FHSS testing only
41+
static const phy_rf_channel_configuration_s phy_2_4ghz = {.channel_0_center_frequency = 2405000000, .channel_spacing = 5000000, .datarate = 250000, .number_of_channels = 16, .modulation = M_OQPSK};
42+
static const phy_rf_channel_configuration_s phy_subghz = {.channel_0_center_frequency = 868300000, .channel_spacing = 2000000, .datarate = 250000, .number_of_channels = 11, .modulation = M_OQPSK};
43+
44+
static const phy_rf_channel_configuration_s phy_subghz_8_ch = {.channel_0_center_frequency = 868300000, .channel_spacing = 2000000, .datarate = 250000, .number_of_channels = 8, .modulation = M_OQPSK};
45+
static const phy_rf_channel_configuration_s phy_subghz_11_ch = {.channel_0_center_frequency = 868300000, .channel_spacing = 2000000, .datarate = 250000, .number_of_channels = 11, .modulation = M_OQPSK};
46+
static const phy_rf_channel_configuration_s phy_subghz_16_ch = {.channel_0_center_frequency = 868300000, .channel_spacing = 2000000, .datarate = 250000, .number_of_channels = 16, .modulation = M_OQPSK};
47+
static const phy_rf_channel_configuration_s phy_2_4ghz_14_ch = {.channel_0_center_frequency = 2405000000, .channel_spacing = 1000000, .datarate = 250000, .number_of_channels = 14, .modulation = M_OQPSK};
48+
static const phy_rf_channel_configuration_s phy_2_4ghz_5_ch = {.channel_0_center_frequency = 2405000000, .channel_spacing = 1000000, .datarate = 250000, .number_of_channels = 5, .modulation = M_OQPSK}; //For FHSS testing only
49+
static const phy_rf_channel_configuration_s phy_2_4ghz_256_ch = {.channel_0_center_frequency = 2405000000, .channel_spacing = 1000000, .datarate = 250000, .number_of_channels = 256, .modulation = M_OQPSK}; //For FHSS testing only
5050

5151
static phy_device_channel_page_s phy_channel_pages[] = {
5252
{CHANNEL_PAGE_0, &phy_2_4ghz}, // this will be modified to contain 11 or 16 channels, depending on radio type

test/nanostack/unittest/mac/mac_mlme/test_mac_mlme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ bool test_mac_mlme_set_req()
569569
uint8_t val[1];
570570
set.value_pointer = &val;
571571

572-
set.attr = 0xfb;
572+
set.attr = 0xf0;
573573
set.value_size = 0;
574574
if (-1 != mac_mlme_set_req(&setup, &set)) {
575575
return false;

0 commit comments

Comments
 (0)