feat: Add Arduino code for position tracking
The code changes include adding a new Arduino sketch for position tracking. The sketch is located at `code/arduino/Position-tracking/Position-tracking.ino`. Additionally, a new class `PositionSensor` is added with its corresponding header and implementation files. This class handles the position sensor functionality and includes methods for initialization and measurement. The commit message suggests that the changes are a new feature addition related to position tracking in the Arduino code.
This commit is contained in:
40
code/arduino/Position-tracking/test/test.ino
Normal file
40
code/arduino/Position-tracking/test/test.ino
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <BLEDevice.h>
|
||||
#include <BLEUtils.h>
|
||||
#include <BLEServer.h>
|
||||
|
||||
// Define the BLE service and characteristic UUIDs
|
||||
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
|
||||
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
|
||||
|
||||
void setup() {
|
||||
// Initialize the BLE environment
|
||||
BLEDevice::init("ESP32-S3");
|
||||
|
||||
// Create a BLE server
|
||||
BLEServer *pServer = BLEDevice::createServer();
|
||||
|
||||
// Create a BLE service
|
||||
BLEService *pService = pServer->createService(SERVICE_UUID);
|
||||
|
||||
// Create a BLE characteristic
|
||||
BLECharacteristic *pCharacteristic = pService->createCharacteristic(
|
||||
CHARACTERISTIC_UUID,
|
||||
BLECharacteristic::PROPERTY_READ |
|
||||
BLECharacteristic::PROPERTY_WRITE
|
||||
);
|
||||
|
||||
// Set the initial value of the characteristic
|
||||
pCharacteristic->setValue("Hello, World!");
|
||||
|
||||
// Start the service
|
||||
pService->start();
|
||||
|
||||
// Start advertising the BLE service
|
||||
BLEAdvertising *pAdvertising = pServer->getAdvertising();
|
||||
pAdvertising->addServiceUUID(SERVICE_UUID);
|
||||
pAdvertising->start();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Nothing to do here for this example
|
||||
}
|
Reference in New Issue
Block a user