BLE fota Lamp Demo
Dependencies: mbed-rtos mbed mbed_fota_fan_control
Fork of mbed_fota_fan_control by
Diff: dialog_fota/app.cpp
- Revision:
- 9:fcf91f563147
- Parent:
- 6:8dd20294b2aa
- Child:
- 12:e3d3676753cc
diff -r 9eec2c246a85 -r fcf91f563147 dialog_fota/app.cpp --- a/dialog_fota/app.cpp Thu Aug 20 05:16:55 2015 +0000 +++ b/dialog_fota/app.cpp Mon Aug 24 02:29:16 2015 +0000 @@ -1,3 +1,12 @@ +/** + * @file app.cpp + * @brief Application entry point + * Copyright 2015 SEVENCORE Co., Ltd. + * + * @author HyeongJun Kim + * @version 1.0.0 + * @date 2015-08-17 +*/ #include "app.h" #include "gapm_task.h" #include "dialog_fota_config.h" @@ -5,9 +14,22 @@ #include "fota_server_task.h" namespace sevencore_fota{ - +/** + **************************************************************************************** + * @addtogroup dialog_fota module + * @brief Application entry point function definition. + * + * @{ + **************************************************************************************** + */ struct app_env_tag app_env; - +/** + **************************************************************************************** + * @brief Send Reset request to GAPM task. + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ void app_rst_gap(BleMsgHandler *BMH) { struct gapm_reset_cmd gm_cmd; @@ -34,7 +56,13 @@ return; } - +/** + **************************************************************************************** + * @brief Send enable request to DISS profile task. + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ void app_diss_db_create(BleMsgHandler* BMH) { uint8_t *msg; @@ -48,7 +76,13 @@ BMH->BleMsgAlloc(DISS_CREATE_DB_REQ,TASK_DISS, TASK_GTL,sizeof(struct diss_create_db_req),&req,msg); BMH->BleSendMsg(msg,msg_size); } - +/** + **************************************************************************************** + * @brief Send enable request to FOTA profile task. + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ void app_fota_server_db_create(BleMsgHandler* BMH) { uint8_t *msg; @@ -62,7 +96,13 @@ BMH->BleMsgAlloc(FOTA_SERVER_CREATE_DB_REQ,TASK_FOTA_SERVER, TASK_GTL,sizeof(struct fota_server_create_db_req),&req,msg); BMH->BleSendMsg(msg,msg_size); } - +/** + **************************************************************************************** + * @brief Send Start Advertising command to GAPM task. + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ void app_adv_start(BleMsgHandler* BMH) { uint8_t device_name_length; @@ -161,7 +201,13 @@ return; } - +/** + **************************************************************************************** + * @brief Set Bondabe mode. + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ void app_set_mode(BleMsgHandler* BMH) { uint8_t *msg; @@ -197,24 +243,15 @@ return; } - - -void app_fota_server_enable(ble_dev *device,BleMsgHandler* BMH) -{ - uint8_t *msg; - struct fota_server_enable_req req; - unsigned short msg_size = 1 + sizeof(ble_hdr) + sizeof(struct fota_server_enable_req); - req.conhdl = device->conhdl; - req.sec_lvl = 1; - - msg = new uint8_t[msg_size]; - - // Send the message - BMH->BleMsgAlloc(FOTA_SERVER_ENABLE_REQ, TASK_FOTA_SERVER, TASK_GTL,sizeof(struct fota_server_enable_req),&req,msg); - BMH->BleSendMsg(msg,msg_size); -} - -void app_dis_enable(ble_dev *device,BleMsgHandler* BMH) +/** + **************************************************************************************** + * @brief Send enable request to DISS profile task. + * @param[in] device Ble device info + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ + void app_dis_enable(ble_dev *device,BleMsgHandler* BMH) { uint8_t *msg; // Allocate the message @@ -231,7 +268,37 @@ BMH->BleMsgAlloc(DISS_ENABLE_REQ,TASK_DISS, TASK_GTL, sizeof(struct diss_enable_req),&req,msg); BMH->BleSendMsg(msg,msg_size); } +/** + **************************************************************************************** + * @brief Send enable request to FOTA profile task. + * @param[in] device Ble device info + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ +void app_fota_server_enable(ble_dev *device,BleMsgHandler* BMH) +{ + uint8_t *msg; + struct fota_server_enable_req req; + unsigned short msg_size = 1 + sizeof(ble_hdr) + sizeof(struct fota_server_enable_req); + req.conhdl = device->conhdl; + req.sec_lvl = 1; + + msg = new uint8_t[msg_size]; + // Send the message + BMH->BleMsgAlloc(FOTA_SERVER_ENABLE_REQ, TASK_FOTA_SERVER, TASK_GTL,sizeof(struct fota_server_enable_req),&req,msg); + BMH->BleSendMsg(msg,msg_size); +} +/** + **************************************************************************************** + * @brief Send connection confirmation. + * param[in] auth Authentication requirements. + * @param[in] device Ble device info + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ void app_connect_confirm(uint8_t auth,ble_dev *device,BleMsgHandler* BMH) { uint8_t *msg; @@ -247,7 +314,16 @@ BMH->BleMsgAlloc(GAPC_CONNECTION_CFM, KE_BUILD_ID(TASK_GAPC,device->conidx), TASK_GTL,sizeof (struct gapc_connection_cfm),&cfm,msg); BMH->BleSendMsg(msg,msg_size); } - +/** + **************************************************************************************** + * @brief Send the GAPC_DISCONNECT_IND message to a task. + * @param[in] dst Task id of the destination task. + * @param[in] conhdl The conhdl parameter of the GAPC_DISCONNECT_IND message. + * @param[in] reason The reason parameter of the GAPC_DISCONNECT_IND message. + * @param[in] BMH Ble Message Handler class reference + * @return void. + **************************************************************************************** + */ void app_send_disconnect(uint16_t dst, uint16_t conhdl, uint8_t reason,BleMsgHandler* BMH) { uint8_t *msg; @@ -264,5 +340,6 @@ BMH->BleSendMsg(msg,msg_size); } +}//namespace -}//namespace +/// @} dialog_fota module