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 app.h Source File

app.h

Go to the documentation of this file.
00001 /**
00002  * @file app.h
00003  * @brief Application entry point
00004  * Copyright 2015 SEVENCORE Co., Ltd.
00005  *
00006  * @author HyeongJun Kim 
00007  * @version 1.0.0  
00008  * @date 2015-08-17
00009 */
00010 #ifndef APP_H
00011 #define APP_H
00012 
00013 #include "BleMsgHandler.h"
00014 #include "app_sw_version.h"
00015 #include "diss_task.h"
00016 #include "dialog_fota_config.h"
00017 
00018 namespace sevencore_fota{
00019 
00020 /**
00021  ****************************************************************************************
00022  * @addtogroup dialog_fota module
00023  * @brief Application entry point Header.
00024  *
00025  * @{
00026  ****************************************************************************************
00027  */
00028 
00029 #define KE_IDX_GET(uint16_t) (((uint16_t) >> 8) & 0xFF)
00030 #define KE_BUILD_ID(type, index) ( (uint16_t)(((index) << 8)|(type)) )
00031 
00032 /*
00033  * DISS DEFINITIONS
00034  ****************************************************************************************
00035  */
00036 /// Manufacturer Name (up to 18 chars)
00037 #define APP_DIS_MANUFACTURER_NAME_STR       ("SevenCore")
00038 #define APP_DIS_MANUFACTURER_NAME_STR_LEN   (9)
00039 /// Model Number String (up to 18 chars)
00040 #define APP_DIS_MODEL_NB_STR            ("DA1458A")
00041 #define APP_DIS_MODEL_NB_STR_LEN        (7)
00042 /// System ID - LSB -> MSB (FIXME)
00043 #define APP_DIS_SERIAL_NB_STR               ("123-789")
00044 #define APP_DIS_SERIAL_NB_STR_LEN           (7)
00045 /// System ID - LSB -> MSB (FIXME)
00046 #define APP_DIS_SYSTEM_ID               ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE")
00047 #define APP_DIS_SYSTEM_ID_LEN           (8)
00048 
00049 #define APP_DIS_SW_REV                  DA14583_REFDES_SW_VERSION
00050 #define APP_DIS_FIRM_REV                DA14583_SW_VERSION
00051 #define APP_DIS_FEATURES                (DIS_MANUFACTURER_NAME_CHAR_SUP | DIS_MODEL_NB_STR_CHAR_SUP | DIS_SYSTEM_ID_CHAR_SUP | DIS_SW_REV_STR_CHAR_SUP | DIS_FIRM_REV_STR_CHAR_SUP | DIS_PNP_ID_CHAR_SUP)
00052 /// Advertising minimum interval
00053 #define APP_ADV_INT_MIN   0x800
00054 /// Advertising maximum interval
00055 #define APP_ADV_INT_MAX   0x800
00056 /// Advertising channel map
00057 #define APP_ADV_CHMAP     0x07
00058 /// Advertising data maximal length
00059 #define APP_ADV_DATA_MAX_SIZE           (ADV_DATA_LEN - 3)
00060 /// Scan Response data maximal length
00061 #define APP_SCAN_RESP_DATA_MAX_SIZE     (SCAN_RSP_DATA_LEN)
00062 #define APP_DFLT_ADV_DATA        "\x09\x03\xFF\x18\xFF\x18\x0A\x18\x0A\x18"
00063 #define APP_DFLT_ADV_DATA_LEN    (8+2)
00064 #define APP_SCNRSP_DATA         "\x09\xFF\x00\x60\x52\x57\x2D\x42\x4C\x45"
00065 #define APP_SCNRSP_DATA_LENGTH  (10)
00066 #define APP_DFLT_DEVICE_NAME    ("DA1458A")
00067 
00068 
00069 typedef struct 
00070 {
00071     unsigned char  free;
00072     struct bd_addr adv_addr;
00073     unsigned short conidx;
00074     unsigned short conhdl;
00075     unsigned char idx;
00076     unsigned char  rssi;
00077     unsigned char  data_len;
00078     unsigned char  data[ADV_DATA_LEN + 1];
00079 
00080 } ble_dev;
00081 
00082 #define MAX_SCAN_DEVICES 9 
00083 
00084 enum
00085 {
00086     /// Idle state
00087     APP_IDLE,
00088     /// Scanning state
00089     APP_CONNECTABLE,
00090     /// Connected state
00091     APP_CONNECTED,
00092     /// Number of defined states.
00093     APP_STATE_MAX,
00094     /// Scanning state
00095     APP_SCAN,
00096 };
00097 
00098 struct app_env_tag
00099 {
00100     unsigned char state;
00101     unsigned char num_of_devices;
00102     ble_dev devices[MAX_SCAN_DEVICES];
00103 };
00104 
00105 extern struct app_env_tag app_env;
00106 
00107 /**
00108  ****************************************************************************************
00109  * @brief Send Reset request to GAPM task.
00110  * @param[in] BMH     Ble Message Handler class reference
00111  * @return void.
00112  ****************************************************************************************
00113  */
00114 void app_rst_gap(BleMsgHandler *BMH);
00115 /**
00116  ****************************************************************************************
00117  * @brief Send enable request to DISS profile task.
00118  * @param[in] BMH     Ble Message Handler class reference
00119  * @return void.
00120  ****************************************************************************************
00121  */
00122 void app_diss_db_create(BleMsgHandler* BMH);
00123 /**
00124  ****************************************************************************************
00125  * @brief Send enable request to FOTA profile task.
00126  * @param[in] BMH     Ble Message Handler class reference
00127  * @return void.
00128  ****************************************************************************************
00129  */
00130 void app_fota_server_db_create(BleMsgHandler* BMH);
00131 /**
00132  ****************************************************************************************
00133  * @brief Send Start Advertising command to GAPM task.
00134  * @param[in] BMH     Ble Message Handler class reference
00135  * @return void.
00136  ****************************************************************************************
00137  */
00138 void app_adv_start(BleMsgHandler* BMH);
00139 /**
00140  ****************************************************************************************
00141  * @brief Set Bondabe mode.
00142  * @param[in] BMH     Ble Message Handler class reference
00143  * @return void.
00144  ****************************************************************************************
00145  */
00146 void app_set_mode(BleMsgHandler* BMH);
00147 /**
00148  ****************************************************************************************
00149  * @brief Send enable request to DISS profile task.
00150  * @param[in] device  Ble device info
00151  * @param[in] BMH     Ble Message Handler class reference
00152  * @return void.
00153  ****************************************************************************************
00154  */
00155 void app_dis_enable(ble_dev *device,BleMsgHandler* BMH);
00156 /**
00157  ****************************************************************************************
00158  * @brief Send enable request to FOTA profile task.
00159  * @param[in] device  Ble device info
00160  * @param[in] BMH     Ble Message Handler class reference
00161  * @return void.
00162  ****************************************************************************************
00163  */
00164 void app_fota_server_enable(ble_dev *device,BleMsgHandler* BMH);
00165 /**
00166  ****************************************************************************************
00167  * @brief Send connection confirmation.
00168  * param[in] auth  Authentication requirements.
00169  * @param[in] device  Ble device info
00170  * @param[in] BMH     Ble Message Handler class reference
00171  * @return void.
00172  ****************************************************************************************
00173  */
00174 void app_connect_confirm(uint8_t auth,ble_dev *device,BleMsgHandler* BMH);
00175 /**
00176  ****************************************************************************************
00177  * @brief Send the GAPC_DISCONNECT_IND message to a task.
00178  * @param[in] dst     Task id of the destination task.
00179  * @param[in] conhdl  The conhdl parameter of the GAPC_DISCONNECT_IND message.
00180  * @param[in] reason  The reason parameter of the GAPC_DISCONNECT_IND message.
00181  * @param[in] BMH     Ble Message Handler class reference
00182  * @return void.
00183  ****************************************************************************************
00184  */
00185 void app_send_disconnect(uint16_t dst, uint16_t conhdl, uint8_t reason,BleMsgHandler* BMH);
00186 
00187 }//namespace
00188 
00189 /// @} dialog_fota module
00190 
00191 #endif//APP_H