Skip to content

Commit

Permalink
Added BLE Test fw
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Dec 9, 2024
1 parent 100b0a6 commit b1f5e37
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
48 changes: 48 additions & 0 deletions examples/BLE/BLE_server/BLE_server.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleServer.cpp
Ported to Arduino ESP32 by Evandro Copercini
updates by chegewara
*/

// note : Example to test whether the BLE function of the board is normal

#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>

// 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("LilyGo-BLE");
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);
}
14 changes: 14 additions & 0 deletions firmware/BLE/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# BLE Firmware

## 1. Firmware to test whether the BLE function of the board is normal

* **esp32_ble_server.bin** For esp32 , Write address 0x0
* **esp32s3_ble_server.bin** For esp32s3 , Write address 0x0
* How to write firmware, please see [here](../GPS_Reset/README.MD)






Binary file added firmware/BLE/esp32_ble_server.bin
Binary file not shown.
Binary file added firmware/BLE/esp32s3_ble_server.bin
Binary file not shown.

0 comments on commit b1f5e37

Please sign in to comment.