Esempio n. 1
0
/*! \brief FlyPacket:setValue Converts a float into a byte array and inserts it into the packet.
 *  \param float (Data)
 */
void FlyPacket::setValue(float dataValue)
{
    if (sizeof(dataValue) <= MAX_PAYLOAD)
    {
        FlyByte localbyteArray[sizeof(dataValue)];
        floatToByteArray(localbyteArray,&dataValue);

        for (unsigned int i = 0; i < sizeof(dataValue); i++)
        {
            byteArray[i] = localbyteArray[i];
        }
    }
}
boolean testBlindsSetDataHandler(float value) {  
  debugPrint("VALUE: ", value);
  
  byte cmd_buffer[8] = { 0xFF, 0x00, 0xFA, 0x01, 0x00, 0x00, 0x00, 0x00};
  
  byte float_buffer[4];
  floatToByteArray(float_buffer, 0, value);

  // Append the value byte array to the response buffer
  for(int i=0,j=4;i<4;i++,j++) {
    cmd_buffer[j] = float_buffer[i];
  }
  
  const byte write_pipe[] = { "3Node" };
  setData(cmd_buffer, write_pipe);
  
  return true;
}