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
Diff: main.cpp
- Revision:
- 3:f3d20b36b7ea
- Parent:
- 2:f538ff758828
- Child:
- 4:ac0ee88ea0ed
--- a/main.cpp Sun Jan 18 15:50:17 2015 +0000
+++ b/main.cpp Tue Feb 17 13:57:28 2015 +0000
@@ -16,7 +16,7 @@
Serial pc(USBTX, USBRX);
/*Variable Declarations*/
-const static char DEVICE_NAME[] = "BLE_NODE";
+const static char DEVICE_NAME[] = "BLE_Broadcaster";
static volatile bool connected;
void blink(void)
@@ -31,24 +31,26 @@
ble.startAdvertising();
}
-
-//Handle_t, addr_type_t peerAddrType, const address_t peerAddr, const ConnectionParams_t *
void connectionCallback(Gap::Handle_t handle, Gap::addr_type_t peerAddrType, const Gap::address_t peerAddr, const Gap::ConnectionParams_t *parms)
{
pc.printf("Connected! - stop advertising. Handle:%d, eType:%d, Add:%u.\r\n", handle, peerAddrType, peerAddr);
connected = true;
-// ble.stopAdvertising();
+ ble.stopAdvertising();
}
int main(void)
{
- uint8_t testCommand = 12;
+ //TODO: I want to be able to send something like:
+ uint8_t command[8] = { 0x4d,0x32,0x81,0xc0,0x4d,0x32,0x81,0xc0 };
+ //with first 4 bits being type code, and last 4 being command, or something
+
+ uint8_t testCommand = 0x12; //max value is 255
//blinky
- led1 = 1;
+ led1 = 1;
Ticker t;
- t.attach(blink, 1.0f);
+ t.attach(blink, 5.0f);
//Create BLE stuff
ble.init();
@@ -56,7 +58,7 @@
ble.onConnection(connectionCallback);
//CarCommsService commsService(ble, cmd);
- TestGattService testService(ble, 0);
+ TestGattService testService(ble, testCommand);
/*
**BREDR_NOT_SUPPORTED = BLE only
@@ -80,7 +82,7 @@
testCommand++;
- if (testCommand < 100) {
+ if (testCommand > 100) {
testCommand = 0;
}