| 192 | === DCF === |
| 193 | |
| 194 | Changes should be made to {{{wlan_mac_dcf.c}}} in the project SDK workspace zip. |
| 195 | |
| 196 | ---- |
| 197 | |
| 198 | We need to define the sequence of channels that a node should traverse through over time. Here, we have created a vector of length 1024 where each element is a valid 2.4 GHz Wi-Fi channel chosen pseudorandomly from a uniform distribution over the range of [1, 11]. Add this variable definition to the top of the DCF code: |
| 199 | |
| 200 | {{{ |
| 201 | #!c |
| 202 | |
| 203 | #define HOP_SEQ_LEN 1024 |
| 204 | u8 hop_vec[HOP_SEQ_LEN] = { 2, 10, 9, 6, 1, 3, 11, 8, 3, 8, 2, 7, 9, 5, 1, 7, 8, 2, 10, 6, |
| 205 | 4, 4, 8, 6, 5, 4, 7, 1, 7, 11, 6, 4, 9, 2, 1, 5, 6, 9, 8, 6, |
| 206 | 3, 2, 5, 5, 11, 11, 4, 10, 7, 6, 10, 9, 6, 1, 5, 5, 7, 2, 7, 5, |
| 207 | 1, 2, 5, 6, 4, 10, 7, 3, 2, 9, 8, 4, 1, 5, 6, 6, 10, 11, 5, 3, |
| 208 | 11, 8, 11, 8, 8, 5, 1, 7, 9, 8, 1, 2, 9, 6, 5, 4, 3, 11, 5, 2, |
| 209 | 6, 1, 7, 5, 9, 2, 6, 7, 1, 6, 9, 2, 8, 10, 6, 1, 4, 11, 2, 9, |
| 210 | 4, 4, 6, 5, 11, 4, 2, 3, 2, 9, 7, 8, 8, 7, 4, 2, 10, 4, 7, 6, |
| 211 | 8, 3, 4, 8, 11, 4, 10, 10, 10, 9, 3, 11, 10, 10, 9, 6, 10, 11, 1, 9, |
| 212 | 6, 7, 11, 10, 11, 4, 4, 4, 4, 7, 4, 11, 8, 9, 3, 2, 1, 7, 7, 5, |
| 213 | 1, 2, 6, 9, 9, 11, 9, 5, 4, 2, 7, 3, 2, 9, 6, 8, 2, 5, 7, 10, |
| 214 | 11, 4, 5, 2, 8, 3, 10, 5, 5, 2, 1, 9, 9, 6, 10, 7, 2, 1, 2, 4, |
| 215 | 9, 9, 2, 9, 2, 8, 1, 5, 9, 6, 11, 4, 7, 3, 5, 11, 4, 10, 8, 1, |
| 216 | 6, 8, 5, 2, 7, 11, 11, 11, 10, 8, 10, 10, 9, 2, 1, 6, 2, 5, 4, 5, |
| 217 | 11, 10, 11, 3, 1, 10, 8, 7, 3, 6, 1, 5, 3, 4, 11, 10, 3, 5, 9, 9, |
| 218 | 1, 3, 1, 8, 10, 4, 8, 2, 5, 10, 8, 8, 10, 4, 8, 4, 11, 9, 10, 9, |
| 219 | 9, 5, 2, 2, 9, 1, 6, 10, 11, 6, 1, 6, 3, 4, 11, 2, 9, 4, 6, 2, |
| 220 | 1, 10, 1, 10, 5, 5, 4, 1, 8, 4, 8, 9, 8, 6, 9, 1, 1, 5, 2, 9, |
| 221 | 1, 2, 5, 3, 11, 5, 6, 3, 7, 6, 11, 8, 10, 1, 5, 1, 7, 9, 8, 1, |
| 222 | 8, 4, 4, 8, 2, 3, 5, 7, 4, 5, 4, 11, 8, 2, 8, 1, 9, 1, 5, 8, |
| 223 | 1, 5, 2, 7, 3, 5, 10, 1, 8, 4, 10, 4, 5, 11, 10, 10, 11, 2, 4, 8, |
| 224 | 7, 10, 3, 4, 3, 1, 8, 4, 1, 4, 2, 1, 7, 1, 10, 1, 6, 2, 5, 10, |
| 225 | 8, 11, 5, 5, 9, 10, 8, 2, 4, 3, 3, 8, 4, 11, 10, 7, 10, 4, 7, 7, |
| 226 | 4, 7, 2, 9, 10, 8, 1, 11, 1, 3, 5, 5, 2, 11, 2, 9, 8, 4, 2, 11, |
| 227 | 10, 2, 5, 6, 9, 10, 11, 8, 7, 10, 5, 10, 9, 10, 5, 1, 10, 7, 9, 7, |
| 228 | 11, 2, 8, 2, 1, 7, 7, 9, 1, 1, 7, 9, 3, 6, 7, 7, 1, 3, 2, 6, |
| 229 | 9, 11, 1, 10, 10, 6, 5, 1, 2, 8, 7, 8, 5, 9, 6, 10, 1, 7, 9, 4, |
| 230 | 6, 10, 6, 9, 7, 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, 11, 9, 7, 9, 7, 1, 6, 10, |
| 246 | 5, 3, 6, 5, 9, 9, 4, 11, 4, 3, 2, 4, 11, 8, 3, 4, 4, 10, 6, 7, |
| 247 | 9, 4, 3, 10, 1, 1, 4, 10, 6, 4, 6, 8, 7, 10, 1, 3, 8, 5, 4, 1, |
| 248 | 4, 5, 7, 3, 10, 10, 11, 7, 4, 9, 6, 7, 8, 1, 8, 4, 3, 4, 4, 3, |
| 249 | 2, 8, 4, 3, 7, 1, 10, 1, 3, 4, 8, 7, 8, 4, 11, 4, 6, 2, 10, 3, |
| 250 | 1, 5, 11, 3, 4, 6, 7, 5, 8, 2, 1, 1, 7, 10, 7, 6, 8, 5, 3, 7, |
| 251 | 7, 9, 3, 4, 1, 4, 4, 8, 7, 9, 10, 10, 1, 6, 1, 9, 4, 3, 3, 2, |
| 252 | 3, 10, 9, 9, 3, 2, 1, 4, 8, 7, 7, 3, 5, 4, 10, 9, 10, 5, 9, 1, |
| 253 | 11, 8, 3, 9, 6, 10, 4, 7, 3, 2, 3, 5, 8, 1, 8, 3, 10, 7, 6, 2, |
| 254 | 3, 5, 11, 6, 2, 11, 6, 10, 4, 9, 1, 3, 9, 8, 10, 7, 6, 9, 10, 10, |
| 255 | 10, 8, 5, 1}; |
| 256 | |
| 257 | }}} |
| 258 | |
| 259 | ---- |
| 260 | |
| 261 | Next, we should create a top-level global variable that represents whether or not the frequency hopping mechanism is currently enabled. Add the following new global variable to the DCF code: |
| 262 | |
| 263 | {{{ |
| 264 | #!c |
| 265 | |
| 266 | static u8 enable_hop; |
| 267 | |
| 268 | }}} |
| 269 | |
| 270 | Next, we'll create setter functions that control this variable. Add the following functions to the DCF code: |
| 271 | |
| 272 | {{{ |
| 273 | #!c |
| 274 | |
| 275 | void enable_hopping(){ |
| 276 | enable_hop = 1; |
| 277 | } |
| 278 | |
| 279 | void disable_hopping(){ |
| 280 | enable_hop = 0; |
| 281 | } |
| 282 | |
| 283 | }}} |
| 284 | |
| 285 | We will now attach these new functions to the callbacks we just created in the MAC Low Framework. We will also explicitly call the {{{disable_hopping()}}} function at boot and wait for a CPU_HIGH project to explicitly tell us when we should enable the frequency hopping behavior. Add the following lines to the initialize code in {{{main()}}}: |
| 286 | |
| 287 | {{{ |
| 288 | #!c |
| 289 | disable_hopping(); |
| 290 | wlan_mac_low_set_enable_hopping_callback((void*)enable_hopping); |
| 291 | wlan_mac_low_set_disable_hopping_callback((void*)disable_hopping); |
| 292 | |
| 293 | }}} |
| 294 | |
| 295 | == Characterizing the Design == |
| 296 | |