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_GATT_test1 by
Diff: main.cpp
- Revision:
- 2:f538ff758828
- Parent:
- 1:ebdf445c4bcc
- Child:
- 3:f3d20b36b7ea
--- a/main.cpp Sun Jan 18 15:46:43 2015 +0000
+++ b/main.cpp Sun Jan 18 15:50:17 2015 +0000
@@ -17,81 +17,7 @@
/*Variable Declarations*/
const static char DEVICE_NAME[] = "BLE_NODE";
-
-///*
-//* Define a custom UUID, first as an array of uint8_t and then convert to
-//* a proper UUID later. The UUID must be 16 bytes (128-bits, 16 letters)
-//* long - here we have padded out to 16 bytes by adding an extra '0' at
-//* the end. Make sure you fill more than 4 bytes otherwise it will count
-//* as a 'short' code and you could end up using a predefined value from
-//* the BLE spec.
-//*/
-//uint8_t raw_characteristic_uuid[16] = {
-// 'M', 'Y', '_', 'T',
-// 'E', 'S', 'T', '_',
-// 'C', 'H', 'A', 'R',
-// 0, 0, 0, 0
-//};
-//
-//// Create a proper UUID
-//UUID characteristic_uuid = {0x4d,0x32,0x81,0xc0,0x86,0xd1,0x11,0xe4,0xb0,0x84,0x00,0x02,0xa5,0xd5,0xc5,0x10};
-
static volatile bool connected;
-//Ticker ticker;
-//
-//
-//// Setup some dummy properties for our characteristic
-//static uint8_t my_char_values[2] = { 15, 10 };
-//
-///*
-//* Here we create our Characteristic adding in the dummy parameter values
-//* we just setup, we also make it readable and writeable meaning that a
-//* central can read and update the parameters we have stored.
-//*/
-//GattCharacteristic pattern(
-// characteristic_uuid,
-// my_char_values,
-// sizeof(my_char_values),
-// sizeof(my_char_values),
-// GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE
-//);
-//
-///*
-//* List the Characteristics of our custom Service, can have one or more
-//* of these each with a custom UUID and parameter values.
-//*/
-//GattCharacteristic *my_service_chars[] = {
-// &new_alert,
-//};
-//
-// Now setup a custom Service UUID, in the same fashion as for the Characteristic
-//uint8_t raw_service_uuid[16] = {
-// 'M', 'Y', '_', 'T',
-// 'E', 'S', 'T', '_',
-// 'S', 'E', 'R', 'V',
-// 'I', 'C', 'E', 0
-//};
-
-
-
-//
-//UUID service_uuid = UUID(raw_service_uuid);
-//// Setup the Service with the UUID and all of the Characteristics
-//GattService my_service(
-// service_uuid,
-// my_service_chars,
-// sizeof(my_service_chars) / sizeof(GattCharacteristic *)
-//);
-//
-///*
-//* Now list the long UUIDs of the services we offer, these will be bundled into the
-//* advertisement. It may look like repetition of 'raw_service_uuid' but here you can
-//* list multiple UUIDs one after another.
-//*/
-//static const uint8_t uuid128_list[] = {
-// 'M', 'Y', '_', 'T', 'E', 'S', 'T', '_', 'S', 'E', 'R', 'V', 'I', 'C', 'E', 0
-// // List more long UUIDs below...
-//};
void blink(void)
{
@@ -117,7 +43,7 @@
int main(void)
{
- uint8_t testLevel = 50;
+ uint8_t testCommand = 12;
//blinky
led1 = 1;
@@ -130,9 +56,8 @@
ble.onConnection(connectionCallback);
//CarCommsService commsService(ble, cmd);
- TestGattService testService(ble, testLevel);
-
-
+ TestGattService testService(ble, 0);
+
/*
**BREDR_NOT_SUPPORTED = BLE only
**LE_GENERAL_DISCOVERABLE = Device is discoverable at any moment (no time out)
@@ -149,46 +74,17 @@
pc.printf("Advertising node %s\n\r", DEVICE_NAME);
-//GATT service stuff - referring to CarCommsService.h
-//string testCommand = "Hello world";
-// CarCommsService carComm(ble, 150);
-//
-// uint8_t x = carComm.getCommand();
-//
-// pc.printf("Command: %u \n", x);
-
-
while(true) {
- ble.waitForEvent(); // this will return upon any system event (such as an interrupt or a ticker wakeup)
+ ble.waitForEvent(); // this will return upon any system event (such as an interrupt or a ticker wakeup)
+
+ testCommand++;
- //if(led1 == 1) {
-// cmd = 1;
-// } else {
-// cmd = 0;
-// }
-//
-// commsService.sendCommand(0);
-// pc.printf("Command: %u\r\n", commsService.getCommand());
-
- testLevel++;
-
- if (testLevel > 100) {
- testLevel = 0;
+ if (testCommand < 100) {
+ testCommand = 0;
}
- pc.printf("Level = %u\r\n", testLevel);
- testService.sendCommand(testLevel);
-
- //if(connected) {
-// led1 = 1;
-// //read data
-// //pc.printf("Command: %u \n", carComm.getCommand());
-// } else {
-// led1 = 0;
-// pc.printf("Waiting...\n\r");
-// ble.waitForEvent();
-// connected = false;
-// }
+ pc.printf("Level = %u\r\n", testCommand);
+ testService.sendCommand(testCommand);
}
}
\ No newline at end of file
