Doridian / Doridian/OpenBambuAPI

[Feature Request] HMS Code mapping

Aperta
#5 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Nessun dato sulla lingua
Stelle
682
Fork
96
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Wasn't sure where this would fit in the current layout, so I will give my findings here.

In the report print payload for all sensors (or a subset if the P1P as it does not send all unless pushall is invoked), there is the value `hms` with an array.

If it contains values, it is as such:
```json
"hms": [
{
"code": "somecode",
"attr": "somecode"
},
{
"code": "somecode",
"attr": "somecode"
}
]
```

The codes and attributes are not recognizable at first, but can be mapped to errors. Both the code and attr are decimal numbers that when converted to Hex with Two's complement, then append the code after the attr and separate each set of 4 character with an underscore, it will be in the format of Bambu's official HMS code errors as per their website.

Note: Not all hms codes are documented yet.

Here is a snippet of how I convert them in nodered:
```js
function DecimalHexTwosComplement(decimal) {
var size = 8;
var hexadecimal;
if (decimal >= 0) {
hexadecimal = decimal.toString(16);

while ((hexadecimal.length % size) != 0) {
hexadecimal = "" + 0 + hexadecimal;
}

return hexadecimal;
} else {
hexadecimal = Math.abs(decimal).toString(16);
while ((hexadecimal.length % size) != 0) {
hexadecimal = "" + 0 + hexadecimal;
}

var output = '';
for (var i = 0; i < hexadecimal.length; i++) {
output += (0x0F - parseInt(hexadecimal[i], 16)).toString(16);
}

output = (0x01 + parseInt(output, 16)).toString(16);
return output;
}
}

let template = [];
if(msg.payload.print.hms != undefined){
for (var hms_code of msg.payload.print.hms) {
var attr = DecimalHexTwosComplement(hms_code.attr);
var code = DecimalHexTwosComplement(hms_code.code);
let full_code = (attr + code).replace(/(.{4})/g, "$1_");
full_code = full_code.substring(0, full_code.length - 1);
let url = "https://wiki.bambulab.com/en/x1/troubleshooting/hmscode/"+full_code;
template.push({"code": "HMS_"+full_code, "url": url});
}
msg.payload.print.hms = template;
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Iniziare ispezionando l’array `hms` del payload del report di stampa e lo snippet di conversione Node-RED fornito. Confrontare i valori decimali di `attr` e `code` con la documentazione collegata dei codici HMS di Bambu; i criteri di completamento e la posizione dell’implementazione devono ancora essere concordati, perché l’issue non identifica un punto di ingresso del progetto né la forma prevista dell’API.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.