Working Code

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_Central_Light_Demo by HM_IOT_Demo

Files at this revision

API Documentation at this revision

Comitter:
hmiot
Date:
Thu Sep 21 07:55:35 2017 +0000
Parent:
14:f84a9745c10a
Commit message:
Blitz Working Code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f84a9745c10a -r ef3cf37827d2 main.cpp
--- a/main.cpp	Fri Feb 10 07:36:43 2017 +0000
+++ b/main.cpp	Thu Sep 21 07:55:35 2017 +0000
@@ -19,7 +19,7 @@
     uint8_t con_status =0;
      //0x51 for Magic light 
     //0x5A
-        if (params->peerAddr[0] == 0x51){ // 0x2F for red bear1.5 /* !ALERT! Alter this filter to suit your device. */
+        if (params->peerAddr[0] == 0x5A){ // 0x2F for red bear1.5 /* !ALERT! Alter this filter to suit your device. */
        
            pc.printf("adv peerAddr[%02x %02x %02x %02x %02x %02x] rssi %d, isScanResponse %u, AdvertisementType %u\r\n",
            params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0],
@@ -141,7 +141,7 @@
 
 }
 
-void light_actions(int service_char[]){
+void light_actions(int * service_char){
     lightCharacteristic_t *ptr_tmp = NULL;
     ptr_tmp = lightChar.services_Char[0];
     uint8_t numCount;
@@ -162,7 +162,6 @@
                 break;
                        
             case TURN_ON: //on
-                if(first_on){
                 pre_write_data[0]=0x56;
                 pre_write_data[1]=0xDE;
                 pre_write_data[2]=0x8E;
@@ -170,7 +169,7 @@
                 pre_write_data[4]=0x00;
                 pre_write_data[5]=0xf0;
                 pre_write_data[6]=0xaa;
-                }
+                
                 error_status = BLE::Instance().gattClient().write(GattClient::GATT_OP_WRITE_CMD,ptr_tmp->connHandle,ptr_tmp->valueHandle,8,pre_write_data);
                 break;
                        
@@ -237,7 +236,7 @@
             if(bufferSize >= 5){
                 bufferSize=0;
                 light_actions(spiRX);
-                spiSlave.reply(0xAA);
+                spiSlave.reply(spiRX[2]); //(0xAA);
                 
                 if(statusWR >=4)
                 {   wait_ms(500);