Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of BLE_Central_Light_Demo_23 by
Diff: main.cpp
- Revision:
- 17:0b0a7dccf151
- Parent:
- 16:0cbb6fa27253
- Child:
- 18:ef42e2579463
diff -r 0cbb6fa27253 -r 0b0a7dccf151 main.cpp
--- a/main.cpp Wed Sep 27 12:40:40 2017 +0000
+++ b/main.cpp Mon Oct 09 09:39:46 2017 +0000
@@ -19,13 +19,14 @@
uint8_t con_status =0;
//0x51 for Magic light
//0x5A
+
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],
params->rssi, params->isScanResponse, params->type);
pc.printf("Data Length : %d\r\n",params->advertisingDataLen);
- //con_status = BLE::Instance().gap().connect(params->peerAddr, Gap::ADDR_TYPE_PUBLIC, NULL, NULL);
+ 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;
BLE::Instance().gap().stopScan();
@@ -159,6 +160,7 @@
write_data[5]=0xf0;
write_data[6]=0xaa;
error_status = BLE::Instance().gattClient().write(GattClient::GATT_OP_WRITE_CMD,ptr_tmp->connHandle,ptr_tmp->valueHandle,8,write_data);
+ BLE::Instance().processEvents();
break;
case TURN_ON: //on
@@ -171,6 +173,7 @@
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);
+ BLE::Instance().processEvents();
break;
case COLOR: // Color
@@ -186,6 +189,7 @@
}
first_on=false;
error_status = BLE::Instance().gattClient().write(GattClient::GATT_OP_WRITE_CMD,ptr_tmp->connHandle,ptr_tmp->valueHandle,8,write_data);
+ BLE::Instance().processEvents();
break;
default:
@@ -237,8 +241,8 @@
bufferSize=0;
light_actions(spiRX);
spiSlave.reply(spiRX[2]); //(0xAA);
-
- if(statusWR >=4)
+ /*
+ if(statusWR >=3)
{
wait_ms(500);
BLE::Instance().shutdown();
@@ -248,7 +252,9 @@
serviceDiscover = true;
bleint();
}
+
statusWR++;
+ */
}
}
