Exemple #1
0
    ByteStream AutoBalance_v2::buildCommand(NodeAddress nodeAddress, uint8 channelNumber, float targetPercent)
    {
        //build the command ByteStream
        ByteStream cmd;
        cmd.append_uint8(0xAA);                                               //Start of Packet
        cmd.append_uint8(0x05);                                               //Delivery Stop Flag
        cmd.append_uint8(0x00);                                               //App Data Type
        cmd.append_uint16(nodeAddress);                                       //Node address
        cmd.append_uint8(0x07);                                               //Payload Length
        cmd.append_uint16(WirelessProtocol::cmdId_autoBalance_v2);            //Command Id
        cmd.append_uint8(channelNumber);                                      //Channel Number
        cmd.append_float(targetPercent);                                      //Target Percentage Value

        //calculate the checksum of bytes 2-13
        uint16 checksum = cmd.calculateSimpleChecksum(1, 12);

        cmd.append_uint16(checksum);        //Checksum

        return cmd;
    }
    ByteStream BaseStation_RfSweepStart::buildCommand(uint32 min, uint32 max, uint32 interval, uint16 options)
    {
        //build the command ByteStream
        ByteStream cmd;

        cmd.append_uint8(0xAA);                                             //Start of packet
        cmd.append_uint8(0x0E);                                             //Delivery Stop Flag
        cmd.append_uint8(WirelessPacket::packetType_baseCommand);           //App Data Type
        cmd.append_uint16(WirelessProtocol::BASE_STATION_ADDRESS);          //Base Station Address
        cmd.append_uint8(0x10);                                             //Payload length
        cmd.append_uint16(WirelessProtocol::cmdId_base_rfScan);             //Command ID
        cmd.append_uint16(options);
        cmd.append_uint32(min);
        cmd.append_uint32(max);
        cmd.append_uint32(interval);
        cmd.append_uint16(cmd.calculateSimpleChecksum(1, 21));              //checksum

        //return the built command bytes
        return cmd;
    }