Skiply Smilio Payload decoder

Hi all,
i try to code a payload decoder for a “Skiply Smilio”. its user_manual cofusing me a little bit about how to detect its datatype, when output look totaly different then the stuff you can find in its manual.

the mqtt output looks like this:

  "txInfo" : {
    "frequency" : 868100000,
    "dr" : 0
  },
  "adr" : false,
  "fCnt" : 150,
  "fPort" : 2,
  "data" : "EQAAOwAAAgAAAg==",
  "object" : {
    "greenCount" : 2,
    "orangeCount" : 944,
    "payloadType" : 17,
    "redCount" : 0
  }
}

and EQAAOwAAAgAAAg== decoded to hex = 1100003b000002000002

My solution for this task is the following:

function Decode(fPort, bytes) {
  var result = {};
  result.payloadType = bytes[0];
  result.redCount = (bytes[1] << 4) + bytes[2];
  result.orangeCount = (bytes[3] << 4) + bytes[4];
  result.greenCount = (bytes[5] << 4) + bytes[6];
  result.battery = (bytes[0] & 0x01);

  return result;
}  

In the manual they wrote about 02 or 03 as 1st byte in the datatype section.
01 should be a keep-alive message with batterystatus, but as you can see in the my hexstring everytime it starts with 11 as 1st byte.

Description taken from its manual:

  • 0x00
    Frame (02) is sent out at each end of period whatever the counter values.
  • 0x10
    Frame (02) is sent out at each end of period, only if counter values have changed since the last sent frame.
  • 0x01
    Frame (02) is sent out at each push with a delay of ‘tpb” between two pushes.

Maybe you have some ideas, how the decoder could look like to solve my problem.
thanks

Regards
Michael

NU_0011_SmilioAction_USER MANUAL_Book_FW_2_0_1_4.pdf (942.6 KB)

I’ve formatted your post; please see How do I format my forum post? [HowTo]

Is this even related to The Things Network?

Also, it’s not clear to me what you’re asking. If indeed each uplink starts with 11 then that’s not something you can fix in the decoder, but needs fixing in the device. That is: if you’re sure that 11 is not expected. Maybe you just have the wrong documentation.

Shifting only 4 bytes doesn’t look right. See Working with Bytes.

The above doesn’t look right either.

Hi Michael,
I’m Jerome from Skiply. I will try to help you to make the suitable decoder.
The first byte gives you the type of payload:
0x01 = heart bit with battery level
0x02 = normal mode
0x03 = normal mode with badge
0x10 or 0x11 or 0x31 or 0x13 or 0x33 = code mode
0x04 is the configuration frame sent by the device at each startup.
So, first you need to know the mode and the frame type to know what the other bytes mean.

When we integrate with TTN, we use this function:

function Decoder(bytes, port) {
  var hexPayload = "";
  bytes.forEach(function(byte) {
    hexPayload += ('0' + (byte & 0xFF).toString(16)).slice(-2);
  });
  var decoded = {hex_payload:hexPayload};
  return decoded;
}

To convert the payload into an hex payload.

Then you can test the frame type with substring.

Does it help ?

Do not hesitate to ask.

Additionnal info: https://skiplyfrance.github.io/simulator.html (to understand the difference between the normal, pulse and code mode)

Yes, of course. But where to find the details? Displaying the binary payload in a human-readable hexadecimal representation is not going to help Michael (or better yet: future readers) at all, I’d say? There must be some documentation that explains more than the one that was posted above?

All the details are in the user manual that is attached. As I said, first you should setup the mode you need, then, you have to adapt the decoder according to that. If you need a “generic decoder”, you should test the frame type, and make the requested conditions.

normal-mode

code

It’s not like I care, as I don’t own the device. But Michael is also saying that 0x11 is not documented. Skimming the documentation I cannot find at least a few of the above either.

Thank you guys for your reply.
i tried the code jerome provide and got the following result when i press the green button twice:

},
“adr” : false,
“fCnt” : 180,
“fPort” : 2,
“data” : “EQAAAQAAAgAAAg==”,
“object” : {
“hex_payload” : “11000001000002000002”
}
}

— and here the 2nd time it got pressed:
},
“adr” : false,
“fCnt” : 181,
“fPort” : 2,
“data” : “EQAAAgAAAgAAAg==”,
“object” : {
“hex_payload” : “11000002000002000002”
}
}

— one time yellow button got pressed:
},
“adr” : false,
“fCnt” : 182,
“fPort” : 2,
“data” : “EQAACwAAAgAAAw==”,
“object” : {
“hex_payload” : “1100000b000002000003”
}

you can see a change in the hex_payload, but i am still confused about 0x11 as 1st byte instead of 0x03 for example.

The 2nd thing not mentioned before, but found on your faq-page is this entry " Why are you sending states of counters instead of number of buttons pressed ?" I understand that its a saver method not to loose any packages, but it confuse me a little bit when the bytes change and not only its counter.

it could be possible that i misunderstand it and its easier than i thought it was.

if you agree let us go through every byte in the hex_payload string.
When i go through the documentation i understand it like this:

example here yellow button got pressed more times  "hex_payload" : "1100000b000002000003" and here a 2nd time "hex_payload" : "1100000c000003000003"

The string consists of 10bytes:
11 = byte[0] will be the payloadtype
0000 = byte[1] + byte[2] should be button1 (green in my example)
0b00 = byte[3] + byte[4] should be button2 (yellow in my example)
0002 = byte[5] + byte[6] should be button3 (red in my example)
0000 = byte[7] + byte[8] should be button4 (a not used one,because with have only 3)
03 = byte[9] what about this byte?

where can i find the batterystatus is this included in byte[9] ?

Would be fine we could could get together to a solution.
thanks

Sorry I missed your message. 11 means you are in code mode (p. 28 of the manual). In this mode, you have the last sequence pressed, and the previous one, + the time in minutes between the 2.
So if you press button 1 and button 3, you should receive something like: 1X XX XXXXXX 000013 (I do it from memory).
If you want to use the normal mode (start with 02 or 03), you should send the corresponding downlink. See: https://skiplyfrance.github.io/configurator.html

Hi, the page 28 describes the code mode.

I did a demo during the virtual TTN conference (I switched from one mode to an other). I don’t know how to find it, it was during the workshops.