This is the code I am using to convert my double value into hexadecimal .
Now I need to decode this hexa decimal value to double/float in payload formatter.
Please let me know if there is any code available for it
uint64_t GetHexValue(long double f, unsigned bits, unsigned expBits)
{
long double fNorm;
int shift;
long long sign, exp, significand;
unsigned significandBits = bits - expBits - 1; // -1 for sign bit
if (f == 0.0) return 0; // get this special case out of the way
// check sign and begin normalization
if (f < 0) { sign = 1; fNorm = -f; }
else { sign = 0; fNorm = f; }
// get the normalized form of f and track the exponent
shift = 0;
while(fNorm >= 2.0) { fNorm /= 2.0; shift++; }
while(fNorm < 1.0) { fNorm *= 2.0; shift--; }
fNorm = fNorm - 1.0;
// calculate the binary form (non-float) of the significand data
significand = fNorm * ((1LL<<significandBits) + 0.5f);
// get the biased exponent
exp = shift + ((1<<(expBits-1)) - 1); // shift + bias
// return the final answer
return (sign<<(bits-1)) | (exp<<(bits-expBits-1)) | significand;
}
Hello
First of all ,I would like to thank all the people who have guided me to achieve my results by commenting on my post.
I am able to send the data successfully to TTN.
I am using LORA RN2483 module.
the response of the device is taking some time.is there any way to reduce the time of response .
I am sending the commads specific to RN2483 module. example : “mac tx uncnf 1 45667”
The device is sending the data for every half a second i.e 500 mili second.(sometimes i might need to send data very quickly )
the response of the device takes 2 sec.
I need the data to be send to TTN as when my device is sending.
Is that possible?
please let me know.
Given that the minimum Rx1 time is 1 second and the default is 5 seconds on TTN, 2 seconds isn’t unreasonable.
No, because it is illegal (police/courts/fines/jail sort of issue) and totally in breach of the TTN Fair Use Policy. This is not a reasonable use case for LoRaWAN - the TTN FUP would allow 2 bytes every 133.4 seconds, you appear to be sending 2.5 bytes, so if we go to 3 bytes, you can send every 148.2 seconds, so you are about 300 times more than you should be sending.
Also the RN2483 runs its own LoRaWAN s/w stack - which will also throttle your messages to try and prevent the breach of duty cycle, this may lead you to assume prblems with the device if not aware of LoRaWAN fundamentals and not undertanding what is going on under the lid - helps avoid the handcuffs and court appearance but its down to you to be responsible as a TTN user and comply with the TTN FUP limits…simply put follow the guidance and rules just given and massively reduce your TX rate.
Iam using rn2483 connected to my private gateway. Iam able to only send the data to cloud but not able to receive back from the server. I have send the commands like “mac set ar on” to enable the automatic reply .
I am supposed to get the response of the device as “mac_rx_” but the response of the device is as “mac_tx_ok” which means there is only transmission but not the reception.
can you please guide me how to get the response back from the server
What do you mean by private gateway - what is it connected to?
That is to get the module to send a reply if it receives a confirmed downlink or the frame pending bit is set - it doesn’t make the gateway or server send a response.
So not a private gateway, just one you own - if it’s on TTN, then everything you do needs to be within the Fair Use Policy - have you stopped sending data every ½second?
By sending a downlink - it’s all in the documentation which is linked bottom right of the console.
I have already referred the document and i tried to send the bytes,I am supposed to receive the reply from the device as “mac_rx “”” but i am receiving just “mac_tx_ok”
what would be the reason for not receiving the data. i have looked in the community discussion. many have faced the problem but i have not seen any solution for it.
You send your uplink with mac_tx and if there is a downlink, you will get back a mac_rx with the port number and the data as hex. If there is no downlink, you’ll just get mac_tx_ok