Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1ff4f95919
|
|||
|
264e12853d
|
|||
|
3e8efa1934
|
|||
|
fcc77531d0
|
|||
|
04c60aac89
|
|||
|
8bb1ae6463
|
|||
|
931ffc0822
|
|||
|
747a7a4766
|
|||
|
9b65139b70
|
|||
|
043459c336
|
|||
| 4e003e8277 |
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "lib/OTALibrary"]
|
||||
path = lib/OTALibrary
|
||||
url = git@git.emaker.limited:MicrocontrollerCD/OTALibrary.git
|
||||
[submodule "lib/BLEOTA"]
|
||||
path = lib/BLEOTA
|
||||
url = git@git.emaker.limited:MicrocontrollerCD/BLEOTA.git
|
||||
|
||||
1
lib/BLEOTA
Submodule
1
lib/BLEOTA
Submodule
Submodule lib/BLEOTA added at ea11640889
Submodule lib/OTALibrary deleted from bf21b61803
@@ -12,3 +12,7 @@
|
||||
platform = espressif32
|
||||
board = esp32-c3-devkitc-02
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
build_flags =
|
||||
'-D ARDUINO_USB_MODE=1'
|
||||
'-D ARDUINO_USB_CDC_ON_BOOT=1'
|
||||
|
||||
44
src/main.cpp
44
src/main.cpp
@@ -1,13 +1,56 @@
|
||||
#include <Arduino.h>
|
||||
#include <BLEOTA.h>
|
||||
#include <BLE2902.h>
|
||||
#include <BLEDevice.h>
|
||||
#include <BLEServer.h>
|
||||
|
||||
#include "pins.h"
|
||||
|
||||
#define BLINKRATE 500
|
||||
#define BLE_SERVER_NAME "Software Release"
|
||||
|
||||
unsigned long lastBlink = 0;
|
||||
|
||||
BLEServer* pServer = NULL;
|
||||
|
||||
bool deviceConnected = false;
|
||||
|
||||
class ServerCallbacks : public BLEServerCallbacks {
|
||||
void onConnect(BLEServer* pServer) override {
|
||||
deviceConnected = true;
|
||||
}
|
||||
|
||||
void onDisconnect(BLEServer* pServer) override {
|
||||
deviceConnected = false;
|
||||
pServer->startAdvertising();
|
||||
}
|
||||
|
||||
void onMtuChanged(BLEServer* pServer, esp_ble_gatts_cb_param_t* param) override {
|
||||
Serial.print("MTU is now: ");
|
||||
Serial.println(param->mtu.mtu);
|
||||
}
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
pinMode(LED, OUTPUT);
|
||||
|
||||
BLEDevice::init(BLE_SERVER_NAME);
|
||||
|
||||
pServer = BLEDevice::createServer();
|
||||
pServer->setCallbacks(new ServerCallbacks());
|
||||
|
||||
BLEota.begin(pServer, "1.0.4");
|
||||
|
||||
BLEAdvertising* pAdvertising = BLEDevice::getAdvertising();
|
||||
pAdvertising->setScanResponse(true);
|
||||
pAdvertising->setMinPreferred(0x06);
|
||||
pAdvertising->setMinPreferred(0x12);
|
||||
BLEDevice::startAdvertising();
|
||||
BLEDevice::setMTU(512);
|
||||
|
||||
delay(1000);
|
||||
Serial.println("Started!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -15,4 +58,5 @@ void loop() {
|
||||
digitalWrite(LED, !digitalRead(LED));
|
||||
lastBlink= millis();
|
||||
}
|
||||
BLEota.loop();
|
||||
}
|
||||
Reference in New Issue
Block a user