| 35 | === MAC High Framework === |
| 36 | |
| 37 | Changes should be made to {{{wlan_mac_high.c}}} in the project SDK workspace zip. |
| 38 | |
| 39 | ---- |
| 40 | |
| 41 | We should create two functions to enable and disable the frequency hopping behavior for our AP and STA applications to call. These function will use the new IPC message we just created. Add the following functions to the MAC High Framework: |
| 42 | |
| 43 | {{{ |
| 44 | #!c |
| 45 | |
| 46 | void wlan_mac_high_enable_hopping(){ |
| 47 | |
| 48 | wlan_ipc_msg ipc_msg_to_low; |
| 49 | u32 ipc_msg_to_low_payload = 1; |
| 50 | |
| 51 | // Send message to CPU Low |
| 52 | ipc_msg_to_low.msg_id = IPC_MBOX_MSG_ID(IPC_MBOX_CONFIG_HOPPING); |
| 53 | ipc_msg_to_low.num_payload_words = 1; |
| 54 | ipc_msg_to_low.payload_ptr = &(ipc_msg_to_low_payload); |
| 55 | |
| 56 | ipc_mailbox_write_msg(&ipc_msg_to_low); |
| 57 | |
| 58 | } |
| 59 | |
| 60 | void wlan_mac_high_disable_hopping(){ |
| 61 | |
| 62 | wlan_ipc_msg ipc_msg_to_low; |
| 63 | u32 ipc_msg_to_low_payload = 0; |
| 64 | |
| 65 | // Send message to CPU Low |
| 66 | ipc_msg_to_low.msg_id = IPC_MBOX_MSG_ID(IPC_MBOX_CONFIG_HOPPING); |
| 67 | ipc_msg_to_low.num_payload_words = 1; |
| 68 | ipc_msg_to_low.payload_ptr = &(ipc_msg_to_low_payload); |
| 69 | |
| 70 | ipc_mailbox_write_msg(&ipc_msg_to_low); |
| 71 | |
| 72 | } |
| 73 | |
| 74 | }}} |
| 75 | |
| 76 | === Access Point (AP) === |
| 77 | |
| 78 | Changes should be made to {{{wlan_mac_ap.c}}} in the project SDK workspace zip. |
| 79 | |
| 80 | ---- |
| 81 | |
| 82 | We can make our changes such that it is easy to toggle between the slow Wi-Fi-compliant approach to frequency hopping or our custom fast hopping approach by defining a new value for the {{{HOP_MODE}}} variable we already created. For clarity, add the following comment above the {{{HOP_MODE}}} global variable definition. |
| 83 | |
| 84 | {{{ |
| 85 | #!c |
| 86 | |
| 87 | // 0 - No hop |
| 88 | // 1 - Slow hop |
| 89 | // 2 - Fast hop |
| 90 | u8 HOP_MODE; |
| 91 | |
| 92 | }}} |
| 93 | |
| 94 | ---- |
| 95 | |
| 96 | In the {{{main()}}} function of the AP, we had previously set {{{HOP_MODE}}} to a value of {{{0}}} and then let the push button callback set the variable to {{{1}}} after the Wi-Fi stations had associated. For the fast approach, we can boot the AP directly into a configuration where fast frequency hopping is enabled. Change the assignment of {{{HOP_MODE}}} in {{{main()}}} to the following: |
| 97 | |
| 98 | {{{ |
| 99 | #!c |
| 100 | |
| 101 | HOP_MODE = 2; |
| 102 | |
| 103 | }}} |
| 104 | |
| 105 | Finally, just before the primary {{{while(1)}}} loop, add the following code snippet: |
| 106 | |
| 107 | {{{ |
| 108 | #!c |
| 109 | |
| 110 | if(HOP_MODE == 2){ |
| 111 | wlan_mac_high_enable_hopping(); |
| 112 | } else { |
| 113 | wlan_mac_high_disable_hopping(); |
| 114 | } |
| 115 | |
| 116 | }}} |
| 117 | |
| 118 | |
| 119 | |