Send vendor information on handshake (#461)

* Send vendor information on handshake

Embed vendor information into build parameters & defines so SlimeVR vendors can maintain their own firmware updates without adding new boards

Bump protocol version to 21

* Fix build flags quotes

* Report in GET TEST if magnetometer is not found

* Remove vendor flags from platformio.ini

* Fix 0 byte string sending and check for lengths

* Formatting

* Make sure the size assert actually works

* Formatting

* Update src/globals.h

Co-authored-by: unlogisch04 <98281608+unlogisch04@users.noreply.github.com>

* Log vendor information

* Formatting

---------

Co-authored-by: gorbit99 <gorbitgames@gmail.com>
Co-authored-by: unlogisch04 <98281608+unlogisch04@users.noreply.github.com>
This commit is contained in:
Eiren Rain
2025-06-23 13:31:50 +03:00
committed by GitHub
parent d45bbddb73
commit 68a38fba7d
6 changed files with 120 additions and 4 deletions

View File

@@ -20,6 +20,11 @@ board = esp12e
build_flags =
${env.build_flags}
-D BOARD=BOARD_SLIMEVR
-D VENDOR_NAME='"SlimeVR"'
-D VENDOR_URL='"https://slimevr.dev"'
-D PRODUCT_NAME='"SlimeVR Tracker"'
-D UPDATE_ADDRESS='"SlimeVR/SlimeVR-Tracker-ESP"'
-D UPDATE_NAME='"BOARD_SLIMEVR-firmware"'
[env:BOARD_SLIMEVR_V1_2]
platform = espressif8266 @ 4.2.1
@@ -27,6 +32,11 @@ board = esp12e
build_flags =
${env.build_flags}
-D BOARD=BOARD_SLIMEVR_V1_2
-D VENDOR_NAME='"SlimeVR"'
-D VENDOR_URL='"https://slimevr.dev"'
-D PRODUCT_NAME='"SlimeVR Tracker v1.2"'
-D UPDATE_ADDRESS='"SlimeVR/SlimeVR-Tracker-ESP"'
-D UPDATE_NAME='"BOARD_SLIMEVR_V1_2-firmware"'
[env:BOARD_SLIMEVR_DEV]
platform = espressif8266 @ 4.2.1
@@ -34,6 +44,8 @@ board = esp12e
build_flags =
${env.build_flags}
-D BOARD=BOARD_SLIMEVR_DEV
-D VENDOR_NAME='"SlimeVR"'
-D PRODUCT_NAME='"SlimeVR Tracker (dev)"'
[env:BOARD_GLOVE_IMU_SLIMEVR_DEV]
platform = espressif32 @ 6.7.0
@@ -44,6 +56,7 @@ build_flags =
${env.build_flags}
-DESP32C3
-D BOARD=BOARD_GLOVE_IMU_SLIMEVR_DEV
-D PRODUCT_NAME='"SlimeVR Glove (dev)"'
board = lolin_c3_mini
[env:BOARD_NODEMCU]

View File

@@ -94,7 +94,7 @@
// Not recommended for production
#define ENABLE_INSPECTION false
#define PROTOCOL_VERSION 20
#define PROTOCOL_VERSION 21
#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "UNKNOWN"

View File

@@ -52,3 +52,23 @@
#ifndef EXPERIMENTAL_BNO_DISABLE_ACCEL_CALIBRATION
#define EXPERIMENTAL_BNO_DISABLE_ACCEL_CALIBRATION true
#endif
#ifndef VENDOR_NAME
#define VENDOR_NAME "Unknown"
#endif
#ifndef VENDOR_URL
#define VENDOR_URL ""
#endif
#ifndef PRODUCT_NAME
#define PRODUCT_NAME "DIY SlimeVR Tracker"
#endif
#ifndef UPDATE_ADDRESS
#define UPDATE_ADDRESS ""
#endif
#ifndef UPDATE_NAME
#define UPDATE_NAME ""
#endif

View File

@@ -66,6 +66,38 @@ void setup() {
logger.info("SlimeVR v" FIRMWARE_VERSION " starting up...");
char vendorBuffer[512];
size_t writtenLength;
if (strlen(VENDOR_URL) == 0) {
sprintf(
vendorBuffer,
"Vendor: %s, product: %s%n",
VENDOR_NAME,
PRODUCT_NAME,
&writtenLength
);
} else {
sprintf(
vendorBuffer,
"Vendor: %s (%s), product: %s%n",
VENDOR_NAME,
VENDOR_URL,
PRODUCT_NAME,
&writtenLength
);
}
if (strlen(UPDATE_ADDRESS) > 0 && strlen(UPDATE_NAME) > 0) {
sprintf(
vendorBuffer + writtenLength,
", firmware update url: %s, name: %s",
UPDATE_ADDRESS,
UPDATE_NAME
);
}
logger.info("%s", vendorBuffer);
statusManager.setStatus(SlimeVR::Status::LOADING, true);
ledManager.setup();

View File

@@ -23,6 +23,8 @@
#include "connection.h"
#include <string_view>
#include "GlobalVars.h"
#include "logging/Logger.h"
#include "packets.h"
@@ -163,10 +165,14 @@ bool Connection::sendPacketNumber() {
}
bool Connection::sendShortString(const char* str) {
uint8_t size = strlen(str);
size_t size = strlen(str);
MUST_TRANSFER_BOOL(sendByte(size));
MUST_TRANSFER_BOOL(sendBytes((const uint8_t*)str, size));
assert(size <= 255);
MUST_TRANSFER_BOOL(sendByte(static_cast<uint8_t>(size)));
if (size > 0) {
MUST_TRANSFER_BOOL(sendBytes((const uint8_t*)str, size));
}
return true;
}
@@ -373,6 +379,16 @@ void Connection::sendTrackerDiscovery() {
// Tracker type to hint the server if it's a glove or normal tracker or
// something else
MUST_TRANSFER_BOOL(sendByte(static_cast<uint8_t>(TRACKER_TYPE)));
static_assert(std::string_view{VENDOR_NAME}.size() <= 255);
MUST_TRANSFER_BOOL(sendShortString(VENDOR_NAME));
static_assert(std::string_view{VENDOR_URL}.size() <= 255);
MUST_TRANSFER_BOOL(sendShortString(VENDOR_URL));
static_assert(std::string_view{PRODUCT_NAME}.size() <= 255);
MUST_TRANSFER_BOOL(sendShortString(PRODUCT_NAME));
static_assert(std::string_view{UPDATE_ADDRESS}.size() <= 255);
MUST_TRANSFER_BOOL(sendShortString(UPDATE_ADDRESS));
static_assert(std::string_view{UPDATE_NAME}.size() <= 255);
MUST_TRANSFER_BOOL(sendShortString(UPDATE_NAME));
return true;
},
0

View File

@@ -155,6 +155,39 @@ void printState() {
statusManager.getStatus(),
WiFiNetwork::getWiFiState()
);
char vendorBuffer[512];
size_t writtenLength;
if (strlen(VENDOR_URL) == 0) {
sprintf(
vendorBuffer,
"Vendor: %s, product: %s%n",
VENDOR_NAME,
PRODUCT_NAME,
&writtenLength
);
} else {
sprintf(
vendorBuffer,
"Vendor: %s (%s), product: %s%n",
VENDOR_NAME,
VENDOR_URL,
PRODUCT_NAME,
&writtenLength
);
}
if (strlen(UPDATE_ADDRESS) > 0 && strlen(UPDATE_NAME) > 0) {
sprintf(
vendorBuffer + writtenLength,
", firmware update url: %s, name: %s",
UPDATE_ADDRESS,
UPDATE_NAME
);
}
logger.info("%s", vendorBuffer);
for (auto& sensor : sensorManager.getSensors()) {
logger.info(
"Sensor[%d]: %s (%.3f %.3f %.3f %.3f) is working: %s, had data: %s",
@@ -296,6 +329,8 @@ void cmdGet(CmdParser* parser) {
const char* mag = sensor0->getAttachedMagnetometer();
if (mag) {
logger.info("[TEST] Sensor[0] magnetometer: %s", mag);
} else {
logger.info("[TEST] Sensor[0] has no magnetometer attached");
}
if (!sensor0->getHadData()) {