Sending a string in send() - not doing as I want it to do



  • Hi,
    I have this function in my sketch:

    void CheckRSSI()
    {
      char SendingRSSI[10];
      char ReceivingRSSI[10];
      char TxPowerLevel[10];
      char TxPowerPercent[10];
      String sendRSSI;
      itoa(RFM69_getSendingRSSI(), SendingRSSI,10);
      wait(200); 
      itoa(RFM69_getReceivingRSSI(), ReceivingRSSI,10);
      wait(200); 
      itoa(RFM69_getTxPowerLevel(), TxPowerLevel,10);
      wait(200); 
      itoa(RFM69_getTxPowerPercent(), TxPowerPercent,10);
      wait(200); 
      // Now, combine all values and send it in
      // Line should look like "T:-90 R:-81 PL:20 PP:100"
      sendRSSI = "T: ";
      sendRSSI.concat(SendingRSSI);
      sendRSSI.concat(" R:");
      sendRSSI.concat(ReceivingRSSI);
      sendRSSI.concat(" PL:");
      sendRSSI.concat(TxPowerLevel);
      sendRSSI.concat(" PP:");
      sendRSSI.concat(TxPowerPercent);
    #ifdef MY_DEBUG
      Serial.print(F("RSSI String: ")); 
      Serial.println(sendRSSI); 
    #endif
      send(msgRSSI.set(sendRSSI));
    }
    

    The output is:

    RSSI String: T: -59 R:-51 PL:-2 PP:0
    TSF:MSG:SEND,13-13-0-0,s=1,c=1,t=47,pt=0,l=23,sg=0,ft=0,st=1
    

    Why does send() only send 1 instead of the string?
    Using 2.2.0-rc.1


  • Mod

    How is msgRSSI created?



  • // Debug
    #define MY_DEBUG
    // Enable and select radio type attached
    #define   MY_RADIO_RFM69
    #define   MY_IS_RFM69HW
    #define   MY_RFM69_NEW_DRIVER
    #define   MY_RFM69_FREQUENCY RFM69_868MHZ
    // #define   MY_RFM69_ENABLE_ENCRYPTION
    
    #include <MySensors.h>
    
    #define SKETCH_NAME    "Test-text"
    #define SKETCH_VERSION "1.0"
    
    #define CHILD_ID_RSSI_INFO  1
    
    // Mysensors settings
    MyMessage msgRSSI(CHILD_ID_RSSI_INFO, V_TEXT);
    
    void before()
    {
    }
    
    void setup()
    {
      Serial.begin(115200); // for serial debugging.
      Serial.println(F("Start up sensor."));
    }
    
    void presentation()
    {
      present(CHILD_ID_RSSI_INFO, S_INFO, "RSSI Info");
    }
    
    void loop()
    {
    #ifdef MY_DEBUG
      Serial.println(F("Starting new measurements"));
    #endif
      CheckRSSI();
      // Sleep 
    #ifdef MY_DEBUG
      Serial.println(F("Waiting 1 minute"));
    #endif
      wait(60000);
    }
    
    
    

  • Mod

    @mickecarlsson sendSketchInfo is missing. Not sure if that affects anything.

    The presentation call is strange. I haven't seen it used with three paramters before.
    Edit: seems to be my inexperience, so presentation is probably ok.


  • Mod

    @mickecarlsson see if changing

      send(msgRSSI.set(sendRSSI));
    

    to

      send(msgRSSI.set(sendRSSI.c_str()));
    

    helps



  • THANKS!!
    That did it:

    RSSI String: T: 127 R:-49 PL:-2 PP:0
    TSF:MSG:SEND,13-13-0-0,s=1,c=1,t=47,pt=0,l=23,sg=0,ft=0,st=OK:T: 127 R:-49 PL:-2 PP:0
    

  • Mod


 

Suggested Topics

287
Online

7.6k
Users

8.5k
Topics

91.3k
Posts