Initial commit

This commit is contained in:
2026-05-08 10:55:59 -06:00
parent bfb60d1e0c
commit b43782cf9f
9 changed files with 677 additions and 0 deletions
+2
View File
@@ -12,3 +12,5 @@
# Built Visual Studio Code Extensions # Built Visual Studio Code Extensions
*.vsix *.vsix
.pio
.venv
+10
View File
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
+44
View File
@@ -0,0 +1,44 @@
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
//
// PlatformIO Debugging Solution
//
// Documentation: https://docs.platformio.org/en/latest/plus/debugging.html
// Configuration: https://docs.platformio.org/en/latest/projectconf/sections/env/options/debug/index.html
{
"version": "0.2.0",
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "/home/semarnat/Gitea/Programacion-II/BLUE_ESP32/.pio/build/esp32-s3-devkitc-1/firmware.elf",
"projectEnvName": "esp32-s3-devkitc-1",
"toolchainBinDir": "/home/semarnat/.platformio/packages/toolchain-xtensa-esp32s3/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "/home/semarnat/Gitea/Programacion-II/BLUE_ESP32/.pio/build/esp32-s3-devkitc-1/firmware.elf",
"projectEnvName": "esp32-s3-devkitc-1",
"toolchainBinDir": "/home/semarnat/.platformio/packages/toolchain-xtensa-esp32s3/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (without uploading)",
"executable": "/home/semarnat/Gitea/Programacion-II/BLUE_ESP32/.pio/build/esp32-s3-devkitc-1/firmware.elf",
"projectEnvName": "esp32-s3-devkitc-1",
"toolchainBinDir": "/home/semarnat/.platformio/packages/toolchain-xtensa-esp32s3/bin",
"internalConsoleOptions": "openOnSessionStart",
"loadMode": "manual"
}
]
}
+37
View File
@@ -0,0 +1,37 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the convention is to give header files names that end with `.h'.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
+46
View File
@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into the executable file.
The source code of each library should be placed in a separate directory
("lib/your_library_name/[Code]").
For example, see the structure of the following example libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
Example contents of `src/main.c` using Foo and Bar:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
The PlatformIO Library Dependency Finder will find automatically dependent
libraries by scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html
+15
View File
@@ -0,0 +1,15 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
File diff suppressed because one or more lines are too long
+79
View File
@@ -0,0 +1,79 @@
#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <BLE2902.h>
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;
int contador = 0;
// UUIDs únicos (puedes generar los tuyos en uuidgenerator.net)
#define SERVICE_UUID "794ff2e6-d4ac-4b80-b97e-dad2d577f17b"
#define CHARACTERISTIC_UUID "26dc4777-a57b-4caa-8a55-2be55a5663c6"
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
// Reiniciar publicidad para permitir reconexión
pServer->getAdvertising()->start();
}
};
void setup() {
Serial.begin(115200);
// Inicializar dispositivo
BLEDevice::init("Debian BLE Server");
// Crear Servidor BLE
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
// Crear Servicio
BLEService *pService = pServer->createService(SERVICE_UUID);
// Crear Característica con Notificación
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY
);
// Descriptor necesario para notificaciones (Client Characteristic Configuration)
pCharacteristic->addDescriptor(new BLE2902());
pService->start();
// Iniciar Publicidad (Advertising)
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
pAdvertising->setScanResponse(true);
pAdvertising->start();
Serial.print("Dirección del dispositivo: ");
Serial.println(BLEDevice::getAddress().toString().c_str());
Serial.println("Esperando conexión BLE...");
}
void loop() {
if (deviceConnected) {
if (contador <= 100) {
char str[10];
itoa(contador, str, 10); // Convertir int a string
pCharacteristic->setValue(str);
pCharacteristic->notify(); // Enviar valor a la PC
Serial.printf("Enviando: %d\n", contador);
contador++;
} else {
contador = 0; // Reiniciar si llega a 100
}
delay(1000); // Enviar cada segundo
}
}
+11
View File
@@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html