BLE Central for Magic Light

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_Central_Light by HM_IOT_Demo

Files at this revision

API Documentation at this revision

Comitter:
hmiot
Date:
Fri Feb 10 07:36:43 2017 +0000
Parent:
13:9b2a587ee7ac
Commit message:
BLE Demo code for Blitz

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Feb 01 12:38:31 2017 +0000
+++ b/main.cpp	Fri Feb 10 07:36:43 2017 +0000
@@ -4,12 +4,10 @@
 ************************************************************************/
 
 #include "hm_config.h"
-//#include "rtos.h"
 
 DiscoveredCharacteristic lightCharacteristic;
 static s_serviceInfo lightChar = {NULL,NULL,NULL,NULL};
 Serial pc(USBTX, USBRX);
-//static uint8_t peer_addr[2] = {0x51,0x5A};
 void bleint();
 void waitBleEvent();
 void ble_actions(int spi_data);
@@ -21,8 +19,6 @@
     uint8_t con_status =0;
      //0x51 for Magic light 
     //0x5A
-    int i;
-  //  for(i=0; i<2; i++){
         if (params->peerAddr[0] == 0x51){ // 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",
@@ -32,15 +28,12 @@
            con_status = BLE::Instance().gap().connect(params->peerAddr, Gap::ADDR_TYPE_PUBLIC, NULL, NULL);
            pc.printf("Connection Status : %d\r\n",con_status);
            connect_status = 1;
-           i++;
            BLE::Instance().gap().stopScan();
            
         }else{
             printf("Not Matched your device\r\n");
             return;
         }
-   // }
-    
  }
 
 void serviceDiscoveryCallback(const DiscoveredService *service) {
@@ -232,7 +225,7 @@
     bufferSize = 0;
     while(1){
         //printf("loop\r\n");
-     //   if(!(connect_status && charDiscover))
+        if(!(connect_status && charDiscover))
             waitBleEvent();
             
         if(spiSlave.receive()){