brocaar / chirpstack-network-server

ChirpStack Network Server is an open-source LoRaWAN network-server.
https://www.chirpstack.io
MIT License
1.49k stars 546 forks source link

Network Controller - Sending Mac Commands #80

Closed leotseng1977 closed 8 years ago

leotseng1977 commented 8 years ago

hi, brocaar,

Now it's working fine to use mosquitto_sub/mosquitto_pub to send/get rx/tx data followed by your loraserver document :smile: thx a LOT.

And then I want to try mac command, could you guide me what value I need to fill in macCommand field?

e.g. To send 'DevStatusReq' so I sent mosquitto_pub -t 'application/0000000000000000/node/363730364192a679/mac/tx' -m '{"reference":"abcd1234","devEUI":"363730364192a679","frmPayload":true,"macCommand":"MDY="}' ==> but it's failed to let me node get payload datat PS. I already transferred CID value '06' to 'MDY=' (Base64) :worried:

Besides, I monitored the error notification by using mosquitto_sub -t "application/0000000000000000/node/+/mac/error" -v. I got this error message: application/0000000000000000/node/363730364192a679/mac/error {"reference":"abcd1234","devEUI":"363730364192a679","message":"unmarshal mac command error: lorawan: invalid CID 30"}

==> where did it go wrong?

leotseng1977 commented 8 years ago

hi, all, I found how it works and I have to admit I misunderstood what mac command filed means... "06" are characters so their hex data are 0x30 & 0x31 from ASCII table, so I should produce a binary file only contains 0x06 hex value. And then use some tool like this website providing "http://www.motobit.com/util/base64-decoder-encoder.asp"

So the base64 format of binary data 0x06 is "Bg==" instead of "MDY=" which is converted from "06" two characters.

Problem solved and thanks for brocaar's kindness..