Improved attempts, still need encyption

This commit is contained in:
2026-06-04 22:32:27 +10:00
parent 4ea1e12ee9
commit 890feae060
8 changed files with 733 additions and 7 deletions
+19
View File
@@ -0,0 +1,19 @@
[env]
lib_extra_dirs = ../..
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
[env:esp32-s3]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
build_flags =
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
+93
View File
@@ -0,0 +1,93 @@
/**
* BluettiADV Monitor Example
*
* READ-ONLY monitoring of newer (encrypted) Bluetti devices — Elite / V2 /
* EP600 etc. — via their BLE advertisement broadcast. No connection, no pairing.
*
* Setup:
* 1. Get the 16-byte AES key (32 hex chars) from the BLUETTI app or the device
* Webserver (look for the Bluetooth data / developer section).
* 2. Get the device's BLE MAC address (a BLE scanner app shows it; the unit
* broadcasts manufacturer data starting "06 0F").
* 3. Fill both in below.
*/
#include <Arduino.h>
#include "BluettiADV.h"
BluettiADV bluetti;
static const char* chargeStatusName(uint8_t s) {
switch (s) {
case 0: return "idle";
case 1: return "charging";
case 2: return "discharging";
default: return "?";
}
}
void onBluettiAdv(const BluettiAdvDevice* dev) {
Serial.printf("\n=== %s (model 0x%04X, rssi %d, %s) record 0x%02X ===\n",
dev->name, dev->modelId, dev->rssi,
dev->connectedFlag ? "app-connected" : "free", dev->lastRecordType);
switch (dev->lastRecordType) {
case BLUETTI_ADV_MONITORING: {
const auto& m = dev->monitoring;
Serial.printf("SoC: %u%%\n", m.soc);
Serial.printf("Input: %u W Output: %u W\n", m.inputPower, m.outputPower);
Serial.printf("Battery: %s\n", chargeStatusName(m.batteryChargeStatus));
if (m.estimatedTimeMin && m.estimatedTimeMin != 0xFFFF)
Serial.printf("Est. time: %uh %um\n", m.estimatedTimeMin / 60, m.estimatedTimeMin % 60);
if (m.alarm) Serial.println("ALARM");
Serial.printf("Events: 0x%04X\n", m.eventLine);
break;
}
case BLUETTI_ADV_BATTERY: {
const auto& b = dev->battery;
Serial.printf("SoC: %.1f%%\n", b.soc);
Serial.printf("Pack: %.1f V %.3f A %.1f C\n",
b.totalVoltage, b.totalCurrent, b.avgTemperatureC);
if (b.alarmCode) Serial.printf("Alarm code: 0x%04X\n", b.alarmCode);
break;
}
case BLUETTI_ADV_INVERTER: {
const auto& i = dev->inverter;
Serial.printf("Battery: %.1f V %.1f A\n", i.batteryVoltage, i.batteryCurrent);
Serial.printf("AC out: %d W PV: %u W\n", i.acOutputPower, i.pvPower);
Serial.printf("Yield today: %.2f kWh\n", i.yieldToday);
break;
}
case BLUETTI_ADV_CONFIG: {
const auto& c = dev->config;
Serial.printf("Inverter mode: %u Charging mode: %u\n", c.inverterMode, c.chargingMode);
Serial.printf("AC ECO: %u DC ECO: %u Power lifting: %s\n",
c.acEcoMode, c.dcEcoMode, c.powerLifting ? "on" : "off");
break;
}
}
}
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("\n\n=============================");
Serial.println("BluettiADV Monitor Example");
Serial.println("=============================\n");
bluetti.begin(5);
bluetti.setDebug(true); // prints discovered devices + decrypted payloads
bluetti.setCallback(onBluettiAdv);
// CHANGE THESE: your device's BLE MAC and the 16-byte AES key (32 hex chars).
bluetti.addDevice("My Elite", "AA:BB:CC:DD:EE:FF",
"112233445566778899aabbccddeeff00");
Serial.printf("Configured %d device(s). Scanning advertisements...\n",
(int)bluetti.getDeviceCount());
}
void loop() {
bluetti.loop();
}