BLE fota Robot Demo
Dependencies: mbed-rtos mbed mbed_fota_fan_control
Fork of mbed_fota_lamp_control by
Diff: dialog_fota/app.h
- Revision:
- 5:e11b23f9aacc
- Parent:
- 4:60be78a172c2
- Child:
- 6:8dd20294b2aa
--- a/dialog_fota/app.h Wed Jun 24 08:50:07 2015 +0000 +++ b/dialog_fota/app.h Mon Jul 13 06:32:05 2015 +0000 @@ -8,17 +8,25 @@ namespace sevencore_fota{ + + +#define KE_IDX_GET(uint16_t) (((uint16_t) >> 8) & 0xFF) +#define KE_BUILD_ID(type, index) ( (uint16_t)(((index) << 8)|(type)) ) + /* * DISS DEFINITIONS **************************************************************************************** */ /// Manufacturer Name (up to 18 chars) -#define APP_DIS_MANUFACTURER_NAME ("Dialog Semi") -#define APP_DIS_MANUFACTURER_NAME_LEN (11) +#define APP_DIS_MANUFACTURER_NAME_STR ("SevenCore") +#define APP_DIS_MANUFACTURER_NAME_STR_LEN (9) /// Model Number String (up to 18 chars) -#define APP_DIS_MODEL_NB_STR ("DA14580") +#define APP_DIS_MODEL_NB_STR ("DA14583") #define APP_DIS_MODEL_NB_STR_LEN (7) /// System ID - LSB -> MSB (FIXME) +#define APP_DIS_SERIAL_NB_STR ("1234-00-6789") +#define APP_DIS_SERIAL_NB_STR_LEN (12) +/// System ID - LSB -> MSB (FIXME) #define APP_DIS_SYSTEM_ID ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE") #define APP_DIS_SYSTEM_ID_LEN (8) @@ -39,13 +47,57 @@ #define APP_DFLT_ADV_DATA_LEN (8+2) #define APP_SCNRSP_DATA "\x09\xFF\x00\x60\x52\x57\x2D\x42\x4C\x45" #define APP_SCNRSP_DATA_LENGTH (10) -#define APP_DFLT_DEVICE_NAME ("EXT_FOTA") +#define APP_DFLT_DEVICE_NAME ("DA14583") + + +typedef struct +{ + unsigned char free; + struct bd_addr adv_addr; + unsigned short conidx; + unsigned short conhdl; + unsigned char idx; + unsigned char rssi; + unsigned char data_len; + unsigned char data[ADV_DATA_LEN + 1]; + +} ble_dev; + +#define MAX_SCAN_DEVICES 9 +enum +{ + /// Idle state + APP_IDLE, + /// Scanning state + APP_CONNECTABLE, + /// Connected state + APP_CONNECTED, + /// Number of defined states. + APP_STATE_MAX, + /// Scanning state + APP_SCAN, +}; + +struct app_env_tag +{ + unsigned char state; + unsigned char num_of_devices; + ble_dev devices[MAX_SCAN_DEVICES]; +}; + +extern struct app_env_tag app_env; void app_rst_gap(BleMsgHandler *BMH); void app_diss_db_create(BleMsgHandler* BMH); +void app_fota_server_db_create(BleMsgHandler* BMH); void app_adv_start(BleMsgHandler* BMH); void app_set_mode(BleMsgHandler* BMH); +void app_fota_server_enable(ble_dev *device,BleMsgHandler* BMH); +void app_dis_enable(ble_dev *device,BleMsgHandler* BMH); +void app_connect_confirm(uint8_t auth,ble_dev *device,BleMsgHandler* BMH); +void app_send_disconnect(uint16_t dst, uint16_t conhdl, uint8_t reason,BleMsgHandler* BMH); +