Without seeing your code, my guess would be that you’re still sending text, as a null-terminated string. The maximum length of such string is always 1 less than its total length, as it always needs a place to store the 0x00 character.
If you look at the manual for slice, you’ll see it needs a start index and an end index. In the examples x is the start index. In my example:
var i = uint16(bytes.slice(0, 2)); // use bytes 0 and 1
var c = latLng(bytes.slice(2, 10)); // use bytes 2 thru 9
You could rewrite that to:
var x = 0;
var i = uint16(bytes.slice(x, x + 2));
x = x + 2;
var c = latLng(bytes.slice(x, x + 8));
x = x + 8;
Here is the Arduino code:
// Prepare upstream data transmission at the next possible time.
Serial.print("\nReady to send string mydata “);
Serial.println(” in DEC is: ");
LMIC_setTxData2(1, mydata, sizeof(mydata) - 1, 0);
to code use code for Arduino and if you use “Convenience class LoraMessage” do not forget “LoraMessage message” at the beggining of the loop, otherwise your payload will grow every time as it will pass the loop ;-);
to decode message on TTN go to console/payload functions and in window of decoder copy src/decoder.js and at the end add for example “return decode(bytes, [uint16, temperature, humidity, uint16], [‘voltage’, ‘temperature’, ‘humidity’, ‘pressure’]);”
You might be able to determine the difference by the size of what is received.
Alternatively what we did once when we had all kinds of different nodes, we added a leading byte describing what data was following. I.e. 0x00 for temp 2 bytes (total of 3 bytes), 0x01 for temp 2 bytes plus voltage 1 byte. Etc.
hello, have you any example please of converting a text in bytes. I’m trying to do so with c++ on raspberry but fail!
The purpose is to send some informations of macaddress of conneted devices.
My string looks like: “54:65:00:AF:99 \n 78:87:09:AR:90 …” i get it in std::string format and i want to split it into bytes. thanks!