Skip to content

Instantly share code, notes, and snippets.

@don
Last active March 10, 2017 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save don/88fd43c1066972c83c8c8b3c4568344a to your computer and use it in GitHub Desktop.
Save don/88fd43c1066972c83c8c8b3c4568344a to your computer and use it in GitHub Desktop.
var midiService = {
uuid: MIDI_SERVICE_UUID,
characteristics: [
{
uuid: MIDI_CHARACTERISTIC_UUID,
properties: property.WRITE | property.READ | property.NOTIFY,
permissions: permission.WRITEABLE | permission.READABLE,
descriptors: [
{
uuid: '2901',
value: 'MIDI'
}
]
}
]
};
blePeripheral.createServiceFromJSON(midiService);
// https://github.com/don/cordova-plugin-ble-peripheral
var channel = 10;
var midiNote = 49; // crash cymbal
var velocity = 127;
var noteOn = new Uint8Array([0x80, 0x80, 0x90 + channel, midiNote, velocity]);
blePeripheral.setCharacteristicValue(
MIDI_SERVICE_UUID,
MIDI_CHARACTERISTIC_UUID,
noteOn.buffer
).then(success, failure);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment