ElectronicCats / Beelan-LoRaWAN

A LoRaWAN library for compatible arduino board
https://www.beelan.mx
MIT License
189 stars 77 forks source link

Encode/Decode #42

Closed simortus closed 3 years ago

simortus commented 4 years ago

Hi, thanks for your contribution, Can you tell what encoding are you using? i get unreadable chars on chirpstack! i want to add a chirpstack repo when I finalize this. If you are around in Copenhagen, lets get that beer 👍

sabas1080 commented 4 years ago

Hi @simortus What example are you using? Beautiful Copenhagen, I hope to return soon

sabas1080 commented 3 years ago

closed due to inactivity

simortus commented 3 years ago

Hey, Sorry about the late reply, got busy with work and holidays. I hope you had a good time as well:) I am using the ABP example. I am using chirpstack loran server. Typically base64 is the go for, but no results. I use this to decode. let me know if I need to change something? Cheers. var result = ""; for(var i = 0; i < bytes.length; ++i){ result+= (String.fromCharCode(bytes[i])); } var decodedStr = (result).toString('base64'); // var decodedStr = (result).toString(); return decodedStr;

sabas1080 commented 3 years ago

@wolftrax5 can you help here?

simortus commented 3 years ago

Where ?

On Wed, 19 Aug 2020 at 16.54, Sabas notifications@github.com wrote:

@wolftrax5 https://github.com/wolftrax5 can you help here?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BeelanMX/Beelan-LoRaWAN/issues/42#issuecomment-676476103, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKQXXB5FUAF5IGZCA6DCQJLSBPRQZANCNFSM4PH4U2OQ .

-- Sent from Gmail Mobile

wolftrax5 commented 3 years ago

how you are implementing that function? and witch version of her chirpstack server are you using, can you share how are you implementing. the bytes should be an array of numbers, if you receive strings this will never return somethings and on a resents versions of chirpstack server, has a template of decode function.

const data = [65,66,67]

function decode (bytes) {
  var result = ''
  for (var i = 0; i < bytes.length; ++i) {
    result += (String.fromCharCode(bytes[i]))
  }
  var decodedStr = (result).toString('base64')
  // var decodedStr = (result).toString();
  return decodedStr
}
console.log(decode(data))
//ABC

another way to decode

sabas1080 commented 3 years ago

closed due to inactivity