TODO and m5stick and debug
This commit is contained in:
4
TODO
Normal file
4
TODO
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Misc Stuff
|
||||||
|
|
||||||
|
* Consider support for upper/lower case MAC address and optionaly ":"
|
||||||
|
* Scanning - list devices publishing, should be able to get list even without knowing MAC / Encryption key
|
||||||
@@ -36,3 +36,24 @@ framework = arduino
|
|||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
build_flags =
|
build_flags =
|
||||||
-DCORE_DEBUG_LEVEL=3
|
-DCORE_DEBUG_LEVEL=3
|
||||||
|
|
||||||
|
[env:m5stick]
|
||||||
|
platform = espressif32
|
||||||
|
board = m5stick-c
|
||||||
|
framework = arduino
|
||||||
|
board_build.mcu = esp32
|
||||||
|
board_build.f_cpu = 240000000L
|
||||||
|
board_build.partitions = no_ota.csv
|
||||||
|
#upload_protocol = espota
|
||||||
|
#upload_port = Button.local
|
||||||
|
monitor_speed = 115200
|
||||||
|
monitor_filters = esp32_exception_decoder
|
||||||
|
build_flags =
|
||||||
|
-Os
|
||||||
|
lib_deps =
|
||||||
|
M5StickC
|
||||||
|
elapsedMillis
|
||||||
|
TaskScheduler
|
||||||
|
Button2
|
||||||
|
ArduinoJson
|
||||||
|
https://github.com/scottp/PsychicHttp.git
|
||||||
|
|||||||
@@ -165,6 +165,14 @@ void setup() {
|
|||||||
// Add your devices here
|
// Add your devices here
|
||||||
// Replace with your actual MAC addresses and encryption keys
|
// Replace with your actual MAC addresses and encryption keys
|
||||||
|
|
||||||
|
// Temporary - Scott Example
|
||||||
|
victron.addDevice(
|
||||||
|
"Rainbow48V", // Device name
|
||||||
|
"E4:05:42:34:14:F3", // MAC address
|
||||||
|
"0ec3adf7433dd61793ff2f3b8ad32ed8", // Encryption key (32 hex chars)
|
||||||
|
DEVICE_TYPE_SOLAR_CHARGER // Device type
|
||||||
|
);
|
||||||
|
|
||||||
// Example: Solar Charger #1
|
// Example: Solar Charger #1
|
||||||
victron.addDevice(
|
victron.addDevice(
|
||||||
"MPPT 100/30", // Device name
|
"MPPT 100/30", // Device name
|
||||||
|
|||||||
@@ -133,6 +133,30 @@ void VictronBLE::loop() {
|
|||||||
// BLE callback implementation
|
// BLE callback implementation
|
||||||
void VictronBLEAdvertisedDeviceCallbacks::onResult(BLEAdvertisedDevice advertisedDevice) {
|
void VictronBLEAdvertisedDeviceCallbacks::onResult(BLEAdvertisedDevice advertisedDevice) {
|
||||||
if (victronBLE) {
|
if (victronBLE) {
|
||||||
|
// Debug: Log all discovered BLE devices
|
||||||
|
if (victronBLE->debugEnabled) {
|
||||||
|
String mac = victronBLE->macAddressToString(advertisedDevice.getAddress());
|
||||||
|
String debugMsg = "BLE Device: " + mac;
|
||||||
|
debugMsg += ", RSSI: " + String(advertisedDevice.getRSSI()) + " dBm";
|
||||||
|
|
||||||
|
if (advertisedDevice.haveName()) {
|
||||||
|
debugMsg += ", Name: " + String(advertisedDevice.getName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (advertisedDevice.haveManufacturerData()) {
|
||||||
|
std::string mfgData = advertisedDevice.getManufacturerData();
|
||||||
|
if (mfgData.length() >= 2) {
|
||||||
|
uint16_t mfgId = (uint8_t)mfgData[1] << 8 | (uint8_t)mfgData[0];
|
||||||
|
debugMsg += ", Mfg ID: 0x" + String(mfgId, HEX);
|
||||||
|
if (mfgId == VICTRON_MANUFACTURER_ID) {
|
||||||
|
debugMsg += " (Victron)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
victronBLE->debugPrint(debugMsg);
|
||||||
|
}
|
||||||
|
|
||||||
victronBLE->processDevice(advertisedDevice);
|
victronBLE->processDevice(advertisedDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,6 +169,35 @@ void VictronBLE::processDevice(BLEAdvertisedDevice advertisedDevice) {
|
|||||||
// Check if this is one of our configured devices
|
// Check if this is one of our configured devices
|
||||||
auto it = devices.find(normalizedMAC);
|
auto it = devices.find(normalizedMAC);
|
||||||
if (it == devices.end()) {
|
if (it == devices.end()) {
|
||||||
|
|
||||||
|
// XXX Check if the device is a Victron device
|
||||||
|
// This needs lots of improvemet and only do in debug
|
||||||
|
if (advertisedDevice.haveManufacturerData()) {
|
||||||
|
std::string mfgData = advertisedDevice.getManufacturerData();
|
||||||
|
if (mfgData.length() >= 2) {
|
||||||
|
uint16_t mfgId = (uint8_t)mfgData[1] << 8 | (uint8_t)mfgData[0];
|
||||||
|
if (mfgId == VICTRON_MANUFACTURER_ID) {
|
||||||
|
debugPrint("Found unmonitored Victron Device: " + mac);
|
||||||
|
// DeviceInfo* deviceInfo = new DeviceInfo(mac, advertisedDevice.getName());
|
||||||
|
// devices.insert({normalizedMAC, deviceInfo});
|
||||||
|
// XXX What type of Victron device is it?
|
||||||
|
// Check if it's a Victron Energy device
|
||||||
|
/*
|
||||||
|
if (advertisedDevice.haveServiceData()) {
|
||||||
|
std::string serviceData = advertisedDevice.getServiceData();
|
||||||
|
if (serviceData.length() >= 2) {
|
||||||
|
uint16_t serviceId = (uint8_t)serviceData[1] << 8 | (uint8_t)serviceData[0];
|
||||||
|
if (serviceId == VICTRON_ENERGY_SERVICE_ID) {
|
||||||
|
debugPrint("Found Victron Energy Device: " + mac);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return; // Not a device we're monitoring
|
return; // Not a device we're monitoring
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,7 +657,9 @@ String VictronBLE::macAddressToString(BLEAddress address) {
|
|||||||
String VictronBLE::normalizeMAC(String mac) {
|
String VictronBLE::normalizeMAC(String mac) {
|
||||||
String normalized = mac;
|
String normalized = mac;
|
||||||
normalized.toLowerCase();
|
normalized.toLowerCase();
|
||||||
normalized.replace("-", ":");
|
// XXX - is this right, was - to : but not consistent location of pairs or not
|
||||||
|
normalized.replace("-", "");
|
||||||
|
normalized.replace(":", "");
|
||||||
return normalized;
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user