![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
BLE fota Robot Demo
Dependencies: mbed-rtos mbed mbed_fota_fan_control
Fork of mbed_fota_lamp_control by
dialog_fota/gapc_task.h@5:e11b23f9aacc, 2015-07-13 (annotated)
- Committer:
- dudnwjs
- Date:
- Mon Jul 13 06:32:05 2015 +0000
- Revision:
- 5:e11b23f9aacc
- Parent:
- 4:60be78a172c2
- Child:
- 9:fcf91f563147
Fota Service Add complete
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudnwjs | 4:60be78a172c2 | 1 | #ifndef GAPC_TASK_H |
dudnwjs | 4:60be78a172c2 | 2 | #define GAPC_TASK_H |
dudnwjs | 4:60be78a172c2 | 3 | |
dudnwjs | 4:60be78a172c2 | 4 | #include "dialog_fota_config.h" |
dudnwjs | 5:e11b23f9aacc | 5 | #include "gap.h" |
dudnwjs | 4:60be78a172c2 | 6 | |
dudnwjs | 4:60be78a172c2 | 7 | namespace sevencore_fota{ |
dudnwjs | 4:60be78a172c2 | 8 | /// GAP Controller Task messages |
dudnwjs | 4:60be78a172c2 | 9 | enum gapc_msg_id |
dudnwjs | 4:60be78a172c2 | 10 | { |
dudnwjs | 4:60be78a172c2 | 11 | /* Default event */ |
dudnwjs | 4:60be78a172c2 | 12 | /// Command Complete event |
dudnwjs | 4:60be78a172c2 | 13 | GAPC_CMP_EVT = 14336, |
dudnwjs | 4:60be78a172c2 | 14 | |
dudnwjs | 4:60be78a172c2 | 15 | /* Connection state information */ |
dudnwjs | 4:60be78a172c2 | 16 | /// Indicate that a connection has been established |
dudnwjs | 4:60be78a172c2 | 17 | GAPC_CONNECTION_REQ_IND, |
dudnwjs | 4:60be78a172c2 | 18 | /// Set specific link data configuration. |
dudnwjs | 4:60be78a172c2 | 19 | GAPC_CONNECTION_CFM, |
dudnwjs | 4:60be78a172c2 | 20 | |
dudnwjs | 4:60be78a172c2 | 21 | /// Indicate that a link has been disconnected |
dudnwjs | 4:60be78a172c2 | 22 | GAPC_DISCONNECT_IND, |
dudnwjs | 4:60be78a172c2 | 23 | |
dudnwjs | 4:60be78a172c2 | 24 | /* Link management command */ |
dudnwjs | 4:60be78a172c2 | 25 | /// Request disconnection of current link command. |
dudnwjs | 4:60be78a172c2 | 26 | GAPC_DISCONNECT_CMD, |
dudnwjs | 4:60be78a172c2 | 27 | |
dudnwjs | 4:60be78a172c2 | 28 | /* Peer device info */ |
dudnwjs | 4:60be78a172c2 | 29 | /// Retrieve information command |
dudnwjs | 4:60be78a172c2 | 30 | GAPC_GET_INFO_CMD, |
dudnwjs | 4:60be78a172c2 | 31 | /// Name of peer device indication |
dudnwjs | 4:60be78a172c2 | 32 | GAPC_PEER_NAME_IND, |
dudnwjs | 4:60be78a172c2 | 33 | /// Indication of peer version info |
dudnwjs | 4:60be78a172c2 | 34 | GAPC_PEER_VERSION_IND, |
dudnwjs | 4:60be78a172c2 | 35 | /// Indication of peer features info |
dudnwjs | 4:60be78a172c2 | 36 | GAPC_PEER_FEATURES_IND, |
dudnwjs | 4:60be78a172c2 | 37 | |
dudnwjs | 4:60be78a172c2 | 38 | /// Indication of ongoing connection RSSI |
dudnwjs | 4:60be78a172c2 | 39 | GAPC_CON_RSSI_IND, |
dudnwjs | 4:60be78a172c2 | 40 | /// Indication of peer privacy info |
dudnwjs | 4:60be78a172c2 | 41 | GAPC_PRIVACY_IND, |
dudnwjs | 4:60be78a172c2 | 42 | /// Indication of peer reconnection address info |
dudnwjs | 4:60be78a172c2 | 43 | GAPC_RECON_ADDR_IND, |
dudnwjs | 4:60be78a172c2 | 44 | |
dudnwjs | 4:60be78a172c2 | 45 | /* Privacy configuration */ |
dudnwjs | 4:60be78a172c2 | 46 | /// Set Privacy flag command. |
dudnwjs | 4:60be78a172c2 | 47 | GAPC_SET_PRIVACY_CMD, |
dudnwjs | 4:60be78a172c2 | 48 | /// Set Reconnection Address Value command. |
dudnwjs | 4:60be78a172c2 | 49 | GAPC_SET_RECON_ADDR_CMD, |
dudnwjs | 4:60be78a172c2 | 50 | |
dudnwjs | 4:60be78a172c2 | 51 | /* Connection parameters update */ |
dudnwjs | 4:60be78a172c2 | 52 | /// Perform update of connection parameters command |
dudnwjs | 4:60be78a172c2 | 53 | GAPC_PARAM_UPDATE_CMD, |
dudnwjs | 4:60be78a172c2 | 54 | /// Request of updating connection parameters indication |
dudnwjs | 4:60be78a172c2 | 55 | GAPC_PARAM_UPDATE_REQ_IND, |
dudnwjs | 4:60be78a172c2 | 56 | /// Master confirm or not that parameters proposed by slave are accepted or not |
dudnwjs | 4:60be78a172c2 | 57 | GAPC_PARAM_UPDATE_CFM, |
dudnwjs | 4:60be78a172c2 | 58 | /// Connection parameters updated indication |
dudnwjs | 4:60be78a172c2 | 59 | GAPC_PARAM_UPDATED_IND, |
dudnwjs | 4:60be78a172c2 | 60 | |
dudnwjs | 4:60be78a172c2 | 61 | /* Bonding procedure */ |
dudnwjs | 4:60be78a172c2 | 62 | /// Start Bonding command procedure |
dudnwjs | 4:60be78a172c2 | 63 | GAPC_BOND_CMD, |
dudnwjs | 4:60be78a172c2 | 64 | /// Bonding requested by peer device indication message. |
dudnwjs | 4:60be78a172c2 | 65 | GAPC_BOND_REQ_IND, |
dudnwjs | 4:60be78a172c2 | 66 | /// Confirm requested bond information. |
dudnwjs | 4:60be78a172c2 | 67 | GAPC_BOND_CFM, |
dudnwjs | 4:60be78a172c2 | 68 | /// Bonding information indication message |
dudnwjs | 4:60be78a172c2 | 69 | GAPC_BOND_IND, |
dudnwjs | 4:60be78a172c2 | 70 | |
dudnwjs | 4:60be78a172c2 | 71 | /* Encryption procedure */ |
dudnwjs | 4:60be78a172c2 | 72 | /// Start Encryption command procedure |
dudnwjs | 4:60be78a172c2 | 73 | GAPC_ENCRYPT_CMD, |
dudnwjs | 4:60be78a172c2 | 74 | /// Encryption requested by peer device indication message. |
dudnwjs | 4:60be78a172c2 | 75 | GAPC_ENCRYPT_REQ_IND, |
dudnwjs | 4:60be78a172c2 | 76 | /// Confirm requested Encryption information. |
dudnwjs | 4:60be78a172c2 | 77 | GAPC_ENCRYPT_CFM, |
dudnwjs | 4:60be78a172c2 | 78 | /// Encryption information indication message |
dudnwjs | 4:60be78a172c2 | 79 | GAPC_ENCRYPT_IND, |
dudnwjs | 4:60be78a172c2 | 80 | |
dudnwjs | 4:60be78a172c2 | 81 | /* Security request procedure */ |
dudnwjs | 4:60be78a172c2 | 82 | /// Start Security Request command procedure |
dudnwjs | 4:60be78a172c2 | 83 | GAPC_SECURITY_CMD, |
dudnwjs | 4:60be78a172c2 | 84 | /// Security requested by peer device indication message |
dudnwjs | 4:60be78a172c2 | 85 | GAPC_SECURITY_IND, |
dudnwjs | 4:60be78a172c2 | 86 | |
dudnwjs | 4:60be78a172c2 | 87 | /* Signature procedure */ |
dudnwjs | 4:60be78a172c2 | 88 | /// Indicate the current sign counters to the application |
dudnwjs | 4:60be78a172c2 | 89 | GAPC_SIGN_COUNTER_IND, |
dudnwjs | 4:60be78a172c2 | 90 | |
dudnwjs | 4:60be78a172c2 | 91 | /* Device information */ |
dudnwjs | 4:60be78a172c2 | 92 | /// Indication of ongoing connection Channel Map |
dudnwjs | 4:60be78a172c2 | 93 | GAPC_CON_CHANNEL_MAP_IND, |
dudnwjs | 4:60be78a172c2 | 94 | |
dudnwjs | 4:60be78a172c2 | 95 | |
dudnwjs | 4:60be78a172c2 | 96 | /* Internal messages for timer events, not part of API*/ |
dudnwjs | 4:60be78a172c2 | 97 | /// Parameter update procedure timeout indication |
dudnwjs | 4:60be78a172c2 | 98 | GAPC_PARAM_UPDATE_TO_IND, |
dudnwjs | 4:60be78a172c2 | 99 | |
dudnwjs | 4:60be78a172c2 | 100 | }; |
dudnwjs | 4:60be78a172c2 | 101 | |
dudnwjs | 4:60be78a172c2 | 102 | /// request operation type - application interface |
dudnwjs | 4:60be78a172c2 | 103 | enum gapc_operation |
dudnwjs | 4:60be78a172c2 | 104 | { |
dudnwjs | 4:60be78a172c2 | 105 | /* Operation Flags */ |
dudnwjs | 4:60be78a172c2 | 106 | /* No Operation (if nothing has been requested) */ |
dudnwjs | 4:60be78a172c2 | 107 | /* ************************************************ */ |
dudnwjs | 4:60be78a172c2 | 108 | /// No operation |
dudnwjs | 4:60be78a172c2 | 109 | GAPC_NO_OP = 0x00, |
dudnwjs | 4:60be78a172c2 | 110 | |
dudnwjs | 4:60be78a172c2 | 111 | /* Connection management */ |
dudnwjs | 4:60be78a172c2 | 112 | /// Disconnect link |
dudnwjs | 4:60be78a172c2 | 113 | GAPC_DISCONNECT, |
dudnwjs | 4:60be78a172c2 | 114 | |
dudnwjs | 4:60be78a172c2 | 115 | /* Connection information */ |
dudnwjs | 4:60be78a172c2 | 116 | /// Retrieve name of peer device. |
dudnwjs | 4:60be78a172c2 | 117 | GAPC_GET_PEER_NAME, |
dudnwjs | 4:60be78a172c2 | 118 | /// Retrieve peer device version info. |
dudnwjs | 4:60be78a172c2 | 119 | GAPC_GET_PEER_VERSION, |
dudnwjs | 4:60be78a172c2 | 120 | /// Retrieve peer device features. |
dudnwjs | 4:60be78a172c2 | 121 | GAPC_GET_PEER_FEATURES, |
dudnwjs | 4:60be78a172c2 | 122 | /// Retrieve connection RSSI. |
dudnwjs | 4:60be78a172c2 | 123 | GAPC_GET_CON_RSSI, |
dudnwjs | 4:60be78a172c2 | 124 | /// Retrieve Privacy Info. |
dudnwjs | 4:60be78a172c2 | 125 | GAPC_GET_PRIVACY, |
dudnwjs | 4:60be78a172c2 | 126 | /// Retrieve Reconnection Address Value. |
dudnwjs | 4:60be78a172c2 | 127 | GAPC_GET_RECON_ADDR, |
dudnwjs | 4:60be78a172c2 | 128 | |
dudnwjs | 4:60be78a172c2 | 129 | /* Privacy Configuration */ |
dudnwjs | 4:60be78a172c2 | 130 | /// Set Privacy flag. |
dudnwjs | 4:60be78a172c2 | 131 | GAPC_SET_PRIVACY, |
dudnwjs | 4:60be78a172c2 | 132 | /// Set Reconnection Address Value. |
dudnwjs | 4:60be78a172c2 | 133 | GAPC_SET_RECON_ADDR, |
dudnwjs | 4:60be78a172c2 | 134 | |
dudnwjs | 4:60be78a172c2 | 135 | /* Connection parameters update */ |
dudnwjs | 4:60be78a172c2 | 136 | /// Perform update of connection parameters. |
dudnwjs | 4:60be78a172c2 | 137 | GAPC_UPDATE_PARAMS, |
dudnwjs | 4:60be78a172c2 | 138 | |
dudnwjs | 4:60be78a172c2 | 139 | /* Security procedures */ |
dudnwjs | 4:60be78a172c2 | 140 | /// Start bonding procedure. |
dudnwjs | 4:60be78a172c2 | 141 | GAPC_BOND, |
dudnwjs | 4:60be78a172c2 | 142 | /// Start encryption procedure. |
dudnwjs | 4:60be78a172c2 | 143 | GAPC_ENCRYPT, |
dudnwjs | 4:60be78a172c2 | 144 | /// Start security request procedure |
dudnwjs | 4:60be78a172c2 | 145 | GAPC_SECURITY_REQ, |
dudnwjs | 4:60be78a172c2 | 146 | |
dudnwjs | 4:60be78a172c2 | 147 | /* Connection information */ |
dudnwjs | 4:60be78a172c2 | 148 | /// Retrieve Connection Channel MAP. |
dudnwjs | 4:60be78a172c2 | 149 | GAPC_GET_CON_CHANNEL_MAP, |
dudnwjs | 4:60be78a172c2 | 150 | |
dudnwjs | 4:60be78a172c2 | 151 | |
dudnwjs | 4:60be78a172c2 | 152 | /// Last GAPC operation flag |
dudnwjs | 4:60be78a172c2 | 153 | GAPC_LAST |
dudnwjs | 4:60be78a172c2 | 154 | }; |
dudnwjs | 4:60be78a172c2 | 155 | |
dudnwjs | 4:60be78a172c2 | 156 | /// Bond event type. |
dudnwjs | 4:60be78a172c2 | 157 | enum gapc_bond |
dudnwjs | 4:60be78a172c2 | 158 | { |
dudnwjs | 4:60be78a172c2 | 159 | /// Bond Pairing request |
dudnwjs | 4:60be78a172c2 | 160 | GAPC_PAIRING_REQ, |
dudnwjs | 4:60be78a172c2 | 161 | /// Respond to Pairing request |
dudnwjs | 4:60be78a172c2 | 162 | GAPC_PAIRING_RSP, |
dudnwjs | 4:60be78a172c2 | 163 | |
dudnwjs | 4:60be78a172c2 | 164 | /// Pairing Finished information |
dudnwjs | 4:60be78a172c2 | 165 | GAPC_PAIRING_SUCCEED, |
dudnwjs | 4:60be78a172c2 | 166 | /// Pairing Failed information |
dudnwjs | 4:60be78a172c2 | 167 | GAPC_PAIRING_FAILED, |
dudnwjs | 4:60be78a172c2 | 168 | |
dudnwjs | 4:60be78a172c2 | 169 | /// Used to retrieve pairing Temporary Key |
dudnwjs | 4:60be78a172c2 | 170 | GAPC_TK_EXCH, |
dudnwjs | 4:60be78a172c2 | 171 | /// Used for Identity Resolving Key exchange |
dudnwjs | 4:60be78a172c2 | 172 | GAPC_IRK_EXCH, |
dudnwjs | 4:60be78a172c2 | 173 | /// Used for Connection Signature Resolving Key exchange |
dudnwjs | 4:60be78a172c2 | 174 | GAPC_CSRK_EXCH, |
dudnwjs | 4:60be78a172c2 | 175 | /// Used for Long Term Key exchange |
dudnwjs | 4:60be78a172c2 | 176 | GAPC_LTK_EXCH, |
dudnwjs | 4:60be78a172c2 | 177 | |
dudnwjs | 4:60be78a172c2 | 178 | /// Bond Pairing request issue, Repeated attempt |
dudnwjs | 4:60be78a172c2 | 179 | GAPC_REPEATED_ATTEMPT, |
dudnwjs | 4:60be78a172c2 | 180 | }; |
dudnwjs | 4:60be78a172c2 | 181 | |
dudnwjs | 4:60be78a172c2 | 182 | /// Command complete event data structure |
dudnwjs | 4:60be78a172c2 | 183 | struct gapc_cmp_evt |
dudnwjs | 4:60be78a172c2 | 184 | { |
dudnwjs | 4:60be78a172c2 | 185 | /// GAP request type |
dudnwjs | 4:60be78a172c2 | 186 | uint8_t operation; |
dudnwjs | 4:60be78a172c2 | 187 | /// Status of the request |
dudnwjs | 4:60be78a172c2 | 188 | uint8_t status; |
dudnwjs | 4:60be78a172c2 | 189 | }; |
dudnwjs | 4:60be78a172c2 | 190 | |
dudnwjs | 4:60be78a172c2 | 191 | /// Indicate that a connection has been established |
dudnwjs | 4:60be78a172c2 | 192 | struct gapc_connection_req_ind |
dudnwjs | 4:60be78a172c2 | 193 | { |
dudnwjs | 4:60be78a172c2 | 194 | /// Connection handle |
dudnwjs | 4:60be78a172c2 | 195 | uint16_t conhdl; |
dudnwjs | 4:60be78a172c2 | 196 | /// Connection interval |
dudnwjs | 4:60be78a172c2 | 197 | uint16_t con_interval; |
dudnwjs | 4:60be78a172c2 | 198 | /// Connection latency |
dudnwjs | 4:60be78a172c2 | 199 | uint16_t con_latency; |
dudnwjs | 4:60be78a172c2 | 200 | /// Link supervision timeout |
dudnwjs | 4:60be78a172c2 | 201 | uint16_t sup_to; |
dudnwjs | 4:60be78a172c2 | 202 | /// Clock accuracy |
dudnwjs | 4:60be78a172c2 | 203 | uint8_t clk_accuracy; |
dudnwjs | 4:60be78a172c2 | 204 | /// Peer address type |
dudnwjs | 4:60be78a172c2 | 205 | uint8_t peer_addr_type; |
dudnwjs | 4:60be78a172c2 | 206 | /// Peer BT address |
dudnwjs | 4:60be78a172c2 | 207 | struct bd_addr peer_addr; |
dudnwjs | 4:60be78a172c2 | 208 | }; |
dudnwjs | 5:e11b23f9aacc | 209 | |
dudnwjs | 5:e11b23f9aacc | 210 | |
dudnwjs | 5:e11b23f9aacc | 211 | |
dudnwjs | 5:e11b23f9aacc | 212 | /// Indicate that a link has been disconnected |
dudnwjs | 5:e11b23f9aacc | 213 | struct gapc_disconnect_ind |
dudnwjs | 5:e11b23f9aacc | 214 | { |
dudnwjs | 5:e11b23f9aacc | 215 | /// Connection handle |
dudnwjs | 5:e11b23f9aacc | 216 | uint16_t conhdl; |
dudnwjs | 5:e11b23f9aacc | 217 | /// Reason of disconnection |
dudnwjs | 5:e11b23f9aacc | 218 | uint8_t reason; |
dudnwjs | 5:e11b23f9aacc | 219 | }; |
dudnwjs | 5:e11b23f9aacc | 220 | |
dudnwjs | 5:e11b23f9aacc | 221 | /// Set specific link data configuration. |
dudnwjs | 5:e11b23f9aacc | 222 | struct gapc_connection_cfm |
dudnwjs | 5:e11b23f9aacc | 223 | { |
dudnwjs | 5:e11b23f9aacc | 224 | /// Local CSRK value |
dudnwjs | 5:e11b23f9aacc | 225 | struct gap_sec_key lcsrk; |
dudnwjs | 5:e11b23f9aacc | 226 | /// Local signature counter value |
dudnwjs | 5:e11b23f9aacc | 227 | uint32_t lsign_counter; |
dudnwjs | 5:e11b23f9aacc | 228 | |
dudnwjs | 5:e11b23f9aacc | 229 | /// Remote CSRK value |
dudnwjs | 5:e11b23f9aacc | 230 | struct gap_sec_key rcsrk; |
dudnwjs | 5:e11b23f9aacc | 231 | /// Remote signature counter value |
dudnwjs | 5:e11b23f9aacc | 232 | uint32_t rsign_counter; |
dudnwjs | 5:e11b23f9aacc | 233 | |
dudnwjs | 5:e11b23f9aacc | 234 | /// Authentication (@see gap_auth) |
dudnwjs | 5:e11b23f9aacc | 235 | uint8_t auth; |
dudnwjs | 5:e11b23f9aacc | 236 | /// Peer device is authorized to access database parameters requiring authorizations. |
dudnwjs | 5:e11b23f9aacc | 237 | /// - GAP_AUTHZ_NOT_SET: Authorization not set |
dudnwjs | 5:e11b23f9aacc | 238 | /// - GAP_AUTHZ_ACCEPT: Authorization automatically accepted |
dudnwjs | 5:e11b23f9aacc | 239 | /// - GAP_AUTHZ_REJECT: Authorization automatically rejected |
dudnwjs | 5:e11b23f9aacc | 240 | uint8_t authorize; |
dudnwjs | 5:e11b23f9aacc | 241 | }; |
dudnwjs | 5:e11b23f9aacc | 242 | |
dudnwjs | 4:60be78a172c2 | 243 | }//namespace |
dudnwjs | 4:60be78a172c2 | 244 | #endif//GAPC_TASK_H |