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 KIM HyoengJun

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gapm_task.h Source File

gapm_task.h

Go to the documentation of this file.
00001 /**
00002  * @file gapm_task.h
00003  * @brief Generic Access Profile Manager Task Header.
00004  * Copyright 2015 SEVENCORE Co., Ltd.
00005  *
00006  * @author HyeongJun Kim 
00007  * @version 1.0.0  
00008  * @date 2015-08-20
00009 */
00010 #ifndef GAPM_TASK_H
00011 #define GAPM_TASK_H
00012 
00013 #include "dialog_fota_config.h"
00014 #include "gap.h"
00015 
00016 /**
00017  ****************************************************************************************
00018  * @addtogroup dialog_fota module
00019  * @brief Generic Access Profile Manager Task Header.
00020  *
00021  * @{
00022  ****************************************************************************************
00023  */
00024 namespace sevencore_fota{
00025 
00026 /// Advertising or scanning report information event
00027 struct gapm_adv_report_ind
00028 {
00029     /// Advertising report structure
00030     struct adv_report report;
00031 };
00032 
00033 ///  Reset link layer and the host command
00034 struct gapm_reset_cmd
00035 {
00036     /// GAPM requested operation:
00037     /// - GAPM_RESET: Reset BLE subsystem: LL and HL.
00038     uint8_t operation;
00039 };
00040 /// Command complete event data structure
00041 struct gapm_cmp_evt
00042 {
00043     /// GAP requested operation
00044     uint8_t operation;
00045     /// Status of the request
00046     uint8_t status;
00047 };
00048 
00049 /// Air operation default parameters
00050 struct gapm_air_operation
00051 {
00052     /// Operation code.
00053     uint8_t  code;
00054 
00055 
00056     /** Own BD address source of the device:
00057      * - GAPM_PUBLIC_ADDR: Public Address
00058      * - GAPM_PROVIDED_RND_ADDR: Provided random address
00059      * - GAPM_GEN_STATIC_RND_ADDR: Generated static random address
00060      * - GAPM_GEN_RSLV_ADDR: Generated resolvable private random address
00061      * - GAPM_GEN_NON_RSLV_ADDR: Generated non-resolvable private random address
00062      * - GAPM_PROVIDED_RECON_ADDR: Provided Reconnection address (only for GAPM_ADV_DIRECT)
00063      */
00064     uint8_t addr_src;
00065 
00066     /// Dummy data use to retrieve internal operation state (should be set to 0).
00067     uint16_t state;
00068 
00069     /// Duration of resolvable address before regenerate it.
00070     uint16_t renew_dur;
00071 
00072     /// Provided own static private random address (addr_src = 1 or 5)
00073     struct bd_addr addr;
00074 };
00075 
00076 /// Advertising data that contains information set by host.
00077 struct gapm_adv_host
00078 {
00079     /// Advertising mode :
00080     /// - GAP_NON_DISCOVERABLE: Non discoverable mode
00081     /// - GAP_GEN_DISCOVERABLE: General discoverable mode
00082     /// - GAP_LIM_DISCOVERABLE: Limited discoverable mode
00083     /// - GAP_BROADCASTER_MODE: Broadcaster mode
00084     uint8_t              mode;
00085 
00086     /// Advertising filter policy:
00087     /// - ADV_ALLOW_SCAN_ANY_CON_ANY: Allow both scan and connection requests from anyone
00088     /// - ADV_ALLOW_SCAN_WLST_CON_ANY: Allow both scan req from White List devices only and
00089     ///   connection req from anyone
00090     /// - ADV_ALLOW_SCAN_ANY_CON_WLST: Allow both scan req from anyone and connection req
00091     ///   from White List devices only
00092     /// - ADV_ALLOW_SCAN_WLST_CON_WLST: Allow scan and connection requests from White List
00093     ///   devices only
00094     uint8_t              adv_filt_policy;
00095 
00096     /// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set
00097     /// Advertising AD type flags, shall not be set in advertising data
00098     uint8_t              adv_data_len;
00099     /// Advertising data
00100     uint8_t              adv_data[ADV_DATA_LEN-3];
00101     /// Scan response data length- maximum 31 bytes
00102     uint8_t              scan_rsp_data_len;
00103     /// Scan response data
00104     uint8_t              scan_rsp_data[SCAN_RSP_DATA_LEN];
00105 };
00106 
00107 /// Set advertising mode Command
00108 struct gapm_start_advertise_cmd
00109 {
00110     /// GAPM requested operation:
00111     /// - GAPM_ADV_NON_CONN: Start non connectable advertising
00112     /// - GAPM_ADV_UNDIRECT: Start undirected connectable advertising
00113     /// - GAPM_ADV_DIRECT: Start directed connectable advertising
00114     struct gapm_air_operation op;
00115 
00116     /// Minimum interval for advertising
00117     uint16_t             intv_min;
00118     /// Maximum interval for advertising
00119     uint16_t             intv_max;
00120 
00121     ///Advertising channel map
00122     uint8_t              channel_map;
00123 
00124     /// Advertising information
00125     union gapm_adv_info
00126     {
00127         /// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT)
00128         struct gapm_adv_host host;
00129         ///  Direct address information (GAPM_ADV_DIRECT)
00130         /// (used only if reconnection address isn't set or privacy disabled)
00131         struct gap_bdaddr direct;
00132     } info;
00133 };
00134 
00135 /// Set device configuration command
00136 struct gapm_set_dev_config_cmd
00137 {
00138     /// GAPM requested operation:
00139     ///  - GAPM_SET_DEV_CONFIG: Set device configuration
00140     uint8_t operation;
00141     /// Device Role: Central, Peripheral, Observer or Broadcaster
00142     uint8_t role;
00143     /// Device IRK used for resolvable random BD address generation (LSB first)
00144     struct gap_sec_key irk;
00145 
00146     /// Device Appearance (0x0000 - Unknown appearance)
00147     uint16_t appearance;
00148     /// Device Appearance write permission requirements for peer device (@see gapm_write_att_perm)
00149     uint8_t  appearance_write_perm;
00150     /// Device Name write permission requirements for peer device (@see gapm_write_att_perm)
00151     uint8_t  name_write_perm;
00152 
00153     /// Maximal MTU
00154     uint16_t max_mtu;
00155 
00156     /// Peripheral only: *****************************************************************
00157     /// Slave preferred Minimum of connection interval
00158     uint16_t con_intv_min;
00159     /// Slave preferred Maximum of connection interval
00160     uint16_t con_intv_max;
00161     /// Slave preferred Connection latency
00162     uint16_t con_latency;
00163     /// Slave preferred Link supervision timeout
00164     uint16_t superv_to;
00165 
00166     /// Privacy settings bit field (0b1 = enabled, 0b0 = disabled)
00167     ///  - [bit 0]: Privacy Support
00168     ///  - [bit 1]: Multiple Bond Support (Peripheral only); If enabled, privacy flag is
00169     ///             read only.
00170     ///  - [bit 2]: Reconnection address visible.
00171     uint8_t flags;
00172 };
00173 
00174 /// GAP Manager Message Interface
00175 enum gapm_msg_id
00176 {
00177     /* Default event */
00178     /// Command Complete event
00179     GAPM_CMP_EVT = 13312,
00180     /// Event triggered to inform that lower layers are ready
00181     GAPM_DEVICE_READY_IND,
00182 
00183     /* Default commands */
00184     /// Reset link layer and the host command
00185     GAPM_RESET_CMD,
00186     /// Cancel ongoing operation
00187     GAPM_CANCEL_CMD,
00188 
00189     /* Device Configuration */
00190     /// Set device configuration command
00191     GAPM_SET_DEV_CONFIG_CMD,
00192     /// Set device name command
00193     GAPM_SET_DEV_NAME_CMD,
00194     /// Set device channel map
00195     GAPM_SET_CHANNEL_MAP_CMD,
00196 
00197     /* Local device information */
00198     /// Get local device info command
00199     GAPM_GET_DEV_INFO_CMD,
00200     /// Local device name indication event
00201     GAPM_DEV_NAME_IND,
00202     /// Local device appearance indication event
00203     GAPM_APPEARANCE_IND,
00204     /// Local device version indication event
00205     GAPM_DEV_VERSION_IND,
00206     /// Local device BD Address indication event
00207     GAPM_DEV_BDADDR_IND,
00208 
00209     /* White List */
00210     /// White List Management Command
00211     GAPM_WHITE_LIST_MGT_CMD,
00212     /// White List Size indication event
00213     GAPM_WHITE_LIST_SIZE_IND,
00214 
00215     /* Air Operations */
00216     /// Set advertising mode Command
00217     GAPM_START_ADVERTISE_CMD,
00218 
00219     /// Set Scan mode Command
00220     GAPM_START_SCAN_CMD,
00221     /// Advertising or scanning report information event
00222     GAPM_ADV_REPORT_IND,
00223 
00224     /// Set connection initialization Command
00225     GAPM_START_CONNECTION_CMD,
00226     /// Name of peer device indication
00227     GAPM_PEER_NAME_IND,
00228     /// Confirm connection to a specific device (Connection Operation in Selective mode)
00229     GAPM_CONNECTION_CFM,
00230 
00231     /* Privacy update events */
00232     /// Privacy flag value has been updated
00233     GAPM_UPDATED_PRIVACY_IND,
00234     /// Reconnection address has been updated
00235     GAPM_UPDATED_RECON_ADDR_IND,
00236 
00237     /* Security / Encryption Toolbox */
00238     /// Resolve address command
00239     GAPM_RESOLV_ADDR_CMD,
00240     /// Indicate that resolvable random address has been solved
00241     GAPM_ADDR_SOLVED_IND,
00242     /// Generate a random address.
00243     GAPM_GEN_RAND_ADDR_CMD,
00244     /// Use the AES-128 block in the controller
00245     GAPM_USE_ENC_BLOCK_CMD,
00246     ///  AES-128 block result indication
00247     GAPM_USE_ENC_BLOCK_IND,
00248     /// Generate a 8-byte random number
00249     GAPM_GEN_RAND_NB_CMD,
00250     /// Random Number Indication
00251     GAPM_GEN_RAND_NB_IND,
00252 
00253     /* Debug  */
00254     /// Indication containing information about memory usage.
00255     GAPM_DBG_MEM_INFO_IND,
00256 
00257     /* Local device information -cont */
00258     /// Advertising channel Tx power level
00259     GAPM_DEV_ADV_TX_POWER_IND,
00260 
00261     /* Internal messages for timer events, not part of API*/
00262     /// Limited discoverable timeout indication
00263     GAPM_LIM_DISC_TO_IND,
00264     /// Scan timeout indication
00265     GAPM_SCAN_TO_IND,
00266     /// Address renewal timeout indication
00267     GAPM_ADDR_RENEW_TO_IND,
00268 };
00269 
00270 /// GAP Manager operation type - application interface
00271 enum gapm_operation
00272 {
00273     /* No Operation (if nothing has been requested)     */
00274     /* ************************************************ */
00275     /// No operation.
00276     GAPM_NO_OP                                     = 0x00,
00277 
00278     /* Default operations                               */
00279     /* ************************************************ */
00280     /// Reset BLE subsystem: LL and HL.
00281     GAPM_RESET,
00282     /// Cancel currently executed operation.
00283     GAPM_CANCEL,
00284 
00285     /* Configuration operations                         */
00286     /* ************************************************ */
00287     /// Set device configuration
00288     GAPM_SET_DEV_CONFIG,
00289     /// Set device name
00290     GAPM_SET_DEV_NAME,
00291     /// Set device channel map
00292     GAPM_SET_CHANNEL_MAP,
00293 
00294     /* Retrieve device information                      */
00295     /* ************************************************ */
00296     /// Get Local device name
00297     GAPM_GET_DEV_NAME,
00298     /// Get Local device version
00299     GAPM_GET_DEV_VERSION,
00300     /// Get Local device BD Address
00301     GAPM_GET_DEV_BDADDR,
00302 
00303     /* Operation on White list                          */
00304     /* ************************************************ */
00305     /// Get White List Size.
00306     GAPM_GET_WLIST_SIZE,
00307     /// Add devices in white list.
00308     GAPM_ADD_DEV_IN_WLIST,
00309     /// Remove devices form white list.
00310     GAPM_RMV_DEV_FRM_WLIST,
00311     /// Clear all devices from white list.
00312     GAPM_CLEAR_WLIST,
00313 
00314     /* Advertise mode operations                        */
00315     /* ************************************************ */
00316     /// Start non connectable advertising
00317     GAPM_ADV_NON_CONN,
00318     /// Start undirected connectable advertising
00319     GAPM_ADV_UNDIRECT,
00320     /// Start directed connectable advertising
00321     GAPM_ADV_DIRECT,
00322 
00323     /* Scan mode operations                             */
00324     /* ************************************************ */
00325     /// Start active scan operation
00326     GAPM_SCAN_ACTIVE,
00327     /// Start passive scan operation
00328     GAPM_SCAN_PASSIVE,
00329 
00330     /* Connection mode operations                       */
00331     /* ************************************************ */
00332     /// Direct connection operation
00333     GAPM_CONNECTION_DIRECT,
00334     /// Automatic connection operation
00335     GAPM_CONNECTION_AUTO,
00336     /// Selective connection operation
00337     GAPM_CONNECTION_SELECTIVE,
00338     /// Name Request operation (requires to start a direct connection)
00339     GAPM_CONNECTION_NAME_REQUEST,
00340 
00341     /* Security / Encryption Toolbox                    */
00342     /* ************************************************ */
00343     /// Resolve device address
00344     GAPM_RESOLV_ADDR,
00345     /// Generate a random address
00346     GAPM_GEN_RAND_ADDR,
00347     /// Use the controller's AES-128 block
00348     GAPM_USE_ENC_BLOCK,
00349     /// Generate a 8-byte random number
00350     GAPM_GEN_RAND_NB,
00351 
00352     /* DEBUG                                            */
00353     /* ************************************************ */
00354     /// Get memory usage
00355     GAPM_DBG_GET_MEM_INFO,
00356     /// Perform a platform reset
00357     GAPM_PLF_RESET,
00358 
00359     /* Retrieve device information - cont               */
00360     /* ************************************************ */
00361     /// Get device advertising power level
00362     GAPM_GET_DEV_ADV_TX_POWER,
00363 
00364     /// Last GAPM operation flag
00365     GAPM_LAST
00366 };
00367 
00368 /// Own BD address source of the device
00369 enum gapm_own_addr_src
00370 {
00371    /// Public Address
00372    GAPM_PUBLIC_ADDR,
00373    /// Provided random address
00374    GAPM_PROVIDED_RND_ADDR,
00375    /// Provided static random address
00376    GAPM_GEN_STATIC_RND_ADDR,
00377    /// Generated resolvable private random address
00378    GAPM_GEN_RSLV_ADDR,
00379    /// Generated non-resolvable private random address
00380    GAPM_GEN_NON_RSLV_ADDR,
00381    /// Provided Reconnection address
00382    GAPM_PROVIDED_RECON_ADDR,
00383 };
00384 
00385 /// Device Attribute write permission requirement
00386 enum gapm_write_att_perm
00387 {
00388     /// Disable write access
00389     GAPM_WRITE_DISABLE  = 0,
00390     /// Enable write access
00391     GAPM_WRITE_ENABLE   = 8,
00392     /// Write access requires unauthenticated link
00393     GAPM_WRITE_UNAUTH   = 16,
00394     /// Write access requires authenticated link
00395     GAPM_WRITE_AUTH     = 24,
00396 };
00397 
00398 }//namespace
00399 
00400 /// @} dialog_fota module
00401 
00402 #endif//GAPM_TASK_H