BLE fota Lamp Demo

Dependencies:   mbed-rtos mbed mbed_fota_fan_control

Fork of mbed_fota_fan_control by KIM HyoengJun

Files at this revision

API Documentation at this revision

Comitter:
dudnwjs
Date:
Tue Oct 13 06:35:19 2015 +0000
Parent:
12:e3d3676753cc
Commit message:
lamp demo;

Changed in this revision

dialog_fota/app.cpp Show annotated file Show diff for this revision Revisions of this file
dialog_fota/app.h Show annotated file Show diff for this revision Revisions of this file
dialog_fota/app_task.cpp Show annotated file Show diff for this revision Revisions of this file
dialog_fota/app_task.h Show annotated file Show diff for this revision Revisions of this file
dialog_fota/dialog_fota_config.h Show annotated file Show diff for this revision Revisions of this file
dialog_fota/lamp_control_task.h Show annotated file Show diff for this revision Revisions of this file
ext_fota/BleMsgHandler.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_fota_lamp_control.lib Show annotated file Show diff for this revision Revisions of this file
diff -r e3d3676753cc -r e714e2971c49 dialog_fota/app.cpp
--- a/dialog_fota/app.cpp	Wed Sep 02 07:44:29 2015 +0000
+++ b/dialog_fota/app.cpp	Tue Oct 13 06:35:19 2015 +0000
@@ -13,6 +13,8 @@
 #include "diss_task.h"
 #include "fota_server_task.h"
 #include "fan_control_task.h"
+#include "lamp_control_task.h"
+
 
 namespace sevencore_fota{
 /**
@@ -119,6 +121,26 @@
 }
 /**
  ****************************************************************************************
+ * @brief Send enable request to Lamp Control profile task.
+ * @param[in] BMH     Ble Message Handler class reference
+ * @return void.
+ ****************************************************************************************
+ */
+void app_lamp_control_db_create(BleMsgHandler* BMH)
+{
+    uint8_t *msg;
+    // Add fan_control service table in the database
+    struct lamp_control_create_db_req req;
+    unsigned short msg_size = 1 + sizeof(ble_hdr) + sizeof(struct lamp_control_create_db_req);
+    req.features = 0x000F;
+    
+    msg = new uint8_t[msg_size];
+    
+    BMH->BleMsgAlloc(LAMP_CONTROL_CREATE_DB_REQ,TASK_LAMP_CONTROL, TASK_GTL,sizeof(struct lamp_control_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.
@@ -335,6 +357,28 @@
 }
 /**
  ****************************************************************************************
+ * @brief Send enable request to lamp_control profile task.
+ * @param[in] device  Ble device info
+ * @param[in] BMH     Ble Message Handler class reference
+ * @return void.
+ ****************************************************************************************
+ */
+void app_lamp_control_enable(ble_dev *device,BleMsgHandler* BMH)
+{
+    uint8_t *msg;
+    struct lamp_control_enable_req req;
+    unsigned short msg_size = 1 + sizeof(ble_hdr) + sizeof(struct lamp_control_enable_req);
+    req.conhdl = device->conhdl;
+    req.sec_lvl = 1;
+    
+    msg = new uint8_t[msg_size];
+
+    // Send the message
+    BMH->BleMsgAlloc(LAMP_CONTROL_ENABLE_REQ, TASK_LAMP_CONTROL, TASK_GTL,sizeof(struct lamp_control_enable_req),&req,msg);
+    BMH->BleSendMsg(msg,msg_size);
+}
+/**
+ ****************************************************************************************
  * @brief Send connection confirmation.
  * param[in] auth  Authentication requirements.
  * @param[in] device  Ble device info
diff -r e3d3676753cc -r e714e2971c49 dialog_fota/app.h
--- a/dialog_fota/app.h	Wed Sep 02 07:44:29 2015 +0000
+++ b/dialog_fota/app.h	Tue Oct 13 06:35:19 2015 +0000
@@ -37,10 +37,10 @@
 #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            ("SC-BF-EXT")
-#define APP_DIS_MODEL_NB_STR_LEN        (9)
+#define APP_DIS_MODEL_NB_STR            ("SC-Lamp-02")
+#define APP_DIS_MODEL_NB_STR_LEN        (10)
 /// System ID - LSB -> MSB (FIXME)
-#define APP_DIS_SERIAL_NB_STR               ("123-789")
+#define APP_DIS_SERIAL_NB_STR               ("123-456")
 #define APP_DIS_SERIAL_NB_STR_LEN           (7)
 /// System ID - LSB -> MSB (FIXME)
 #define APP_DIS_SYSTEM_ID               ("\x12\x34\x56\xFF\xFE\x9A\xBC\xDE")
@@ -63,7 +63,7 @@
 #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    ("FAN-00")
+#define APP_DFLT_DEVICE_NAME    ("SC-Lamp-02")
 
 
 typedef struct 
@@ -138,6 +138,14 @@
 void app_fan_control_db_create(BleMsgHandler* BMH);
 /**
  ****************************************************************************************
+ * @brief Send enable request to Lamp Control profile task.
+ * @param[in] BMH     Ble Message Handler class reference
+ * @return void.
+ ****************************************************************************************
+ */
+void app_lamp_control_db_create(BleMsgHandler* BMH);
+/**
+ ****************************************************************************************
  * @brief Send Start Advertising command to GAPM task.
  * @param[in] BMH     Ble Message Handler class reference
  * @return void.
@@ -181,6 +189,15 @@
 void app_fan_control_enable(ble_dev *device,BleMsgHandler* BMH);
 /**
  ****************************************************************************************
+ * @brief Send enable request to Lamp_control profile task.
+ * @param[in] device  Ble device info
+ * @param[in] BMH     Ble Message Handler class reference
+ * @return void.
+ ****************************************************************************************
+ */
+void app_lamp_control_enable(ble_dev *device,BleMsgHandler* BMH);
+/**
+ ****************************************************************************************
  * @brief Send connection confirmation.
  * param[in] auth  Authentication requirements.
  * @param[in] device  Ble device info
diff -r e3d3676753cc -r e714e2971c49 dialog_fota/app_task.cpp
--- a/dialog_fota/app_task.cpp	Wed Sep 02 07:44:29 2015 +0000
+++ b/dialog_fota/app_task.cpp	Tue Oct 13 06:35:19 2015 +0000
@@ -11,11 +11,16 @@
 #include "app.h"
 #include "fota_server_task.h"
 #include "fan_control_task.h"
+#include "lamp_control_task.h"
 #include "mbed.h"
 
 extern DigitalOut port18;//mid
 extern DigitalOut port19;//low
 extern DigitalOut port20;//high
+
+extern DigitalOut port21;//low
+extern DigitalOut port22;//high
+
 extern uint8_t Timer_flag;
 extern uint32_t Residual_Time;
 
@@ -334,7 +339,8 @@
     if (app_env.state == APP_IDLE)
     {
         //app_set_mode(BMH);
-        app_fan_control_db_create(BMH);
+        //app_fan_control_db_create(BMH);
+        app_lamp_control_db_create(BMH);
     }
     
     return 0;
@@ -552,9 +558,170 @@
         }
     }
 }
+/**
+ ****************************************************************************************
+ * @brief Handles the LAMP_CONTROL_CREATE_DB_CFM message.
+ *
+ * @param[in] msgid     Id of the message received.
+ * @param[in] param     Pointer to the parameters of the message.
+ * @param[in] dest_id   ID of the receiving task instance (TASK_GAP).
+ * @param[in] src_id    ID of the sending task instance.
+ * @param[in] BMH     Ble Message Handler class reference.
+ *
+ * @return If the message was consumed or not.
+ ****************************************************************************************
+ */
+void lamp_control_create_db_cfm_handler(unsigned short msgid,
+                                  struct lamp_control_create_db_cfm *param,
+                                  unsigned short dest_id,
+                                  unsigned short src_id,
+                                  BleMsgHandler* BMH)
+{
+    uint8_t fota_normal = 0;
+    uint8_t fota_normal_len = sizeof(fota_normal);
+    if (param->status == CO_ERROR_NO_ERROR)
+    {
+        // Initialization All Characteristic
+        {
+            uint8_t *msg;
+            struct lamp_control_set_char_val_req power_state_val;
+            unsigned short msg_size = 1+sizeof(ble_hdr)+ sizeof(lamp_control_set_char_val_req)-(4-LAMP_CONTROL_MIN_SIZE);
+            // Fill in the parameter structure
+            power_state_val.char_code     = LAMP_CONTROL_POWER_STATE_CHAR;
+            power_state_val.val_len       = LAMP_CONTROL_MIN_SIZE;
+            memcpy(&power_state_val.val[0], &fota_normal, fota_normal_len);
+            
+            msg = new uint8_t[msg_size];
+            
+            BMH->BleMsgAlloc(LAMP_CONTROL_SET_CHAR_VAL_REQ,TASK_LAMP_CONTROL, TASK_GTL,sizeof(struct lamp_control_set_char_val_req)-(4-FAN_CONTROL_MIN_SIZE),&power_state_val,msg );
+            // Send the message
+            BMH->BleSendMsg(msg,msg_size);
+            free(msg);
+        }
+        {
+            uint8_t *msg;
+            struct lamp_control_set_char_val_req light_intensity_val;
+            unsigned short msg_size = 1+sizeof(ble_hdr)+ sizeof(lamp_control_set_char_val_req)-(4-LAMP_CONTROL_MIN_SIZE);
+            // Fill in the parameter structure
+            light_intensity_val.char_code     = LAMP_CONTROL_LIGHT_INTENSITY_CHAR;
+            light_intensity_val.val_len       = LAMP_CONTROL_MIN_SIZE;
+            memcpy(&light_intensity_val.val[0], &fota_normal, fota_normal_len);
+            
+            msg = new uint8_t[msg_size];
+            
+            BMH->BleMsgAlloc(LAMP_CONTROL_SET_CHAR_VAL_REQ,TASK_LAMP_CONTROL, TASK_GTL,sizeof(struct lamp_control_set_char_val_req)-(4-LAMP_CONTROL_MIN_SIZE),&light_intensity_val,msg );
+            // Send the message
+            BMH->BleSendMsg(msg,msg_size);
+            free(msg);
+        }
+        {
+            uint8_t *msg;
+            struct lamp_control_set_char_val_req lamp_timer_val;
+            unsigned short msg_size = 1+sizeof(ble_hdr)+ sizeof(lamp_control_set_char_val_req)-(4-LAMP_CONTROL_MIN_SIZE);
+            // Fill in the parameter structure
+            lamp_timer_val.char_code     = LAMP_CONTROL_LAMP_TIMER_CHAR;
+            lamp_timer_val.val_len       = LAMP_CONTROL_MIN_SIZE;
+            memcpy(&lamp_timer_val.val[0], &fota_normal, fota_normal_len);
+            
+            msg = new uint8_t[msg_size];
+            
+            BMH->BleMsgAlloc(LAMP_CONTROL_SET_CHAR_VAL_REQ,TASK_LAMP_CONTROL, TASK_GTL,sizeof(struct lamp_control_set_char_val_req)-(4-LAMP_CONTROL_MIN_SIZE),&lamp_timer_val,msg );
+            // Send the message
+            BMH->BleSendMsg(msg,msg_size);
+            free(msg);
+        }
+        {
+            uint8_t *msg;
+            struct lamp_control_set_char_val_req residual_time_val;
+            unsigned short msg_size = 1+sizeof(ble_hdr)+ sizeof(lamp_control_set_char_val_req)-(4-LAMP_CONTROL_MAX_SIZE);
+            // Fill in the parameter structure
+            residual_time_val.char_code     = LAMP_CONTROL_RESIDUAL_TIME_CHAR;
+            residual_time_val.val_len       = LAMP_CONTROL_MAX_SIZE;
+            memcpy(&residual_time_val.val[0], &fota_normal, fota_normal_len*4);
+            
+            msg = new uint8_t[msg_size];
+            
+            BMH->BleMsgAlloc(LAMP_CONTROL_SET_CHAR_VAL_REQ,TASK_LAMP_CONTROL, TASK_GTL,sizeof(struct lamp_control_set_char_val_req)-(4-FAN_CONTROL_MAX_SIZE),&residual_time_val,msg );
+            // Send the message
+            BMH->BleSendMsg(msg,msg_size);
+            free(msg);
+        }
+    }
+    if (app_env.state == APP_IDLE)
+    {
+        app_set_mode(BMH);
+    }
+}
 
 /**
  ****************************************************************************************
+ * @brief Handles the LAMP_CONTROL_COMMAND_IND message.
+ *
+ * @param[in] msgid     Id of the message received.
+ * @param[in] param     Pointer to the parameters of the message.
+ * @param[in] dest_id   ID of the receiving task instance (TASK_GAP).
+ * @param[in] src_id    ID of the sending task instance.
+ * @param[in] BMH     Ble Message Handler class reference.
+ *
+ * @return If the message was consumed or not.
+ ****************************************************************************************
+ */
+void lamp_control_command_ind_handler(unsigned short msgid,
+                                  struct lamp_control_command_ind *param,
+                                  unsigned short dest_id,
+                                  unsigned short src_id,
+                                  BleMsgHandler* BMH)
+{
+    char str[30] = "\nLAMP remote control START!!\n";
+    BMH->HostPcPrint(str);
+    if( param->char_code == LAMP_CONTROL_POWER_STATE_CHAR){
+        if(param->command == 0){
+            Timer_flag = 0;
+            Residual_Time = 0;
+            port21 = 0;
+            port22 = 0;
+        }
+        if(param->command == 1){
+            if( port21 == 0 && port22 == 0 )
+                port21 = 1;
+        }
+    }else if( param->char_code == LAMP_CONTROL_LIGHT_INTENSITY_CHAR){
+        if( param->command == 1 ){ //low
+            port21 = 1;
+            port22 = 0;
+        }
+        else if( param->command == 2 ){ //mid
+            port21 = 0;
+            port22 = 1;
+        } 
+    }else if( param->char_code == LAMP_CONTROL_LAMP_TIMER_CHAR){
+        Timer_flag = param->command;
+    }else if( param->char_code == LAMP_CONTROL_RESIDUAL_TIME_CHAR){
+        Residual_Time = param->residual_time;
+        {
+                uint8_t fota_normal = 0;
+                uint8_t *msg;
+                struct lamp_control_set_char_val_req char_set_req;
+                unsigned short msg_size = 1+sizeof(ble_hdr)+ sizeof(lamp_control_set_char_val_req)-(4-LAMP_CONTROL_MIN_SIZE);
+                // Fill in the parameter structure
+                char_set_req.char_code     = LAMP_CONTROL_POWER_STATE_CHAR;
+                char_set_req.val_len       = LAMP_CONTROL_MIN_SIZE;
+                memcpy(&char_set_req.val[0], &fota_normal, sizeof(fota_normal));
+                
+                msg = new uint8_t[msg_size];
+                
+                BMH->BleMsgAlloc(LAMP_CONTROL_SET_CHAR_VAL_REQ
+                    ,TASK_LAMP_CONTROL, TASK_GTL
+                    ,sizeof(struct fan_control_set_char_val_req)-(4-LAMP_CONTROL_MIN_SIZE)
+                    ,&char_set_req,msg );
+                // Send the message
+                BMH->BleSendMsg(msg,msg_size);                
+                free(msg);
+        }
+    }
+}
+/**
+ ****************************************************************************************
  * @brief Handles ready indication from the GAP.
  *
  * @param[in] msgid     Id of the message received.
@@ -670,7 +837,8 @@
     
     app_dis_enable(&device,BMH);
     app_fota_server_enable(&device,BMH);
-    app_fan_control_enable(&device,BMH);
+    //app_fan_control_enable(&device,BMH);
+    app_lamp_control_enable(&device,BMH);
     app_connect_confirm(GAP_AUTH_REQ_NO_MITM_NO_BOND,&device,BMH);
    
     return 0;
diff -r e3d3676753cc -r e714e2971c49 dialog_fota/app_task.h
--- a/dialog_fota/app_task.h	Wed Sep 02 07:44:29 2015 +0000
+++ b/dialog_fota/app_task.h	Tue Oct 13 06:35:19 2015 +0000
@@ -132,6 +132,42 @@
                                   BleMsgHandler* BMH);
 /**
  ****************************************************************************************
+ * @brief Handles the LAMP_CONTROL_CREATE_DB_CFM message.
+ *
+ * @param[in] msgid     Id of the message received.
+ * @param[in] param     Pointer to the parameters of the message.
+ * @param[in] dest_id   ID of the receiving task instance (TASK_GAP).
+ * @param[in] src_id    ID of the sending task instance.
+ * @param[in] BMH     Ble Message Handler class reference.
+ *
+ * @return If the message was consumed or not.
+ ****************************************************************************************
+ */
+void lamp_control_create_db_cfm_handler(unsigned short msgid,
+                                  struct lamp_control_create_db_cfm *param,
+                                  unsigned short dest_id,
+                                  unsigned short src_id,
+                                  BleMsgHandler* BMH);
+/**
+ ****************************************************************************************
+ * @brief Handles the LAMP_CONTROL_COMMAND_IND message.
+ *
+ * @param[in] msgid     Id of the message received.
+ * @param[in] param     Pointer to the parameters of the message.
+ * @param[in] dest_id   ID of the receiving task instance (TASK_GAP).
+ * @param[in] src_id    ID of the sending task instance.
+ * @param[in] BMH     Ble Message Handler class reference.
+ *
+ * @return If the message was consumed or not.
+ ****************************************************************************************
+ */
+void lamp_control_command_ind_handler(unsigned short msgid,
+                                  struct lamp_control_command_ind *param,
+                                  unsigned short dest_id,
+                                  unsigned short src_id,
+                                  BleMsgHandler* BMH);
+/**
+ ****************************************************************************************
  * @brief Handles ready indication from the GAP.
  *
  * @param[in] msgid     Id of the message received.
diff -r e3d3676753cc -r e714e2971c49 dialog_fota/dialog_fota_config.h
--- a/dialog_fota/dialog_fota_config.h	Wed Sep 02 07:44:29 2015 +0000
+++ b/dialog_fota/dialog_fota_config.h	Tue Oct 13 06:35:19 2015 +0000
@@ -96,6 +96,7 @@
     // Start of conditionally assigned task types
     TASK_FOTA_SERVER    = 54  ,
     TASK_FAN_CONTROL    = 55  ,
+    TASK_LAMP_CONTROL   = 56  ,
     
 #if (BLE_SAMPLE128)
     TASK_SAMPLE128    ,   // Sample128 Task
diff -r e3d3676753cc -r e714e2971c49 dialog_fota/lamp_control_task.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dialog_fota/lamp_control_task.h	Tue Oct 13 06:35:19 2015 +0000
@@ -0,0 +1,141 @@
+/**
+ * @file lamp_control_task.h
+ * @brief Lamp Control Task Header.
+ * Copyright 2015 SEVENCORE Co., Ltd.
+ *
+ * @author HyeongJun Kim 
+ * @version 1.0.0  
+ * @date 2015-09-02
+*/
+
+#ifndef LAMP_CONTROL_TASK_H_
+#define LAMP_CONTROL_TASK_H_
+
+/*
+ * INCLUDE FILES
+ ****************************************************************************************
+*/
+
+
+/**
+ ****************************************************************************************
+ * @addtogroup dialog_fota module
+ * @brief Fota Server Task Header.
+ *
+ * @{
+ ****************************************************************************************
+ */
+namespace sevencore_fota{
+
+
+/*
+ * DEFINES
+ ****************************************************************************************
+ */
+
+/// Maximum number of fota server task instances
+#define LAMP_CONTROL_IDX_MAX                 (1)
+#define LAMP_CONTROL_MIN_SIZE                (1)
+#define LAMP_CONTROL_MAX_SIZE                (4)
+
+/*
+ * ENUMERATIONS
+ ****************************************************************************************
+ */
+ 
+///Attribue Table Indexes
+enum
+{
+    LAMP_CONTROL_POWER_STATE_CHAR,
+    LAMP_CONTROL_LIGHT_INTENSITY_CHAR,
+    LAMP_CONTROL_LAMP_TIMER_CHAR,
+    LAMP_CONTROL_RESIDUAL_TIME_CHAR,
+    
+    LAMP_CONTROL_CHAR_MAX,
+};
+
+/// Messages for Fota Server
+enum
+{
+    /// Start lamp_control. Device connection
+    LAMP_CONTROL_ENABLE_REQ = TASK_LAMP_CONTROL*1024,
+    ///Create DataBase
+    LAMP_CONTROL_CREATE_DB_REQ,
+    ///Inform APP of database creation status
+    LAMP_CONTROL_CREATE_DB_CFM,
+    /// Disable confirm.
+    LAMP_CONTROL_DISABLE_IND,
+    //Set Request of The Attribute Value of  Fota Service Characteristics  
+    LAMP_CONTROL_SET_CHAR_VAL_REQ,
+    //Fan Control Command Indication
+    LAMP_CONTROL_COMMAND_IND,
+    /// Error Indication
+    LAMP_CONTROL_ERROR_IND,
+};
+
+
+/*
+ * API MESSAGES STRUCTURES
+ ****************************************************************************************
+ */
+
+
+/// Parameters of the @ref LAMP_CONTROL_ENABLE_REQ message
+struct lamp_control_enable_req
+
+{
+    /// Connection Handle
+    uint16_t conhdl;
+    /// Security level
+    uint8_t sec_lvl;
+};
+
+
+/// Parameters of the @ref LAMP_CONTROL_CREATE_DB_REQ message
+struct lamp_control_create_db_req
+{
+    /// Indicate if TXPS is supported or not
+    uint16_t features;   
+};
+
+
+/// Parameters of the @ref LAMP_CONTROL_CREATE_DB_CFM message
+struct lamp_control_create_db_cfm
+{
+    /// Status
+    uint8_t status;
+};
+
+
+/// Parameters of the @ref LAMP_CONTROL_SET_CHAR_VAL_REQ message - shall be dynamically allocated
+struct lamp_control_set_char_val_req
+{
+    /// Characteristic Code
+    uint8_t char_code;
+    /// Value length
+    uint8_t val_len;
+    /// Value
+    uint8_t val[4];
+};
+
+
+/// Parameters of the @ref LAMP_CONTROL_DISABLE_IND message
+struct lamp_control_disable_ind
+{
+    /// Connection Handle
+    uint16_t conhdl;
+};
+
+/// Parameters of the @ref LAMP_CONTROL_COMMAND_IND message
+struct lamp_control_command_ind
+{
+    uint8_t char_code;
+    uint8_t command;
+    uint32_t residual_time;
+};
+
+
+}//namespace
+
+/// @} dialog_fota module
+#endif // LAMP_CONTROL_TASK_H_
diff -r e3d3676753cc -r e714e2971c49 ext_fota/BleMsgHandler.cpp
--- a/ext_fota/BleMsgHandler.cpp	Wed Sep 02 07:44:29 2015 +0000
+++ b/ext_fota/BleMsgHandler.cpp	Tue Oct 13 06:35:19 2015 +0000
@@ -14,6 +14,7 @@
 #include "fota_server_task.h"
 #include "app_task.h"
 #include "fan_control_task.h"
+#include "lamp_control_task.h"
 
 /**
  ****************************************************************************************
@@ -247,6 +248,24 @@
             if( print_flag == 1)
                 hostpc->printf("==> FAN_CONTROL_ERROR_IND !!\n");
             break;
+        case LAMP_CONTROL_CREATE_DB_CFM:
+            if ( print_flag == 1)
+                hostpc->printf("Rcved LAMP_CONTROL_CREATE_DB_CFM Msg\n");
+            lamp_control_create_db_cfm_handler(msg_hdr.bType,(struct lamp_control_create_db_cfm *)&msg[paramPos],msg_hdr.bDstid,msg_hdr.bSrcid,this);
+            break;
+        case LAMP_CONTROL_DISABLE_IND:
+            if( print_flag == 1)
+                hostpc->printf("==> LAMP_CONTROL_DISABLE_IND!!\n");
+            break;
+        case LAMP_CONTROL_COMMAND_IND:
+            if( print_flag == 1)
+                hostpc->printf("==> LAMP_CONTROL_COMMAND_IND msg\n");
+            lamp_control_command_ind_handler(msg_hdr.bType,(struct lamp_control_command_ind *)&msg[paramPos],msg_hdr.bDstid,msg_hdr.bSrcid,this);
+            break;
+        case LAMP_CONTROL_ERROR_IND:
+            if( print_flag == 1)
+                hostpc->printf("==> LAMP_CONTROL_ERROR_IND !!\n");
+            break;
         default:
             if( print_flag == 1)
                 hostpc->printf("message Type Not Defined ! \n");
diff -r e3d3676753cc -r e714e2971c49 main.cpp
--- a/main.cpp	Wed Sep 02 07:44:29 2015 +0000
+++ b/main.cpp	Tue Oct 13 06:35:19 2015 +0000
@@ -28,6 +28,9 @@
 DigitalOut port19(p19);//low
 DigitalOut port20(p20);//high
 
+DigitalOut port21(p21);//low
+DigitalOut port22(p22);//high
+
 uint8_t Timer_flag;
 uint32_t Residual_Time;
 
@@ -45,8 +48,8 @@
         if( Timer_flag == 1 && Residual_Time == 0 )
         {
             hostpc.printf("Power off!!\n");
-            if( port18 == 1 || port19 == 1 || port20 == 1 )
-                port18 = port19 = port20 = 0;
+            if( port21 == 1 || port22 == 1  )
+                port21 = port22 = 0;
             Timer_flag = 0;
             /*{
                 uint8_t fota_normal = 0;
diff -r e3d3676753cc -r e714e2971c49 mbed_fota_lamp_control.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_fota_lamp_control.lib	Tue Oct 13 06:35:19 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/dudnwjs/code/mbed_fota_fan_control/#e3d3676753cc