Skip to content

Commit b50c050

Browse files
Copilotnetmindz
andcommitted
Map info response fields to upgradeData structure field by field
Co-authored-by: netmindz <[email protected]>
1 parent 366f3d3 commit b50c050

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

wled00/data/index.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,13 +3393,55 @@ function reportUpgradeEvent(info, oldVersion, newVersion) {
33933393
})
33943394
.then(res => res.json())
33953395
.then(infoData => {
3396-
// Make AJAX call to postUpgradeEvent API with fresh info data
3396+
// Map WLED info response to upgradeData structure expected by API
3397+
const upgradeData = {
3398+
// Version information
3399+
version: infoData.ver || '',
3400+
versionId: infoData.vid || 0,
3401+
3402+
// Device information
3403+
name: infoData.name || '',
3404+
brand: 'WLED',
3405+
3406+
// Hardware information
3407+
arch: infoData.arch || '',
3408+
chipModel: infoData.arch || '', // TODO: Verify if this should be different from arch
3409+
core: infoData.core || '',
3410+
flash: infoData.flash || 0,
3411+
freeHeap: infoData.freeheap || 0,
3412+
clockSpeed: infoData.clock || 0,
3413+
3414+
// LED information
3415+
ledCount: infoData.leds ? infoData.leds.count : 0,
3416+
ledPower: infoData.leds ? infoData.leds.pwr : 0,
3417+
ledMaxPower: infoData.leds ? infoData.leds.maxpwr : 0,
3418+
3419+
// Network information
3420+
ip: '', // TODO: Not available in info endpoint
3421+
mac: infoData.mac || '', // TODO: Check if mac is in info response
3422+
rssi: infoData.wifi ? infoData.wifi.rssi : 0,
3423+
signal: infoData.wifi ? infoData.wifi.signal : 0,
3424+
channel: infoData.wifi ? infoData.wifi.channel : 0,
3425+
3426+
// Feature information
3427+
fxCount: infoData.fxcount || 0,
3428+
palCount: infoData.palcount || 0,
3429+
3430+
// Runtime information
3431+
uptime: infoData.uptime || 0,
3432+
3433+
// Additional metadata
3434+
uid: infoData.mac || '', // TODO: Verify if UID should be MAC or something else
3435+
timestamp: new Date().toISOString()
3436+
};
3437+
3438+
// Make AJAX call to postUpgradeEvent API with properly structured data
33973439
return fetch('https://usage.wled.me/api/v1/usage/upgrade', {
33983440
method: 'POST',
33993441
headers: {
34003442
'Content-Type': 'application/json'
34013443
},
3402-
body: JSON.stringify(infoData)
3444+
body: JSON.stringify(upgradeData)
34033445
});
34043446
})
34053447
.then(res => {

0 commit comments

Comments
 (0)