The IR Puck can mimic arbitrary infrared remote controls. Built on the Puck IOT platform.

Dependencies:   Puck IRSender mbed

The IR Puck is a puck that can mimic arbitrary infrared remote controls. This is useful for controlling things like TVs, radios, airconditioners, window blinds, and just about anything and everything that can be otherwise be controlled by a regular remote control.

A tutorial for the IR Puck is available on GitHub.

Tutorials and in-depth documentation for the Puck platform is available at the project's GitHub page

main.cpp

Committer:
stiaje
Date:
2014-08-01
Revision:
12:a7d9b4f303fd
Parent:
10:35d78d589580
Child:
15:cf6c517f31ad

File content as of revision 12:a7d9b4f303fd:

#include "mbed.h"
#include "IR.h"

#define LOG_LEVEL_ERROR
#include "Log.h"
#include "Puck.h"

Puck* puck = &Puck::getPuck();

const UUID IR_SERVICE_UUID = stringToUUID("bftj ir         ");
const UUID HEADER_UUID     = stringToUUID("bftj ir header  ");
const UUID ONE_UUID        = stringToUUID("bftj ir one     ");
const UUID ZERO_UUID       = stringToUUID("bftj ir zero    ");
const UUID PTRAIL_UUID     = stringToUUID("bftj ir ptrail  ");
const UUID PREDATA_UUID    = stringToUUID("bftj ir predata ");
const UUID CODE_UUID       = stringToUUID("bftj ir code    ");


void onIRCodeWrite(uint8_t* value) {
    puck->getBle().disconnect();
    LOG_INFO("Going to fire IR code...\n");
    fireIRCode(puck->getCharacteristicValue(HEADER_UUID),
               puck->getCharacteristicValue(ONE_UUID), 
               puck->getCharacteristicValue(ZERO_UUID),
               puck->getCharacteristicValue(PTRAIL_UUID),
               puck->getCharacteristicValue(PREDATA_UUID),
               puck->getCharacteristicValue(CODE_UUID));
    LOG_INFO("Fire complete!\n");
}


int main() {
    puck->addCharacteristic(IR_SERVICE_UUID, HEADER_UUID, 4);
    puck->addCharacteristic(IR_SERVICE_UUID, ONE_UUID, 4);
    puck->addCharacteristic(IR_SERVICE_UUID, ZERO_UUID, 4);
    puck->addCharacteristic(IR_SERVICE_UUID, PTRAIL_UUID, 2);
    puck->addCharacteristic(IR_SERVICE_UUID, PREDATA_UUID, 2);
    puck->addCharacteristic(IR_SERVICE_UUID, CODE_UUID, 2);
    puck->init(0xABBA);
    puck->onCharacteristicWrite(&CODE_UUID, onIRCodeWrite);
    while (puck->drive());
}