micro:bitにRCBControllerを接続するサンプルプログラム。 接続が不安定。micro:bitの電源入り切りやリセットSW押下を何度か試せば接続できるかも。
Fork of BLE_GATT_Example by
Diff: main.cpp
- Revision:
- 10:6acaa9f0ef85
- Parent:
- 9:b33f42191584
- Child:
- 11:b59226338001
--- a/main.cpp Mon Mar 09 19:21:06 2015 +0000 +++ b/main.cpp Tue Mar 10 15:11:10 2015 +0000 @@ -11,7 +11,7 @@ const static char DEVICE_NAME[] = "ChangeMe!!"; // change this static const uint16_t uuid16_list[] = {0xFFFF}; //Custom UUID, FFFF is reserved for development -// Set Up Characteristics +// Set Up custom Characteristics static uint8_t readValue[10] = {0}; GattCharacteristic readChar(reachCharUUID, readValue, sizeof(readValue), sizeof(readValue), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); @@ -46,6 +46,7 @@ } // print the data if more than 1 byte is written else { + printf("0x"); for(int x=0; x < params->len; x++) { printf("%x",params->data[x]); } @@ -64,10 +65,9 @@ { /* initialize stuff */ printf("\n\r********* Starting Main Loop *********\n\r"); - led = 1; // turn LED off (led is inverted) ble.init(); ble.onDisconnection(disconnectionCallback); - ble.onDataWritten(writeCharCallback); //TODO: this is not correct, figure out correct syntax + ble.onDataWritten(writeCharCallback); /* setup advertising */ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); // BLE only, no classic BT