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. Message Payload type

Message Payload type

Scheduled Pinned Locked Moved Development
7 Posts 3 Posters 648 Views 3 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.
  • R Offline
    R Offline
    r-nox
    wrote on last edited by r-nox
    #1

    I'm sending a message from node to node but when the message gets there it's the wrong type.
    I need to send as P_STRING but it's showing as P_INT16

    This is my send

    void sendToReceiver(boolean reed_tripped)
    {
     char percent;
     
     Serial.print(" Light Status ");
     Serial.println(reed_tripped);
    
    switch (reed_tripped) {
     
     case 0:
     percent = "0";
    
     send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent).setType(V_PERCENTAGE));
     //send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent));
     //send(msgDimmer_to_5.set(percent, 0));
     
     break;
     
     case 1:
     percent = "30";
    
     send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent).setType(V_PERCENTAGE));
     //send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent));
     //send(msgDimmer_to_5.set(percent, 0));
     break;
    
    }
     
    
    }
    

    and the message

    2836 !TSF:MSG:SEND,8-8-5-5,s=0,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=NACK:4
    2842 !TSF:RTE:N2N FAIL
    2846 TSF:MSG:SEND,8-8-0-5,s=0,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:4
    2854 MCO:SLP:MS=360000,SMS=0,I1=0,M1=1,I2=255,M2=255
    2861 TSF:TDI:TSL
    

    What the heck am I doing wrong?

    mfalkviddM 1 Reply Last reply
    0
    • R r-nox

      I'm sending a message from node to node but when the message gets there it's the wrong type.
      I need to send as P_STRING but it's showing as P_INT16

      This is my send

      void sendToReceiver(boolean reed_tripped)
      {
       char percent;
       
       Serial.print(" Light Status ");
       Serial.println(reed_tripped);
      
      switch (reed_tripped) {
       
       case 0:
       percent = "0";
      
       send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent).setType(V_PERCENTAGE));
       //send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent));
       //send(msgDimmer_to_5.set(percent, 0));
       
       break;
       
       case 1:
       percent = "30";
      
       send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent).setType(V_PERCENTAGE));
       //send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent));
       //send(msgDimmer_to_5.set(percent, 0));
       break;
      
      }
       
      
      }
      

      and the message

      2836 !TSF:MSG:SEND,8-8-5-5,s=0,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=NACK:4
      2842 !TSF:RTE:N2N FAIL
      2846 TSF:MSG:SEND,8-8-0-5,s=0,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:4
      2854 MCO:SLP:MS=360000,SMS=0,I1=0,M1=1,I2=255,M2=255
      2861 TSF:TDI:TSL
      

      What the heck am I doing wrong?

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @r-nox you are setting the message type to V_PERCENTAGE. You probably want to use V_TEXT.

      R 1 Reply Last reply
      0
      • fritsF Offline
        fritsF Offline
        frits
        wrote on last edited by
        #3

        @r-nox said in Message Payload type:

        char percent;

        Your data is of type char. Make it char *. Something like

        char buf[MAX_PAYLOAD_SIZE+1];
        strcpy ( buf, "30" );
        send(msgDimmer_to_5.setDestination(5).setSensor(0).set(buf).setType(V_TEXT));
        
        R 1 Reply Last reply
        1
        • fritsF frits

          @r-nox said in Message Payload type:

          char percent;

          Your data is of type char. Make it char *. Something like

          char buf[MAX_PAYLOAD_SIZE+1];
          strcpy ( buf, "30" );
          send(msgDimmer_to_5.setDestination(5).setSensor(0).set(buf).setType(V_TEXT));
          
          R Offline
          R Offline
          r-nox
          wrote on last edited by
          #4

          @frits

          I tried this. Here's the results. They are close but payload looks corrupted.

          char buf[MAX_PAYLOAD_SIZE+1];
          strcpy ( buf, percent );
          
          void sendToReceiver(boolean reed_tripped)
          {
            char percent;
            
            Serial.print(" Light Status ");
            Serial.println(reed_tripped);
           
           switch (reed_tripped) {
            
            case 0:
            percent = "0";
            Serial.print(" Select case is ");
            Serial.println("0");
            
          char buf[MAX_PAYLOAD_SIZE+1];
          strcpy ( buf, percent );
          
          send(msgDimmer_to_5.setDestination(5).setSensor(0).set(buf).setType(V_TEXT));
            
            break;
            
            case 1:
            percent = "30";
            Serial.print(" Select case is ");
            Serial.println("30");
            
          char buf2[MAX_PAYLOAD_SIZE+1];
          strcpy ( buf, percent );
          send(msgDimmer_to_5.setDestination(5).setSensor(0).set(buf2).setType(V_TEXT));
            
           
            break;
          
           
          }
          

          My results have had their molecules mixed during transport. I expected "30" but received :⸮

          4870 TSF:MSG:SEND,8-8-0-5,s=0,c=1,t=47,pt=0,l=3,sg=0,ft=0,st=OK:⸮
          
          

          Any further advice?

          1 Reply Last reply
          0
          • mfalkviddM mfalkvidd

            @r-nox you are setting the message type to V_PERCENTAGE. You probably want to use V_TEXT.

            R Offline
            R Offline
            r-nox
            wrote on last edited by
            #5

            @mfalkvidd

            Sending as V_TEXT did not have the effect needed.

            void sendToReceiver(boolean reed_tripped)
            {
              char percent;
              
              Serial.print(" Light Status ");
              Serial.println(reed_tripped);
             
             switch (reed_tripped) {
              
              case 0:
              percent = "0";
              Serial.print(" Select case is ");
              Serial.println("0");
            
              send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent).setType(V_TEXT));
              //send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent));
              //send(msgDimmer_to_5.set(percent, 0));
              
              break;
              
              case 1:
              percent = "30";
              Serial.print(" Select case is ");
              Serial.println("30");
                
              send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent).setType(V_TEXT));
              //send(msgDimmer_to_5.setDestination(5).setSensor(0).set(percent));
              //send(msgDimmer_to_5.set(percent, 0));
              break;
              
             
            }
              
             
            }
            

            and the results

            3201 TSF:MSG:SEND,8-8-0-5,s=0,c=1,t=47,pt=2,l=2,sg=0,ft=0,st=OK:4
            

            Payload still shows as P_INT16 and payload is 4 but in fact should be 30

            This should be simple. I don't understand what's going wrong.

            1 Reply Last reply
            0
            • fritsF Offline
              fritsF Offline
              frits
              wrote on last edited by
              #6

              @r-nox said in Message Payload type:

              char buf2[MAX_PAYLOAD_SIZE+1];
              strcpy ( buf, percent );
              send(msgDimmer_to_5.setDestination(5).setSensor(0).set(buf2).setType(V_TEXT));

              You copied to buf, but sent buf2 ;-)

              R 1 Reply Last reply
              1
              • fritsF frits

                @r-nox said in Message Payload type:

                char buf2[MAX_PAYLOAD_SIZE+1];
                strcpy ( buf, percent );
                send(msgDimmer_to_5.setDestination(5).setSensor(0).set(buf2).setType(V_TEXT));

                You copied to buf, but sent buf2 ;-)

                R Offline
                R Offline
                r-nox
                wrote on last edited by
                #7

                @frits Thank you for catching that. I was just reworking and now it's sending proper values. :)

                1 Reply Last reply
                0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                19

                Online

                12.0k

                Users

                11.2k

                Topics

                113.4k

                Posts


                Copyright 2025 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