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 TxIR mbed nRF51822
Fork of ir-puck by
Revision 4:24d9873936e6, committed 2014-07-15
- Comitter:
- stiaje
- Date:
- Tue Jul 15 08:49:45 2014 +0000
- Parent:
- 3:65d3ccfe6d45
- Commit message:
- Wait for bluetooth disconnect before sending IR signal.
Changed in this revision
IR.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 65d3ccfe6d45 -r 24d9873936e6 IR.cpp --- a/IR.cpp Mon Jul 14 07:44:51 2014 +0000 +++ b/IR.cpp Tue Jul 15 08:49:45 2014 +0000 @@ -31,7 +31,13 @@ code[i / 16] <<= 1; } raw_codes[66] = WORD(ptrail, 0); - + + px.printf("Full sequence received: [%i", raw_codes[0]); + for (int i=1; i<67; i++) { + px.printf(", %i", raw_codes[i]); + } + px.printf("]\n"); + txir.txSeq(26, 67, raw_codes); px.printf("Wrote message :)\n");
diff -r 65d3ccfe6d45 -r 24d9873936e6 main.cpp --- a/main.cpp Mon Jul 14 07:44:51 2014 +0000 +++ b/main.cpp Tue Jul 15 08:49:45 2014 +0000 @@ -12,7 +12,7 @@ Serial py(USBTX, USBRX); const static uint8_t beaconPayload[] = { - 0x00, 0x4C, // Company identifier code (0x004C == Apple) + 0x00, 0x00, // Company identifier code (0x004C == Apple) - Should be all zero until we figure out this weird iOS bug 0x02, // ID 0x15, // length of the remaining payload 0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, // UUID @@ -25,7 +25,9 @@ extern GattService ir_service; extern GattCharacteristic header, one, zero, ptrail, predata, code; -int received_ir_transmission = 0; +bool received_ir_transmission = false; +bool device_disconnected = true; + void onDataWritten(uint16_t handle) { py.printf("Data written! %i\n", handle); @@ -43,20 +45,21 @@ } if (code.getHandle() == handle) { - received_ir_transmission = 1; + py.printf("Received complete instruction\n"); + received_ir_transmission = true; } } void disconnectionCallback(void) { py.printf("Disconnected!\n"); - py.printf("Restarting the advertising process\n"); - ble.startAdvertising(); + device_disconnected = true; } void connectionCallback(void) { py.printf("Connected!\n"); + device_disconnected = false; } void onDataSent(uint16_t data) @@ -90,9 +93,10 @@ while (true) { ble.waitForEvent(); - if (received_ir_transmission == 1) { + if (received_ir_transmission && device_disconnected) { fireIRCode(header.getValuePtr(), one.getValuePtr(), zero.getValuePtr(), ptrail.getValuePtr(), predata.getValuePtr(), code.getValuePtr()); - received_ir_transmission = 0; + received_ir_transmission = false; + ble.startAdvertising(); } myled = !myled; }