title: arduino passing struct as argument to function
body: <p>I'm using an Arduino library for a radio. </p>
  
  <p><a href="https://www.cooking-hacks.com/documentation/tutorials/extreme-range-lora-sx1272-module-shield-arduino-raspberry-pi-intel-galileo#step3_2" rel="nofollow">Arduino radio</a></p>
  
  <p>If you do crtl+f and for "Transmission without ACK" you will see example code.</p>
  
  <p>There is a function called sendPacketTimeout(). This function takes a destination and payload packet of type char, for example like this.  </p>
  
  <pre><code>char message1 [] = "Hello";
  
  void setup()
  {
  
  }
  void loop(void)
  {
  e = sx1272.sendPacketTimeout(8, message1);
  }  
  </code></pre>
  
  <p>I've copied the sendPacketTimeout() function declaration from the header file below. </p>
  
  <p><strong>Questions</strong></p>
  
  <ol>
  <li>can you only pass a char to the function? </li>
  <li>Could I create a struct with information and pass that to the function for example like this.</li>
  </ol>
  
  <p>//</p>
  
  <pre><code>struct messagePacket {
  char boardID[3];       
  char temperature[3];
  char humidity[3];
  };
  
  struct messagePacket myPacket;
  
  void setup() {
  struct messagePacket myPacket;
  Serial.begin(9600);
  strcpy(myPacket.boardID, "01");
  strcpy(myPacket.temperature, "75");
  strcpy(myPacket.humidity, "90"); 
  e = sx1272.sendPacketTimeout(8, myPacket;
  </code></pre>
  
  <p>This the function declaration from the library</p>
  
  <pre><code>uint8_t sendPacketTimeout(uint8_t dest, char *payload);
  
  //! It sends the packet wich payload is a parameter before ending MAX_TIMEOUT.
  /*!
  \param uint8_t dest : packet destination.
  \param uint8_t *payload: packet payload.
  \param uint16_t length : payload buffer length.
  \return '0' on success, '1' otherwise
  */
  uint8_t sendPacketTimeout(uint8_t dest, uint8_t *payload, uint16_t length);
  
  //! It sends the packet wich payload is a parameter before ending 'wait' time.
  /*!
  \param uint8_t dest : packet destination.
  \param char *payload : packet payload.
  \param uint16_t wait : time to wait.
  \return '0' on success, '1' otherwise
  */
  </code></pre>