{"action":"opened","issue":{"url":"https://api.github.com/repos/neilbags/arduino-esp32-BLE-MIDI/issues/1","repository_url":"https://api.github.com/repos/neilbags/arduino-esp32-BLE-MIDI","labels_url":"https://api.github.com/repos/neilbags/arduino-esp32-BLE-MIDI/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/neilbags/arduino-esp32-BLE-MIDI/issues/1/comments","events_url":"https://api.github.com/repos/neilbags/arduino-esp32-BLE-MIDI/issues/1/events","html_url":"https://github.com/neilbags/arduino-esp32-BLE-MIDI/issues/1","id":326880703,"number":1,"title":"Update to this:","user":{"login":"daviidmart","id":10666050,"avatar_url":"https://avatars2.githubusercontent.com/u/10666050?v=4","gravatar_id":"","url":"https://api.github.com/users/daviidmart","html_url":"https://github.com/daviidmart","followers_url":"https://api.github.com/users/daviidmart/followers","following_url":"https://api.github.com/users/daviidmart/following{/other_user}","gists_url":"https://api.github.com/users/daviidmart/gists{/gist_id}","starred_url":"https://api.github.com/users/daviidmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daviidmart/subscriptions","organizations_url":"https://api.github.com/users/daviidmart/orgs","repos_url":"https://api.github.com/users/daviidmart/repos","events_url":"https://api.github.com/users/daviidmart/events{/privacy}","received_events_url":"https://api.github.com/users/daviidmart/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-28T02:56:51Z","updated_at":"2018-05-28T02:56:51Z","closed_at":null,"author_association":"NONE","body":"```\r\n#include <BLEDevice.h>\r\n#include <BLEUtils.h>\r\n#include <BLEServer.h>\r\n#include <BLE2902.h>\r\n\r\n#define SERVICE_UUID        \"03b80e5a-ede8-4b33-a751-6ce34ec4c700\"\r\n#define CHARACTERISTIC_UUID \"7772e5db-3868-4112-a1a9-f2669d106bf3\"\r\n\r\nBLECharacteristic *pCharacteristic;\r\nbool deviceConnected = false;\r\n\r\nuint8_t midiPacket[] = {\r\n   0x80,  // header\r\n   0x80,  // timestamp, not implemented \r\n   0x00,  // status\r\n   0x3c,  // 0x3c == 60 == middle c\r\n   0x00   // velocity\r\n};\r\n\r\nclass MyServerCallbacks: public BLEServerCallbacks {\r\n    void onConnect(BLEServer* pServer) {\r\n      deviceConnected = true;\r\n    };\r\n\r\n    void onDisconnect(BLEServer* pServer) {\r\n      deviceConnected = false;\r\n    }\r\n};\r\n\r\nvoid setup() {\r\n  Serial.begin(115200);\r\n\r\n  BLEDevice::init(\"Beemi Pro\");\r\n  BLEServer *pServer = BLEDevice::createServer();\r\n  pServer->setCallbacks(new MyServerCallbacks());\r\n  BLEService *pService = pServer->createService(BLEUUID(SERVICE_UUID));\r\n  pCharacteristic = pService->createCharacteristic(\r\n    BLEUUID(CHARACTERISTIC_UUID),\r\n    BLECharacteristic::PROPERTY_READ   |\r\n    BLECharacteristic::PROPERTY_WRITE  |\r\n    BLECharacteristic::PROPERTY_NOTIFY |\r\n    BLECharacteristic::PROPERTY_WRITE_NR\r\n  );\r\n\r\n  pCharacteristic->addDescriptor(new BLE2902());\r\n  pService->start();\r\n  pServer->getAdvertising()->start();\r\n}\r\n\r\nvoid loop() {\r\n  if (deviceConnected) {\r\n   // note down\r\n   midiPacket[2] = 0x90; // note down, channel 0\r\n   midiPacket[4] = 127;  // velocity\r\n   pCharacteristic->setValue(midiPacket, 5); // packet, length in bytes\r\n   pCharacteristic->notify();\r\n\r\n   // play note for 500ms\r\n   delay(500);\r\n\r\n   // note up\r\n   midiPacket[2] = 0x80; // note up, channel 0\r\n   midiPacket[4] = 0;    // velocity\r\n   pCharacteristic->setValue(midiPacket, 5); // packet, length in bytes)\r\n   pCharacteristic->notify();\r\n\r\n   delay(500);\r\n  }\r\n}\r\n```"}}
{"actor":{"display_login":"daviidmart"}}