ir-puck

Dependencies:   Puck IRSender mbed

Fork of ir-puck by Nordic Pucks

Committer:
stiaje
Date:
Wed Jul 23 14:20:06 2014 +0000
Revision:
8:260888851644
Parent:
5:3642c0af497e
Child:
10:35d78d589580
Disconnect ble before firing IR code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sigveseb 0:c94311378ec1 1 #include "mbed.h"
sigveseb 0:c94311378ec1 2 #include "IR.h"
sigveseb 0:c94311378ec1 3
sigveseb 5:3642c0af497e 4 #define LOG_LEVEL_VERBOSE
sigveseb 5:3642c0af497e 5 #include "Puck.h"
sigveseb 0:c94311378ec1 6
sigveseb 5:3642c0af497e 7 Puck* puck = &Puck::getPuck();
sigveseb 0:c94311378ec1 8
sigveseb 5:3642c0af497e 9 const UUID IR_SERVICE_UUID = stringToUUID("bftj ir ");
sigveseb 5:3642c0af497e 10 const UUID HEADER_UUID = stringToUUID("bftj ir header ");
sigveseb 5:3642c0af497e 11 const UUID ONE_UUID = stringToUUID("bftj ir one ");
sigveseb 5:3642c0af497e 12 const UUID ZERO_UUID = stringToUUID("bftj ir zero ");
sigveseb 5:3642c0af497e 13 const UUID PTRAIL_UUID = stringToUUID("bftj ir ptrail ");
sigveseb 5:3642c0af497e 14 const UUID PREDATA_UUID = stringToUUID("bftj ir predata ");
sigveseb 5:3642c0af497e 15 const UUID CODE_UUID = stringToUUID("bftj ir code ");
sigveseb 0:c94311378ec1 16
stiaje 4:24d9873936e6 17
sigveseb 5:3642c0af497e 18 void onIRCodeWrite(uint8_t* value) {
stiaje 8:260888851644 19 puck->getBle().disconnect();
sigveseb 5:3642c0af497e 20 LOG_INFO("Going to fire IR code...\n");
sigveseb 5:3642c0af497e 21 fireIRCode(puck->getCharacteristicValue(HEADER_UUID),
sigveseb 5:3642c0af497e 22 puck->getCharacteristicValue(ONE_UUID),
sigveseb 5:3642c0af497e 23 puck->getCharacteristicValue(ZERO_UUID),
sigveseb 5:3642c0af497e 24 puck->getCharacteristicValue(PTRAIL_UUID),
sigveseb 5:3642c0af497e 25 puck->getCharacteristicValue(PREDATA_UUID),
sigveseb 5:3642c0af497e 26 puck->getCharacteristicValue(CODE_UUID));
sigveseb 5:3642c0af497e 27 LOG_INFO("Fire complete!\n");
sigveseb 0:c94311378ec1 28 }
sigveseb 0:c94311378ec1 29
sigveseb 0:c94311378ec1 30
sigveseb 5:3642c0af497e 31 int main() {
sigveseb 5:3642c0af497e 32 puck->addCharacteristic(IR_SERVICE_UUID, HEADER_UUID, 4);
sigveseb 5:3642c0af497e 33 puck->addCharacteristic(IR_SERVICE_UUID, ONE_UUID, 4);
sigveseb 5:3642c0af497e 34 puck->addCharacteristic(IR_SERVICE_UUID, ZERO_UUID, 4);
sigveseb 5:3642c0af497e 35 puck->addCharacteristic(IR_SERVICE_UUID, PTRAIL_UUID, 2);
sigveseb 5:3642c0af497e 36 puck->addCharacteristic(IR_SERVICE_UUID, PREDATA_UUID, 2);
sigveseb 5:3642c0af497e 37 puck->addCharacteristic(IR_SERVICE_UUID, CODE_UUID, 2);
sigveseb 5:3642c0af497e 38 puck->init(0xABBA);
sigveseb 5:3642c0af497e 39 puck->onCharacteristicWrite(CODE_UUID, onIRCodeWrite);
sigveseb 5:3642c0af497e 40 while (puck->drive());
sigveseb 0:c94311378ec1 41 }