Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 78 additions & 9 deletions wled00/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3413,13 +3413,25 @@ function showVersionUpgradePrompt(info, oldVersion, newVersion) {

function reportUpgradeEvent(info, oldVersion, alwaysReport) {
showToast('Reporting upgrade...');
const IR_TYPES = {
0: null, // not configured — omit field entirely
1: "3-key",
2: "24-key",
3: "24-key-v2",
4: "40-key",
5: "44-key",
6: "21-key",
7: "6-key",
8: "9-key",
9: "json-remote",
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// Fetch fresh data from /json/info endpoint as requested
fetch(getURL('/json/info'), {
method: 'get'
})
.then(res => res.json())
.then(infoData => {
// Fetch fresh data from /json/info and /json/cfg endpoints
Promise.all([
fetch(getURL('/json/info'), {method: 'get'}).then(res => res.json()),
fetch(getURL('/json/cfg'), {method: 'get'}).then(res => res.json())
])
.then(([infoData, cfgData]) => {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
// Map to UpgradeEventRequest structure per OpenAPI spec
// Required fields: deviceId, version, previousVersion, releaseName, chip, ledCount, isMatrix, bootloaderSHA256
const upgradeData = {
Expand All @@ -3434,13 +3446,59 @@ function reportUpgradeEvent(info, oldVersion, alwaysReport) {
brand: infoData.brand, // Device brand (always present)
product: infoData.product, // Product name (always present)
flashSize: infoData.flash, // Flash size (always present)
repo: infoData.repo // GitHub repository (always present)
};
repo: infoData.repo, // GitHub repository (always present)
fsUsed: infoData.fs?.u, // Filesystem used space in kB
fsTotal: infoData.fs?.t, // Filesystem total space in kB

// LED hardware
busCount: cfgData.hw?.led?.ins?.length ?? 1,
busTypes: (cfgData.hw?.led?.ins ?? []).map(b => busTypeToString(b.type)),
matrixWidth: infoData.leds?.matrix?.w,
matrixHeight: infoData.leds?.matrix?.h,
ledFeatures: [
...(infoData.leds?.lc & 0x02 ? ["rgbw"] : []),
...(infoData.leds?.lc & 0x04 ? ["cct"] : []),
...((infoData.leds?.maxpwr ?? 0) > 0 ? ["abl"] : []),
...(cfgData.hw?.led?.cr ? ["cct-from-rgb"] : []),
...(cfgData.hw?.led?.cct ? ["white-balance"] : []),
...((cfgData.light?.gc?.col ?? 1.0) > 1.0 ? ["gamma"] : []),
...(cfgData.light?.aseg ? ["auto-segments"] : []),
...((cfgData.light?.nl?.mode ?? 0) > 0 ? ["nightlight"] : []),
],
Comment thread
netmindz marked this conversation as resolved.

// peripherals
peripherals: [
...((cfgData.hw?.relay?.pin ?? -1) >= 0 ? ["relay"] : []),
...((cfgData.hw?.btn?.ins ?? []).some(b => b.type !== 0) ? ["buttons"] : []),
...((cfgData.hw?.if?.['i2c-pin']?.[0] ?? -1) >= 0 ? ["i2c"] : []),
...((cfgData.hw?.if?.['spi-pin']?.[0] ?? -1) >= 0 ? ["spi"] : []),
Comment thread
netmindz marked this conversation as resolved.
Outdated
...((cfgData.eth?.type ?? 0) > 0 ? ["ethernet"] : []),
...((cfgData.if?.live?.dmx?.inputRxPin ?? 0) > 0 ? ["dmx-input"] : []),
...((cfgData.hw?.ir?.type ?? 0) > 0 ? ["ir-remote"] : []),
],
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// integrations
integrations: [
...(cfgData.if?.hue?.en ? ["hue"] : []),
...(cfgData.if?.mqtt?.en ? ["mqtt"] : []),
...(cfgData.if?.va?.alexa ? ["alexa"] : []),
...(cfgData.if?.sync?.send?.en ? ["wled-sync"] : []),
...(cfgData.nw?.espnow ? ["esp-now"] : []),
...(cfgData.if?.sync?.espnow ? ["esp-now-sync"] : []),
],

// usermods
usermods: Object.keys(cfgData.um ?? {}),
usermodIds: infoData.um ?? [],
};

// IR remote — only include if configured
const irType = IR_TYPES[cfgData.hw?.ir?.type ?? 0];
if (irType) upgradeData.irRemoteType = irType;

// Add optional fields if available
if (infoData.psrSz !== undefined) upgradeData.psramSize = infoData.psrSz; // Total PSRAM size in MB; can be 0

// Note: partitionSizes not currently available in /json/info endpoint

// Make AJAX call to postUpgradeEvent API
return fetch('https://usage.wled.me/api/usage/upgrade', {
Expand Down Expand Up @@ -3471,6 +3529,17 @@ function reportUpgradeEvent(info, oldVersion, alwaysReport) {
});
}

function busTypeToString(t) {
if (t === 0) return "none";
if (t === 40) return "on-off";
if (t >= 16 && t <= 39) return "digital"; // WS2812, SK6812, etc.
if (t >= 41 && t <= 47) return "pwm"; // analog RGB/CCT/single
if (t >= 48 && t <= 63) return "digital-spi"; // APA102, WS2801, etc.
if (t >= 64 && t <= 71) return "hub75"; // HUB75 matrix panels
if (t >= 80 && t <= 95) return "network"; // DDP, E1.31, ArtNet
return "unknown";
}

function updateVersionInfo(version, neverAsk, alwaysReport) {
const versionInfo = {
version: version,
Expand Down
Loading