diff --git a/src/lightingFirmware/SimpleBleDevice/SimpleBleDevice.ino b/src/lightingFirmware/SimpleBleDevice/SimpleBleDevice.ino new file mode 100644 index 00000000..a424df85 --- /dev/null +++ b/src/lightingFirmware/SimpleBleDevice/SimpleBleDevice.ino @@ -0,0 +1,39 @@ +#include +#include +#include + +// See the following for generating UUIDs: +// https://www.uuidgenerator.net/ + +#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b" +#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8" + +void setup() { + Serial.begin(115200); + Serial.println("Starting BLE work!"); + + BLEDevice::init("Long name works now"); + BLEServer *pServer = BLEDevice::createServer(); + BLEService *pService = pServer->createService(SERVICE_UUID); + BLECharacteristic *pCharacteristic = pService->createCharacteristic( + CHARACTERISTIC_UUID, + BLECharacteristic::PROPERTY_READ | + BLECharacteristic::PROPERTY_WRITE + ); + + pCharacteristic->setValue("Hello World says Neil"); + pService->start(); + // BLEAdvertising *pAdvertising = pServer->getAdvertising(); // this still is working for backward compatibility + BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); + pAdvertising->addServiceUUID(SERVICE_UUID); + pAdvertising->setScanResponse(true); + pAdvertising->setMinPreferred(0x06); // functions that help with iPhone connections issue + pAdvertising->setMinPreferred(0x12); + BLEDevice::startAdvertising(); + Serial.println("Characteristic defined! Now you can read it in your phone!"); +} + +void loop() { + // put your main code here, to run repeatedly: + delay(2000); +} \ No newline at end of file diff --git a/src/lightingFirmware/SimpleBleDevice/ci.json b/src/lightingFirmware/SimpleBleDevice/ci.json new file mode 100644 index 00000000..d33a23f3 --- /dev/null +++ b/src/lightingFirmware/SimpleBleDevice/ci.json @@ -0,0 +1,6 @@ +{ + "requires": [ + "CONFIG_BT_ENABLED=y", + "CONFIG_BLUEDROID_ENABLED=y" + ] +} diff --git a/src/lightingFirmware/esp32_test0/esp32_test0.ino b/src/lightingFirmware/esp32_test0/esp32_test0.ino index d875cbe4..b45c72c9 100644 --- a/src/lightingFirmware/esp32_test0/esp32_test0.ino +++ b/src/lightingFirmware/esp32_test0/esp32_test0.ino @@ -1,19 +1,43 @@ // Include Section #include "esp_dmx.h" +#include "BluetoothSerial.h" +#include +#include +#include +// Name of Bluetooth client. +String BTDeviceName = "3D_SkyLED_LEDBoard"; +String BTMacAddress; +// Check if Bluetooth is available. +#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) +#error Bluetooth is not enabled! +#endif + +// Check if Serial Port Profile (SPP) is available. +#if !defined(CONFIG_BT_SPP_ENABLED) +#error Serial Port Profile for Bluetooth is not available or not enabled! +#endif // Define Section - -#define ledPin 2 +#define BT_DISCOVER_TIME 30000 #define INTERRUPT_PIN 0 +BluetoothSerial SerialBT; +char btmessage; + struct Button { const uint8_t PIN; uint32_t numberKeyPresses; bool pressed; }; -struct Panel [led0,led1,led2,led3]; +struct Panel { + int led0; + int led1; + int led2; + int led3; +}; + // Defining BOOT button on ESP32 as our built-in button. Button button1 = {INTERRUPT_PIN, 0, false}; @@ -150,7 +174,7 @@ uint8_t dataSeq[modeAmount][DMX_PACKET_SIZE] = { 0, //Start Inner Round - universalBrightness,0,0,0, + 0,0,universalBrightness,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, @@ -232,7 +256,9 @@ void dmxSetup() { void setup() { Serial.begin(115200); - pinMode(ledPin,OUTPUT); + SerialBT.begin(BTDeviceName); + BTMacAddress = SerialBT.getBtAddressString(); + Serial.println(BTMacAddress.c_str()); pinMode(INTERRUPT_PIN, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), isr, RISING); delay(2000); @@ -255,4 +281,8 @@ void loop() { // Now write the packet synchronously! dmx_write(DMX_NUM_1, dataSeq[mode], 100); serialRead(); + if (SerialBT.available()) { + btmessage=SerialBT.read(); + Serial.print(btmessage); + }; }