Goran Mahovlic / Mbed 2 deprecated BLE_MIDI

Dependencies:   BLE_API mbed nRF51822_BLE_MIDI

Dependents:   BLE_MIDI_one_note_TEST

Fork of BLE_MIDI by Kaoru Shoji

Revision:
0:83889dc90473
Child:
1:cba2eba64f5c
diff -r 000000000000 -r 83889dc90473 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 02 05:17:14 2015 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "BLEDevice.h"
+#include "BLEMIDI.h"
+
+BLEDevice device;
+BLEMIDI bleMidi(&device);
+
+DigitalOut led1(P0_0);
+
+void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) {
+    bleMidi.onBleDisconnection(handle, reason);
+}
+
+void connectionCallback(Gap::Handle_t handle, Gap::addr_type_t type, const Gap::address_t addr, const Gap::ConnectionParams_t *params) {
+    bleMidi.onBleConnection(handle, type, addr, params);
+}
+
+void onNoteOn(uint8_t channel, uint8_t note, uint8_t velocity) {
+    led1 = 1;
+//    if (bleMidi.connected()) {
+//        bleMidi.sendNoteOn(channel, note, velocity);
+//    }
+}
+
+void onNoteOff(uint8_t channel, uint8_t note, uint8_t velocity) {
+    led1 = 0;
+//    if (bleMidi.connected()) {
+//        bleMidi.sendNoteOff(channel, note, velocity);
+//    }
+}
+
+int main(void) {
+    device.onConnection(connectionCallback);
+    device.onDisconnection(disconnectionCallback);
+    
+    bleMidi.attachNoteOn(onNoteOn);
+    bleMidi.attachNoteOff(onNoteOff);
+    
+    for (;;) {
+        device.waitForEvent();
+    }
+}