sevencore fota solution development project
dialog_fota/app.h@6:8dd20294b2aa, 2015-07-17 (annotated)
- Committer:
- dudnwjs
- Date:
- Fri Jul 17 14:04:12 2015 +0000
- Revision:
- 6:8dd20294b2aa
- Parent:
- 5:e11b23f9aacc
- Child:
- 8:9eec2c246a85
EXT DEMO FILE OPEN COMPLETE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudnwjs | 3:1e70387e1337 | 1 | #ifndef APP_H |
dudnwjs | 3:1e70387e1337 | 2 | #define APP_H |
dudnwjs | 3:1e70387e1337 | 3 | |
dudnwjs | 3:1e70387e1337 | 4 | #include "BleMsgHandler.h" |
dudnwjs | 4:60be78a172c2 | 5 | #include "app_sw_version.h" |
dudnwjs | 4:60be78a172c2 | 6 | #include "diss_task.h" |
dudnwjs | 4:60be78a172c2 | 7 | #include "dialog_fota_config.h" |
dudnwjs | 3:1e70387e1337 | 8 | |
dudnwjs | 3:1e70387e1337 | 9 | namespace sevencore_fota{ |
dudnwjs | 3:1e70387e1337 | 10 | |
dudnwjs | 5:e11b23f9aacc | 11 | |
dudnwjs | 5:e11b23f9aacc | 12 | |
dudnwjs | 5:e11b23f9aacc | 13 | #define KE_IDX_GET(uint16_t) (((uint16_t) >> 8) & 0xFF) |
dudnwjs | 5:e11b23f9aacc | 14 | #define KE_BUILD_ID(type, index) ( (uint16_t)(((index) << 8)|(type)) ) |
dudnwjs | 5:e11b23f9aacc | 15 | |
dudnwjs | 4:60be78a172c2 | 16 | /* |
dudnwjs | 4:60be78a172c2 | 17 | * DISS DEFINITIONS |
dudnwjs | 4:60be78a172c2 | 18 | **************************************************************************************** |
dudnwjs | 4:60be78a172c2 | 19 | */ |
dudnwjs | 4:60be78a172c2 | 20 | /// Manufacturer Name (up to 18 chars) |
dudnwjs | 5:e11b23f9aacc | 21 | #define APP_DIS_MANUFACTURER_NAME_STR ("SevenCore") |
dudnwjs | 5:e11b23f9aacc | 22 | #define APP_DIS_MANUFACTURER_NAME_STR_LEN (9) |
dudnwjs | 4:60be78a172c2 | 23 | /// Model Number String (up to 18 chars) |
dudnwjs | 6:8dd20294b2aa | 24 | #define APP_DIS_MODEL_NB_STR ("DA14588") |
dudnwjs | 4:60be78a172c2 | 25 | #define APP_DIS_MODEL_NB_STR_LEN (7) |
dudnwjs | 4:60be78a172c2 | 26 | /// System ID - LSB -> MSB (FIXME) |
dudnwjs | 6:8dd20294b2aa | 27 | #define APP_DIS_SERIAL_NB_STR ("123-789") |
dudnwjs | 6:8dd20294b2aa | 28 | #define APP_DIS_SERIAL_NB_STR_LEN (7) |
dudnwjs | 5:e11b23f9aacc | 29 | /// System ID - LSB -> MSB (FIXME) |
dudnwjs | 4:60be78a172c2 | 30 | #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") |
dudnwjs | 4:60be78a172c2 | 31 | #define APP_DIS_SYSTEM_ID_LEN (8) |
dudnwjs | 4:60be78a172c2 | 32 | |
dudnwjs | 4:60be78a172c2 | 33 | #define APP_DIS_SW_REV DA14583_REFDES_SW_VERSION |
dudnwjs | 4:60be78a172c2 | 34 | #define APP_DIS_FIRM_REV DA14583_SW_VERSION |
dudnwjs | 4:60be78a172c2 | 35 | #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 | 36 | /// Advertising minimum interval |
dudnwjs | 4:60be78a172c2 | 37 | #define APP_ADV_INT_MIN 0x800 |
dudnwjs | 4:60be78a172c2 | 38 | /// Advertising maximum interval |
dudnwjs | 4:60be78a172c2 | 39 | #define APP_ADV_INT_MAX 0x800 |
dudnwjs | 4:60be78a172c2 | 40 | /// Advertising channel map |
dudnwjs | 4:60be78a172c2 | 41 | #define APP_ADV_CHMAP 0x07 |
dudnwjs | 4:60be78a172c2 | 42 | /// Advertising data maximal length |
dudnwjs | 4:60be78a172c2 | 43 | #define APP_ADV_DATA_MAX_SIZE (ADV_DATA_LEN - 3) |
dudnwjs | 4:60be78a172c2 | 44 | /// Scan Response data maximal length |
dudnwjs | 4:60be78a172c2 | 45 | #define APP_SCAN_RESP_DATA_MAX_SIZE (SCAN_RSP_DATA_LEN) |
dudnwjs | 4:60be78a172c2 | 46 | #define APP_DFLT_ADV_DATA "\x09\x03\x03\x18\x02\x18\x04\x18\xF5\xFE" |
dudnwjs | 4:60be78a172c2 | 47 | #define APP_DFLT_ADV_DATA_LEN (8+2) |
dudnwjs | 4:60be78a172c2 | 48 | #define APP_SCNRSP_DATA "\x09\xFF\x00\x60\x52\x57\x2D\x42\x4C\x45" |
dudnwjs | 4:60be78a172c2 | 49 | #define APP_SCNRSP_DATA_LENGTH (10) |
dudnwjs | 6:8dd20294b2aa | 50 | #define APP_DFLT_DEVICE_NAME ("DA14588") |
dudnwjs | 5:e11b23f9aacc | 51 | |
dudnwjs | 5:e11b23f9aacc | 52 | |
dudnwjs | 5:e11b23f9aacc | 53 | typedef struct |
dudnwjs | 5:e11b23f9aacc | 54 | { |
dudnwjs | 5:e11b23f9aacc | 55 | unsigned char free; |
dudnwjs | 5:e11b23f9aacc | 56 | struct bd_addr adv_addr; |
dudnwjs | 5:e11b23f9aacc | 57 | unsigned short conidx; |
dudnwjs | 5:e11b23f9aacc | 58 | unsigned short conhdl; |
dudnwjs | 5:e11b23f9aacc | 59 | unsigned char idx; |
dudnwjs | 5:e11b23f9aacc | 60 | unsigned char rssi; |
dudnwjs | 5:e11b23f9aacc | 61 | unsigned char data_len; |
dudnwjs | 5:e11b23f9aacc | 62 | unsigned char data[ADV_DATA_LEN + 1]; |
dudnwjs | 5:e11b23f9aacc | 63 | |
dudnwjs | 5:e11b23f9aacc | 64 | } ble_dev; |
dudnwjs | 5:e11b23f9aacc | 65 | |
dudnwjs | 5:e11b23f9aacc | 66 | #define MAX_SCAN_DEVICES 9 |
dudnwjs | 4:60be78a172c2 | 67 | |
dudnwjs | 5:e11b23f9aacc | 68 | enum |
dudnwjs | 5:e11b23f9aacc | 69 | { |
dudnwjs | 5:e11b23f9aacc | 70 | /// Idle state |
dudnwjs | 5:e11b23f9aacc | 71 | APP_IDLE, |
dudnwjs | 5:e11b23f9aacc | 72 | /// Scanning state |
dudnwjs | 5:e11b23f9aacc | 73 | APP_CONNECTABLE, |
dudnwjs | 5:e11b23f9aacc | 74 | /// Connected state |
dudnwjs | 5:e11b23f9aacc | 75 | APP_CONNECTED, |
dudnwjs | 5:e11b23f9aacc | 76 | /// Number of defined states. |
dudnwjs | 5:e11b23f9aacc | 77 | APP_STATE_MAX, |
dudnwjs | 5:e11b23f9aacc | 78 | /// Scanning state |
dudnwjs | 5:e11b23f9aacc | 79 | APP_SCAN, |
dudnwjs | 5:e11b23f9aacc | 80 | }; |
dudnwjs | 5:e11b23f9aacc | 81 | |
dudnwjs | 5:e11b23f9aacc | 82 | struct app_env_tag |
dudnwjs | 5:e11b23f9aacc | 83 | { |
dudnwjs | 5:e11b23f9aacc | 84 | unsigned char state; |
dudnwjs | 5:e11b23f9aacc | 85 | unsigned char num_of_devices; |
dudnwjs | 5:e11b23f9aacc | 86 | ble_dev devices[MAX_SCAN_DEVICES]; |
dudnwjs | 5:e11b23f9aacc | 87 | }; |
dudnwjs | 5:e11b23f9aacc | 88 | |
dudnwjs | 5:e11b23f9aacc | 89 | extern struct app_env_tag app_env; |
dudnwjs | 3:1e70387e1337 | 90 | |
dudnwjs | 3:1e70387e1337 | 91 | void app_rst_gap(BleMsgHandler *BMH); |
dudnwjs | 4:60be78a172c2 | 92 | void app_diss_db_create(BleMsgHandler* BMH); |
dudnwjs | 5:e11b23f9aacc | 93 | void app_fota_server_db_create(BleMsgHandler* BMH); |
dudnwjs | 4:60be78a172c2 | 94 | void app_adv_start(BleMsgHandler* BMH); |
dudnwjs | 4:60be78a172c2 | 95 | void app_set_mode(BleMsgHandler* BMH); |
dudnwjs | 5:e11b23f9aacc | 96 | void app_fota_server_enable(ble_dev *device,BleMsgHandler* BMH); |
dudnwjs | 5:e11b23f9aacc | 97 | void app_dis_enable(ble_dev *device,BleMsgHandler* BMH); |
dudnwjs | 5:e11b23f9aacc | 98 | void app_connect_confirm(uint8_t auth,ble_dev *device,BleMsgHandler* BMH); |
dudnwjs | 5:e11b23f9aacc | 99 | void app_send_disconnect(uint16_t dst, uint16_t conhdl, uint8_t reason,BleMsgHandler* BMH); |
dudnwjs | 5:e11b23f9aacc | 100 | |
dudnwjs | 3:1e70387e1337 | 101 | |
dudnwjs | 3:1e70387e1337 | 102 | |
dudnwjs | 3:1e70387e1337 | 103 | |
dudnwjs | 3:1e70387e1337 | 104 | }//namespace |
dudnwjs | 3:1e70387e1337 | 105 | |
dudnwjs | 3:1e70387e1337 | 106 | #endif//APP_H |