Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Raw binary transmission

Raw binary transmission

Scheduled Pinned Locked Moved Development
5 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gizi
    wrote on last edited by
    #1

    Hi All

    Just getting to grips with MySensors.

    Is there a means to transmit raw binary data. In particular the handling of the transmission from the gateway to the controller - maybe as a hexadecimal encoded string of characters?

    I wish to send some bytes of bit flags to my custom controller (which publishes onto MQTT), this controller parses the serial port looking for carriage return ('\n') characters to split the received packets. This obviously presents a problem if the payload data actually contains the '\n' carriage return as a valid bit flag value, splitting the packet incorrectly. (Not to mention all the other control characters that may be received).

    Is such a feature already possibly, or do I need to investigate the gateway code and implement this myself?

    Cheers
    Gizi

    1 Reply Last reply
    0
    • hekH Online
      hekH Online
      hek
      Admin
      wrote on last edited by
      #2

      If you set payload using the following:

      https://github.com/mysensors/Arduino/blob/master/libraries/MySensors/MyMessage.cpp#L170

      The payload will be serialised into hex string when it reaches the gateway.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gizi
        wrote on last edited by
        #3

        Ok, so I am obviously missing something here, I saw you mention this solution in my searches, but I am unable to output a serialised hex string. My test code below appears to be setting the packetType correctly for the different types but for P_CUSTOM my results are an empty string...

        #include <MySensor.h>
        #include <SPI.h>
        
        #define CHILD_ID 3
        
        #define MS_CEPIN 8
        #define MS_CSPIN 7
        
        MySensor gw(MS_CEPIN, MS_CSPIN);
        
        unsigned int counter=0;
        unsigned int counter2=0;
        
        // Change to V_LIGHT if you use S_LIGHT in presentation below
        MyMessage msg(CHILD_ID,V_VAR1);
        
        void setup()
        {
        	gw.begin(NULL, 99);
        	gw.present(CHILD_ID, S_CUSTOM);
        }
        
        // some random buffer for testing
        char buffer[10] = {'H','e','l','l','o',' ','Y','o','u','\0'};
        
        void loop()
        {
        	//send something periodically
        	counter++;
        	if (counter == 0) {
        		counter2++;
        		gw.send(msg.set(buffer));	//pt=0 > P_STRING
        		gw.send(msg.set(counter2));	//pt=3 > P_UINT16
        		gw.send(msg.set(buffer,5)); //pt=6 > P_CUSTOM
        	}
        }
        
        

        My gateway returns the following when raw dumping the received serial data (this was the 61st send)...

        mysensorsmqtt: serial recv - 0;0;3;0;9;read: 99-99-0 s=3,c=1,t=24,pt=0,l=9:Hello You
        mysensorsmqtt: serial recv - 99;3;1;0;24;Hello You
        
        mysensorsmqtt: serial recv - 0;0;3;0;9;read: 99-99-0 s=3,c=1,t=24,pt=3,l=2:61
        mysensorsmqtt: serial recv - 99;3;1;0;24;61
        
        mysensorsmqtt: serial recv - 0;0;3;0;9;read: 99-99-0 s=3,c=1,t=24,pt=6,l=5:
        mysensorsmqtt: serial recv - 99;3;1;0;24;
        
        

        So the "pt=" seems to be set as expected, but no serialised hex. I must be missing something simple.

        1 Reply Last reply
        0
        • hekH Online
          hekH Online
          hek
          Admin
          wrote on last edited by hek
          #4

          I haven't fiddled with the MQTT gateway much. Do you see the same problem using the SerialGateway?

          getString must provide a buffer...

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gizi
            wrote on last edited by
            #5

            Sorry for the confusion, this is using the SerialGateway - I have my own code server side parsing the serial responses. Everything after the 'mysensorsmqtt: serial recv -' is just dumps of the serial string received.

            Ill dig a little deeper into the code and look at the MyGateway side of the code, everything seemed in order but I will do some debugging.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            12

            Online

            11.7k

            Users

            11.2k

            Topics

            113.0k

            Posts


            Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular