UniCT-ARSLab / LWN-Simulator

A LoRaWAN nodes' and network simulator that works with a real LoRaWAN environment (such as Chirpstack) and equipped with a web interface for real-time interaction.
MIT License
81 stars 50 forks source link

sending hex str in device chirpstack #8

Closed iotgeeksameer closed 1 year ago

iotgeeksameer commented 1 year ago

Hi I tried sending "51282412059f23190000000000000000000000000000000000000000000000000000000000000000" in device payload and i am getting base64 encoded data on chirpstack as NTEyODI0MTIwNTlmMjMxOTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA=

whereas expected encoded data is USgkEgWfIxkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==

i tried finding the issue and in order to get this data correctly i need to do a hex decode , but i am not sure where to do it

i am addding the sample sudo code here

package main

import ( "encoding/base64" "encoding/hex" "fmt" )

func main() { fmt.Printf("expected: \n USgkEgWfIxkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==") payload := "51282412059f23190000000000000000000000000000000000000000000000000000000000000000"

current_output := base64.StdEncoding.EncodeToString([]byte(payload))
db := decodeHex([]byte(payload))
expected_output := base64.StdEncoding.EncodeToString(db)

fmt.Printf("\noriginal encoding \n %s\n", current_output)
fmt.Printf("new encoding \n %s\n", expected_output)

}

func decodeHex(input []byte) []byte { db := make([]byte, hex.DecodedLen(len(input))) hex.Decode(db, input) return db }

kindly suggest where this decodeHex needs to be put

fedyfausto commented 1 year ago

We are working on improving this feature! Then the normal send does not work?

fedyfausto commented 1 year ago

Closing the issue because is considered solved