Skip to content

Commit

Permalink
Fix ELRS UUID (#4096)
Browse files Browse the repository at this point in the history
Fix Buffer.from
  • Loading branch information
haslinghuis authored Jul 10, 2024
1 parent 3cffa09 commit e6a48ce
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/js/tabs/receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ receiver.initialize = function (callback) {
if (text) {
const bindingPhraseFull = `-DMY_BINDING_PHRASE="${text}"`;
const hash = CryptoES.MD5(bindingPhraseFull).toString();
uidBytes = Uint8Array.from(Buffer.from(hash, 'hex')).subarray(0, 6);
// Buffer.from is not available in the browser
const bytes = hash.match(/.{1,2}/g).map(byte => parseInt(byte, 16));
const view = new DataView(new ArrayBuffer(6));
for (let i = 0; i < 6; i++) {
view.setUint8(i, bytes[i]);
}
uidBytes = Array.from(new Uint8Array(view.buffer));
}

return uidBytes;
Expand Down

0 comments on commit e6a48ce

Please sign in to comment.