Bluetooth Low Energy based Firmware Over The Air with Mbed. Mbed part is a external processor of the IoT devices and communicate with a Bluetooth module. The Bluetooth module have to support BLE and implement BLE FOTA profile designed by ours. BLE FOTA profile specification is available from our GIT hub wiki(https://github.com/sevencore/BLEFOTA).
Dependencies: mbed
Fork of mbed_fota by
Bluetooth Low Energy based Firmware Over The Air with Mbed. Mbed part is a external processor of the IoT devices and communicate with a Bluetooth module. The Bluetooth module have to support BLE and implement BLE FOTA profile designed by ours. BLE FOTA profile specification is available from our GIT hub wiki.
Diff: dialog_fota/gapm_task.h
- Revision:
- 4:60be78a172c2
- Parent:
- 3:1e70387e1337
- Child:
- 5:e11b23f9aacc
diff -r 1e70387e1337 -r 60be78a172c2 dialog_fota/gapm_task.h --- a/dialog_fota/gapm_task.h Tue Jun 23 06:32:40 2015 +0000 +++ b/dialog_fota/gapm_task.h Wed Jun 24 08:50:07 2015 +0000 @@ -1,8 +1,17 @@ #ifndef GAPM_TASK_H #define GAPM_TASK_H +#include "dialog_fota_config.h" + namespace sevencore_fota{ +/// Advertising or scanning report information event +struct gapm_adv_report_ind +{ + /// Advertising report structure + struct adv_report report; +}; + /// Reset link layer and the host command struct gapm_reset_cmd { @@ -10,6 +19,193 @@ /// - GAPM_RESET: Reset BLE subsystem: LL and HL. uint8_t operation; }; +/// Command complete event data structure +struct gapm_cmp_evt +{ + /// GAP requested operation + uint8_t operation; + /// Status of the request + uint8_t status; +}; + +/// Air operation default parameters +struct gapm_air_operation +{ + /// Operation code. + uint8_t code; + + + /** Own BD address source of the device: + * - GAPM_PUBLIC_ADDR: Public Address + * - GAPM_PROVIDED_RND_ADDR: Provided random address + * - GAPM_GEN_STATIC_RND_ADDR: Generated static random address + * - GAPM_GEN_RSLV_ADDR: Generated resolvable private random address + * - GAPM_GEN_NON_RSLV_ADDR: Generated non-resolvable private random address + * - GAPM_PROVIDED_RECON_ADDR: Provided Reconnection address (only for GAPM_ADV_DIRECT) + */ + uint8_t addr_src; + + /// Dummy data use to retrieve internal operation state (should be set to 0). + uint16_t state; + + /// Duration of resolvable address before regenerate it. + uint16_t renew_dur; + + /// Provided own static private random address (addr_src = 1 or 5) + struct bd_addr addr; +}; + +/// Advertising data that contains information set by host. +struct gapm_adv_host +{ + /// Advertising mode : + /// - GAP_NON_DISCOVERABLE: Non discoverable mode + /// - GAP_GEN_DISCOVERABLE: General discoverable mode + /// - GAP_LIM_DISCOVERABLE: Limited discoverable mode + /// - GAP_BROADCASTER_MODE: Broadcaster mode + uint8_t mode; + + /// Advertising filter policy: + /// - ADV_ALLOW_SCAN_ANY_CON_ANY: Allow both scan and connection requests from anyone + /// - ADV_ALLOW_SCAN_WLST_CON_ANY: Allow both scan req from White List devices only and + /// connection req from anyone + /// - ADV_ALLOW_SCAN_ANY_CON_WLST: Allow both scan req from anyone and connection req + /// from White List devices only + /// - ADV_ALLOW_SCAN_WLST_CON_WLST: Allow scan and connection requests from White List + /// devices only + uint8_t adv_filt_policy; + + /// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set + /// Advertising AD type flags, shall not be set in advertising data + uint8_t adv_data_len; + /// Advertising data + uint8_t adv_data[ADV_DATA_LEN-3]; + /// Scan response data length- maximum 31 bytes + uint8_t scan_rsp_data_len; + /// Scan response data + uint8_t scan_rsp_data[SCAN_RSP_DATA_LEN]; +}; + + +//////////////GAP +#define KEY_LEN 0x10 +/// Generic Security key structure +struct gap_sec_key +{ + /// Key value MSB -> LSB + uint8_t key[KEY_LEN]; +}; + +/// Address information about a device address +struct gap_bdaddr +{ + /// BD Address of device + struct bd_addr addr; + /// Address type of the device 0=public/1=private random + uint8_t addr_type; +}; + +/// Advertising mode +enum gap_adv_mode +{ + /// Mode in non-discoverable + GAP_NON_DISCOVERABLE, + /// Mode in general discoverable + GAP_GEN_DISCOVERABLE, + /// Mode in limited discoverable + GAP_LIM_DISCOVERABLE, + /// Broadcaster mode which is a non discoverable and non connectable mode. + GAP_BROADCASTER_MODE, +}; +/****************** GAP Role **********************/ +enum gap_role +{ + /// No role set yet + GAP_NO_ROLE = 0x00, + + /// Observer role + GAP_OBSERVER_SCA = 0x01, + + /// Broadcaster role + GAP_BROADCASTER_ADV = 0x02, + + /// Master/Central role + GAP_CENTRAL_MST = (0x04 | GAP_OBSERVER_SCA), + + /// Peripheral/Slave role + GAP_PERIPHERAL_SLV = (0x08 | GAP_BROADCASTER_ADV), +}; + +//////////////GAP + +/// Set advertising mode Command +struct gapm_start_advertise_cmd +{ + /// GAPM requested operation: + /// - GAPM_ADV_NON_CONN: Start non connectable advertising + /// - GAPM_ADV_UNDIRECT: Start undirected connectable advertising + /// - GAPM_ADV_DIRECT: Start directed connectable advertising + struct gapm_air_operation op; + + /// Minimum interval for advertising + uint16_t intv_min; + /// Maximum interval for advertising + uint16_t intv_max; + + ///Advertising channel map + uint8_t channel_map; + + /// Advertising information + union gapm_adv_info + { + /// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT) + struct gapm_adv_host host; + /// Direct address information (GAPM_ADV_DIRECT) + /// (used only if reconnection address isn't set or privacy disabled) + struct gap_bdaddr direct; + } info; +}; + + +/// Set device configuration command +struct gapm_set_dev_config_cmd +{ + /// GAPM requested operation: + /// - GAPM_SET_DEV_CONFIG: Set device configuration + uint8_t operation; + /// Device Role: Central, Peripheral, Observer or Broadcaster + uint8_t role; + /// Device IRK used for resolvable random BD address generation (LSB first) + struct gap_sec_key irk; + + /// Device Appearance (0x0000 - Unknown appearance) + uint16_t appearance; + /// Device Appearance write permission requirements for peer device (@see gapm_write_att_perm) + uint8_t appearance_write_perm; + /// Device Name write permission requirements for peer device (@see gapm_write_att_perm) + uint8_t name_write_perm; + + /// Maximal MTU + uint16_t max_mtu; + + /// Peripheral only: ***************************************************************** + /// Slave preferred Minimum of connection interval + uint16_t con_intv_min; + /// Slave preferred Maximum of connection interval + uint16_t con_intv_max; + /// Slave preferred Connection latency + uint16_t con_latency; + /// Slave preferred Link supervision timeout + uint16_t superv_to; + + /// Privacy settings bit field (0b1 = enabled, 0b0 = disabled) + /// - [bit 0]: Privacy Support + /// - [bit 1]: Multiple Bond Support (Peripheral only); If enabled, privacy flag is + /// read only. + /// - [bit 2]: Reconnection address visible. + uint8_t flags; +}; + /// GAP Manager Message Interface @@ -206,6 +402,36 @@ GAPM_LAST }; +/// Own BD address source of the device +enum gapm_own_addr_src +{ + /// Public Address + GAPM_PUBLIC_ADDR, + /// Provided random address + GAPM_PROVIDED_RND_ADDR, + /// Provided static random address + GAPM_GEN_STATIC_RND_ADDR, + /// Generated resolvable private random address + GAPM_GEN_RSLV_ADDR, + /// Generated non-resolvable private random address + GAPM_GEN_NON_RSLV_ADDR, + /// Provided Reconnection address + GAPM_PROVIDED_RECON_ADDR, +}; + +/// Device Attribute write permission requirement +enum gapm_write_att_perm +{ + /// Disable write access + GAPM_WRITE_DISABLE = 0, + /// Enable write access + GAPM_WRITE_ENABLE = 8, + /// Write access requires unauthenticated link + GAPM_WRITE_UNAUTH = 16, + /// Write access requires authenticated link + GAPM_WRITE_AUTH = 24, +}; + }//namespace #endif//GAPM_TASK_H