BLE fota Lamp Demo
Dependencies: mbed-rtos mbed mbed_fota_fan_control
Fork of mbed_fota_fan_control by
dialog_fota/app.h@13:e714e2971c49, 2015-10-13 (annotated)
- Committer:
- dudnwjs
- Date:
- Tue Oct 13 06:35:19 2015 +0000
- Revision:
- 13:e714e2971c49
- Parent:
- 12:e3d3676753cc
lamp demo;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudnwjs | 9:fcf91f563147 | 1 | /** |
dudnwjs | 9:fcf91f563147 | 2 | * @file app.h |
dudnwjs | 9:fcf91f563147 | 3 | * @brief Application entry point |
dudnwjs | 9:fcf91f563147 | 4 | * Copyright 2015 SEVENCORE Co., Ltd. |
dudnwjs | 9:fcf91f563147 | 5 | * |
dudnwjs | 9:fcf91f563147 | 6 | * @author HyeongJun Kim |
dudnwjs | 9:fcf91f563147 | 7 | * @version 1.0.0 |
dudnwjs | 9:fcf91f563147 | 8 | * @date 2015-08-17 |
dudnwjs | 9:fcf91f563147 | 9 | */ |
dudnwjs | 3:1e70387e1337 | 10 | #ifndef APP_H |
dudnwjs | 3:1e70387e1337 | 11 | #define APP_H |
dudnwjs | 3:1e70387e1337 | 12 | |
dudnwjs | 3:1e70387e1337 | 13 | #include "BleMsgHandler.h" |
dudnwjs | 4:60be78a172c2 | 14 | #include "app_sw_version.h" |
dudnwjs | 4:60be78a172c2 | 15 | #include "diss_task.h" |
dudnwjs | 4:60be78a172c2 | 16 | #include "dialog_fota_config.h" |
dudnwjs | 3:1e70387e1337 | 17 | |
dudnwjs | 3:1e70387e1337 | 18 | namespace sevencore_fota{ |
dudnwjs | 3:1e70387e1337 | 19 | |
dudnwjs | 9:fcf91f563147 | 20 | /** |
dudnwjs | 9:fcf91f563147 | 21 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 22 | * @addtogroup dialog_fota module |
dudnwjs | 9:fcf91f563147 | 23 | * @brief Application entry point Header. |
dudnwjs | 9:fcf91f563147 | 24 | * |
dudnwjs | 9:fcf91f563147 | 25 | * @{ |
dudnwjs | 9:fcf91f563147 | 26 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 27 | */ |
dudnwjs | 5:e11b23f9aacc | 28 | |
dudnwjs | 5:e11b23f9aacc | 29 | #define KE_IDX_GET(uint16_t) (((uint16_t) >> 8) & 0xFF) |
dudnwjs | 5:e11b23f9aacc | 30 | #define KE_BUILD_ID(type, index) ( (uint16_t)(((index) << 8)|(type)) ) |
dudnwjs | 5:e11b23f9aacc | 31 | |
dudnwjs | 4:60be78a172c2 | 32 | /* |
dudnwjs | 4:60be78a172c2 | 33 | * DISS DEFINITIONS |
dudnwjs | 4:60be78a172c2 | 34 | **************************************************************************************** |
dudnwjs | 4:60be78a172c2 | 35 | */ |
dudnwjs | 4:60be78a172c2 | 36 | /// Manufacturer Name (up to 18 chars) |
dudnwjs | 5:e11b23f9aacc | 37 | #define APP_DIS_MANUFACTURER_NAME_STR ("SevenCore") |
dudnwjs | 5:e11b23f9aacc | 38 | #define APP_DIS_MANUFACTURER_NAME_STR_LEN (9) |
dudnwjs | 4:60be78a172c2 | 39 | /// Model Number String (up to 18 chars) |
dudnwjs | 13:e714e2971c49 | 40 | #define APP_DIS_MODEL_NB_STR ("SC-Lamp-02") |
dudnwjs | 13:e714e2971c49 | 41 | #define APP_DIS_MODEL_NB_STR_LEN (10) |
dudnwjs | 4:60be78a172c2 | 42 | /// System ID - LSB -> MSB (FIXME) |
dudnwjs | 13:e714e2971c49 | 43 | #define APP_DIS_SERIAL_NB_STR ("123-456") |
dudnwjs | 6:8dd20294b2aa | 44 | #define APP_DIS_SERIAL_NB_STR_LEN (7) |
dudnwjs | 5:e11b23f9aacc | 45 | /// System ID - LSB -> MSB (FIXME) |
dudnwjs | 4:60be78a172c2 | 46 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") |
dudnwjs | 4:60be78a172c2 | 47 | #define APP_DIS_SYSTEM_ID_LEN (8) |
dudnwjs | 4:60be78a172c2 | 48 | |
dudnwjs | 4:60be78a172c2 | 49 | #define APP_DIS_SW_REV DA14583_REFDES_SW_VERSION |
dudnwjs | 4:60be78a172c2 | 50 | #define APP_DIS_FIRM_REV DA14583_SW_VERSION |
dudnwjs | 4:60be78a172c2 | 51 | #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) |
dudnwjs | 4:60be78a172c2 | 52 | /// Advertising minimum interval |
dudnwjs | 4:60be78a172c2 | 53 | #define APP_ADV_INT_MIN 0x800 |
dudnwjs | 4:60be78a172c2 | 54 | /// Advertising maximum interval |
dudnwjs | 4:60be78a172c2 | 55 | #define APP_ADV_INT_MAX 0x800 |
dudnwjs | 4:60be78a172c2 | 56 | /// Advertising channel map |
dudnwjs | 4:60be78a172c2 | 57 | #define APP_ADV_CHMAP 0x07 |
dudnwjs | 4:60be78a172c2 | 58 | /// Advertising data maximal length |
dudnwjs | 4:60be78a172c2 | 59 | #define APP_ADV_DATA_MAX_SIZE (ADV_DATA_LEN - 3) |
dudnwjs | 4:60be78a172c2 | 60 | /// Scan Response data maximal length |
dudnwjs | 4:60be78a172c2 | 61 | #define APP_SCAN_RESP_DATA_MAX_SIZE (SCAN_RSP_DATA_LEN) |
dudnwjs | 12:e3d3676753cc | 62 | #define APP_DFLT_ADV_DATA "\x09\x03\xF0\x18\xFF\x18\x0A\x18\xF1\x18" |
dudnwjs | 4:60be78a172c2 | 63 | #define APP_DFLT_ADV_DATA_LEN (8+2) |
dudnwjs | 4:60be78a172c2 | 64 | #define APP_SCNRSP_DATA "\x09\xFF\x00\x60\x52\x57\x2D\x42\x4C\x45" |
dudnwjs | 4:60be78a172c2 | 65 | #define APP_SCNRSP_DATA_LENGTH (10) |
dudnwjs | 13:e714e2971c49 | 66 | #define APP_DFLT_DEVICE_NAME ("SC-Lamp-02") |
dudnwjs | 5:e11b23f9aacc | 67 | |
dudnwjs | 5:e11b23f9aacc | 68 | |
dudnwjs | 5:e11b23f9aacc | 69 | typedef struct |
dudnwjs | 5:e11b23f9aacc | 70 | { |
dudnwjs | 5:e11b23f9aacc | 71 | unsigned char free; |
dudnwjs | 5:e11b23f9aacc | 72 | struct bd_addr adv_addr; |
dudnwjs | 5:e11b23f9aacc | 73 | unsigned short conidx; |
dudnwjs | 5:e11b23f9aacc | 74 | unsigned short conhdl; |
dudnwjs | 5:e11b23f9aacc | 75 | unsigned char idx; |
dudnwjs | 5:e11b23f9aacc | 76 | unsigned char rssi; |
dudnwjs | 5:e11b23f9aacc | 77 | unsigned char data_len; |
dudnwjs | 5:e11b23f9aacc | 78 | unsigned char data[ADV_DATA_LEN + 1]; |
dudnwjs | 5:e11b23f9aacc | 79 | |
dudnwjs | 5:e11b23f9aacc | 80 | } ble_dev; |
dudnwjs | 5:e11b23f9aacc | 81 | |
dudnwjs | 5:e11b23f9aacc | 82 | #define MAX_SCAN_DEVICES 9 |
dudnwjs | 4:60be78a172c2 | 83 | |
dudnwjs | 5:e11b23f9aacc | 84 | enum |
dudnwjs | 5:e11b23f9aacc | 85 | { |
dudnwjs | 5:e11b23f9aacc | 86 | /// Idle state |
dudnwjs | 5:e11b23f9aacc | 87 | APP_IDLE, |
dudnwjs | 5:e11b23f9aacc | 88 | /// Scanning state |
dudnwjs | 5:e11b23f9aacc | 89 | APP_CONNECTABLE, |
dudnwjs | 5:e11b23f9aacc | 90 | /// Connected state |
dudnwjs | 5:e11b23f9aacc | 91 | APP_CONNECTED, |
dudnwjs | 5:e11b23f9aacc | 92 | /// Number of defined states. |
dudnwjs | 5:e11b23f9aacc | 93 | APP_STATE_MAX, |
dudnwjs | 5:e11b23f9aacc | 94 | /// Scanning state |
dudnwjs | 5:e11b23f9aacc | 95 | APP_SCAN, |
dudnwjs | 5:e11b23f9aacc | 96 | }; |
dudnwjs | 5:e11b23f9aacc | 97 | |
dudnwjs | 5:e11b23f9aacc | 98 | struct app_env_tag |
dudnwjs | 5:e11b23f9aacc | 99 | { |
dudnwjs | 5:e11b23f9aacc | 100 | unsigned char state; |
dudnwjs | 5:e11b23f9aacc | 101 | unsigned char num_of_devices; |
dudnwjs | 5:e11b23f9aacc | 102 | ble_dev devices[MAX_SCAN_DEVICES]; |
dudnwjs | 5:e11b23f9aacc | 103 | }; |
dudnwjs | 5:e11b23f9aacc | 104 | |
dudnwjs | 5:e11b23f9aacc | 105 | extern struct app_env_tag app_env; |
dudnwjs | 3:1e70387e1337 | 106 | |
dudnwjs | 9:fcf91f563147 | 107 | /** |
dudnwjs | 9:fcf91f563147 | 108 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 109 | * @brief Send Reset request to GAPM task. |
dudnwjs | 9:fcf91f563147 | 110 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 111 | * @return void. |
dudnwjs | 9:fcf91f563147 | 112 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 113 | */ |
dudnwjs | 3:1e70387e1337 | 114 | void app_rst_gap(BleMsgHandler *BMH); |
dudnwjs | 9:fcf91f563147 | 115 | /** |
dudnwjs | 9:fcf91f563147 | 116 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 117 | * @brief Send enable request to DISS profile task. |
dudnwjs | 9:fcf91f563147 | 118 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 119 | * @return void. |
dudnwjs | 9:fcf91f563147 | 120 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 121 | */ |
dudnwjs | 4:60be78a172c2 | 122 | void app_diss_db_create(BleMsgHandler* BMH); |
dudnwjs | 9:fcf91f563147 | 123 | /** |
dudnwjs | 9:fcf91f563147 | 124 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 125 | * @brief Send enable request to FOTA profile task. |
dudnwjs | 9:fcf91f563147 | 126 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 127 | * @return void. |
dudnwjs | 9:fcf91f563147 | 128 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 129 | */ |
dudnwjs | 5:e11b23f9aacc | 130 | void app_fota_server_db_create(BleMsgHandler* BMH); |
dudnwjs | 9:fcf91f563147 | 131 | /** |
dudnwjs | 9:fcf91f563147 | 132 | **************************************************************************************** |
dudnwjs | 12:e3d3676753cc | 133 | * @brief Send enable request to Fan Control profile task. |
dudnwjs | 12:e3d3676753cc | 134 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 12:e3d3676753cc | 135 | * @return void. |
dudnwjs | 12:e3d3676753cc | 136 | **************************************************************************************** |
dudnwjs | 12:e3d3676753cc | 137 | */ |
dudnwjs | 12:e3d3676753cc | 138 | void app_fan_control_db_create(BleMsgHandler* BMH); |
dudnwjs | 12:e3d3676753cc | 139 | /** |
dudnwjs | 12:e3d3676753cc | 140 | **************************************************************************************** |
dudnwjs | 13:e714e2971c49 | 141 | * @brief Send enable request to Lamp Control profile task. |
dudnwjs | 13:e714e2971c49 | 142 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 13:e714e2971c49 | 143 | * @return void. |
dudnwjs | 13:e714e2971c49 | 144 | **************************************************************************************** |
dudnwjs | 13:e714e2971c49 | 145 | */ |
dudnwjs | 13:e714e2971c49 | 146 | void app_lamp_control_db_create(BleMsgHandler* BMH); |
dudnwjs | 13:e714e2971c49 | 147 | /** |
dudnwjs | 13:e714e2971c49 | 148 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 149 | * @brief Send Start Advertising command to GAPM task. |
dudnwjs | 9:fcf91f563147 | 150 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 151 | * @return void. |
dudnwjs | 9:fcf91f563147 | 152 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 153 | */ |
dudnwjs | 4:60be78a172c2 | 154 | void app_adv_start(BleMsgHandler* BMH); |
dudnwjs | 9:fcf91f563147 | 155 | /** |
dudnwjs | 9:fcf91f563147 | 156 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 157 | * @brief Set Bondabe mode. |
dudnwjs | 9:fcf91f563147 | 158 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 159 | * @return void. |
dudnwjs | 9:fcf91f563147 | 160 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 161 | */ |
dudnwjs | 4:60be78a172c2 | 162 | void app_set_mode(BleMsgHandler* BMH); |
dudnwjs | 9:fcf91f563147 | 163 | /** |
dudnwjs | 9:fcf91f563147 | 164 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 165 | * @brief Send enable request to DISS profile task. |
dudnwjs | 9:fcf91f563147 | 166 | * @param[in] device Ble device info |
dudnwjs | 9:fcf91f563147 | 167 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 168 | * @return void. |
dudnwjs | 9:fcf91f563147 | 169 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 170 | */ |
dudnwjs | 9:fcf91f563147 | 171 | void app_dis_enable(ble_dev *device,BleMsgHandler* BMH); |
dudnwjs | 9:fcf91f563147 | 172 | /** |
dudnwjs | 9:fcf91f563147 | 173 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 174 | * @brief Send enable request to FOTA profile task. |
dudnwjs | 9:fcf91f563147 | 175 | * @param[in] device Ble device info |
dudnwjs | 9:fcf91f563147 | 176 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 177 | * @return void. |
dudnwjs | 9:fcf91f563147 | 178 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 179 | */ |
dudnwjs | 5:e11b23f9aacc | 180 | void app_fota_server_enable(ble_dev *device,BleMsgHandler* BMH); |
dudnwjs | 9:fcf91f563147 | 181 | /** |
dudnwjs | 9:fcf91f563147 | 182 | **************************************************************************************** |
dudnwjs | 12:e3d3676753cc | 183 | * @brief Send enable request to fan_control profile task. |
dudnwjs | 12:e3d3676753cc | 184 | * @param[in] device Ble device info |
dudnwjs | 12:e3d3676753cc | 185 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 12:e3d3676753cc | 186 | * @return void. |
dudnwjs | 12:e3d3676753cc | 187 | **************************************************************************************** |
dudnwjs | 12:e3d3676753cc | 188 | */ |
dudnwjs | 12:e3d3676753cc | 189 | void app_fan_control_enable(ble_dev *device,BleMsgHandler* BMH); |
dudnwjs | 12:e3d3676753cc | 190 | /** |
dudnwjs | 12:e3d3676753cc | 191 | **************************************************************************************** |
dudnwjs | 13:e714e2971c49 | 192 | * @brief Send enable request to Lamp_control profile task. |
dudnwjs | 13:e714e2971c49 | 193 | * @param[in] device Ble device info |
dudnwjs | 13:e714e2971c49 | 194 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 13:e714e2971c49 | 195 | * @return void. |
dudnwjs | 13:e714e2971c49 | 196 | **************************************************************************************** |
dudnwjs | 13:e714e2971c49 | 197 | */ |
dudnwjs | 13:e714e2971c49 | 198 | void app_lamp_control_enable(ble_dev *device,BleMsgHandler* BMH); |
dudnwjs | 13:e714e2971c49 | 199 | /** |
dudnwjs | 13:e714e2971c49 | 200 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 201 | * @brief Send connection confirmation. |
dudnwjs | 9:fcf91f563147 | 202 | * param[in] auth Authentication requirements. |
dudnwjs | 9:fcf91f563147 | 203 | * @param[in] device Ble device info |
dudnwjs | 9:fcf91f563147 | 204 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 205 | * @return void. |
dudnwjs | 9:fcf91f563147 | 206 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 207 | */ |
dudnwjs | 5:e11b23f9aacc | 208 | void app_connect_confirm(uint8_t auth,ble_dev *device,BleMsgHandler* BMH); |
dudnwjs | 9:fcf91f563147 | 209 | /** |
dudnwjs | 9:fcf91f563147 | 210 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 211 | * @brief Send the GAPC_DISCONNECT_IND message to a task. |
dudnwjs | 9:fcf91f563147 | 212 | * @param[in] dst Task id of the destination task. |
dudnwjs | 9:fcf91f563147 | 213 | * @param[in] conhdl The conhdl parameter of the GAPC_DISCONNECT_IND message. |
dudnwjs | 9:fcf91f563147 | 214 | * @param[in] reason The reason parameter of the GAPC_DISCONNECT_IND message. |
dudnwjs | 9:fcf91f563147 | 215 | * @param[in] BMH Ble Message Handler class reference |
dudnwjs | 9:fcf91f563147 | 216 | * @return void. |
dudnwjs | 9:fcf91f563147 | 217 | **************************************************************************************** |
dudnwjs | 9:fcf91f563147 | 218 | */ |
dudnwjs | 5:e11b23f9aacc | 219 | void app_send_disconnect(uint16_t dst, uint16_t conhdl, uint8_t reason,BleMsgHandler* BMH); |
dudnwjs | 5:e11b23f9aacc | 220 | |
dudnwjs | 3:1e70387e1337 | 221 | }//namespace |
dudnwjs | 3:1e70387e1337 | 222 | |
dudnwjs | 9:fcf91f563147 | 223 | /// @} dialog_fota module |
dudnwjs | 9:fcf91f563147 | 224 | |
dudnwjs | 3:1e70387e1337 | 225 | #endif//APP_H |