ITP | Week 7 | March 10, 2017
Don Coleman
Scan for FEE7
Use service cba20d00-224d-11e6-9fb8-0002a5d5c51b
Characteristic cba20002-224d-11e6-9fb8-0002a5d5c51b
Write 0x5701 to activate switchbot
57 09 03 01 00 <repeat> <hour> <min> 00 00
repeat
00 - Never
01 - Monday
02 - Tuesday
04 - Wednesday
08 - Thursday
10 - Friday
20 - Saturday
40 - Sunday
7f - Everyday
80 - Once
hour
0 - 23 (0x0 - 0x17)
min
0 - 59 (0x0 - 0x3b)
#include <BLEHIDPeripheral.h>
#include <BLEMouse.h>
BLEHIDPeripheral bleHIDPeripheral;
BLEMouse bleMouse;
bleHIDPeripheral.addHID(bleMouse);
bleMouse.move(x, y);
bleMouse.click();
bleMouse.press();
bleMouse.release();
BLEMouse.h
#include <BLEHIDPeripheral.h>
#include <BLEKeyboard.h>
BLEHIDPeripheral bleHIDPeripheral;
BLEKeyboard bleKeyboard;
bleHIDPeripheral.addHID(bleKeyboard);
bleKeyboard.write(char);
bleKeyboard.press(key);
bleKeyboard.release(key);
bleKeyboard.releaseAll();
BLEKeyboard.h
#include <BLEHIDPeripheral.h>
#include <BLEMultimedia.h>
BLEHIDPeripheral bleHIDPeripheral;
bleHIDPeripheral.addHID(bleMultimedia);
bleMultimedia.write(MMKEY_VOL_UP);
bleMultimedia.write(MMKEY_VOL_DOWN);
bleMultimedia.write(MMKEY_MUTE);
// Hold down button on start to unpair
if (buttonState == LOW) {
Serial.println("clearing bond data");
bleHIDPeripheral.clearBondStoreData();
}
MIDI is a music protocol that sends description of the notes rather than actual music.
https://midi.org/
BLEPeripheral blePeripheral;
BLEService midiService(
"03B80E5A-EDE8-4B33-A751-6CE34EC4C700");
BLECharacteristic midiChar(
"7772E5DB-3868-4112-A1A9-F2669D106BF3",
BLEWrite | BLEWriteWithoutResponse | BLENotify | BLERead,
5);
uint8_t channel = 10;
uint8_t note = 38; // snare drum
uint8_t velocity = 127;
uint8_t data[] = { 0x80, 0x80,
0x90 + channel, note, velocity
};
midiChar.setValue(data, sizeof(data));
Service & Characteristics live on the Peripheral.
The Central device remotely accesses the Characteristics on the Peripheral using Bluetooth Low Energy.
Don Coleman
dc159@nyu.edu
NYU ITP Bluetooth Spring 2017 Week 7 by Don Coleman is licensed under a Creative Commons Attribution 4.0 International License.