created separate function for hex to char

Dependencies:   SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217

Fork of SS_SensePOC2P0_11Dec2017_USERPID by rashmi v

Revision:
58:b75255e6e4c3
Parent:
57:e82d4bd6b2c0
Child:
59:dadb88794375
--- a/bt.cpp	Fri Nov 10 11:58:38 2017 +0000
+++ b/bt.cpp	Sat Nov 11 11:40:36 2017 +0000
@@ -16,6 +16,7 @@
 #define STRUCTURE_LENGTH    26
 #define POC2P0_BT_RX_MSG_LEN 0x05U
 
+
 typedef struct __attribute__((__packed__))
 {
     uint8_t     sos;
@@ -483,23 +484,34 @@
     poc2p0_bluetooth_msg_request poc2p0_bt_msg_req = {0u};
     uint8_t cal_chksum = 0xFFu;
     uint8_t touch_state = 0x00u;
-
-    //if (blue.readable()!= NULL)                                                    // reading string from bluetooth
-    while (mc.readable()!= NULL)
+    char recv_buff[11] = {0X00u};
+    char HEART_BEAT_ex[11] = "C07100C0FF";
+    //mc.printf("enter the data\n");
+   while (blue.readable()!= NULL)                                                    // reading string from bluetooth
+    //while(mc.readable()!= NULL)
     {
-       mc.printf("\n");
-       //blue.gets((char *)&poc2p0_bt_msg_req, sizeof(poc2p0_bt_msg_req));
-       mc.gets((char *)&poc2p0_bt_msg_req, sizeof(poc2p0_bt_msg_req));
-       mc.puts((const char *)&poc2p0_bt_msg_req);                               //,sizeof(poc2p0_bt_msg_req)
+       blue.scanf("%11s\n",recv_buff);
+      //mc.scanf("%10s\n",recv_buff);
+       
+       //mc.gets((char *)&poc2p0_bt_msg_req, sizeof(poc2p0_bt_msg_req));
+       //mc.puts((const char *)&poc2p0_bt_msg_req);
+       mc.printf("%11s\r\n",recv_buff); 
+     
        
+       //memcpy(poc2p0_bt_msg_req.cmd, &recv_buff, 2); 
+       //mc.printf("CMD: %2x\n",poc2p0_bt_msg_req.cmd);
     }
-    
+    if(strcmp(HEART_BEAT_ex, recv_buff) == 0)
+    {
+        mc.printf("hEATBEAT RQ in bt\n");
+        poc2p0_send_device_heartbeat_msg_res(curr_touch_state);
+     }
+     memset((void *)recv_buff, 0x00u, sizeof(recv_buff));
+ #if 0   
     cal_chksum = checksum_struct((uint8_t *)poc2p0_bt_msg_req.cmd, (sizeof(poc2p0_bt_msg_req)-2));
    
-    if (cal_chksum == poc2p0_bt_msg_req.chksum)
-    {
-        
-        mc.printf("CMD: %2x\n",poc2p0_bt_msg_req.cmd);
+    //if (cal_chksum == poc2p0_bt_msg_req.chksum)
+    //{
         switch (poc2p0_bt_msg_req.cmd)
         {
         case STRT_BP_TEST_REQ:
@@ -528,10 +540,11 @@
             break;
 
         case HEARTBEAT_REQ:
-            if ((curr_touch_state == TOUCH_STATE_HOME_SCREEN)||(curr_touch_state == TOUCH_STATE_TEST_SCREEN))
-            {
+            mc.printf("Heartbeat request\n");
+            //if ((curr_touch_state == TOUCH_STATE_HOME_SCREEN)||(curr_touch_state == TOUCH_STATE_TEST_SCREEN))
+            //{
                 poc2p0_send_device_heartbeat_msg_res(curr_touch_state);
-            }
+            //}
             break;
 
         case HOME_SCREEN_REQ:
@@ -547,8 +560,8 @@
         default:
             break;
         }
-    }
-    cal_chksum = 0xFFu;
-    mc.printf("\n%d\n",touch_state);
+    //}
+    //mc.printf("\n%d\n",touch_state);
+#endif
     return touch_state;
 }
\ No newline at end of file