You are here: Forum Home → ANT Developers Forums → ANT General Questions → Thread
// antID: ANT+ ID to emulate (1-65532)
// power: current power to send
// A Power-Only message example: 0 -  10 -  17 -  ff -  5a -  6d -  19 -  1b -  1 -  80 -  65 -  0 -  b -  5 -  0 -  0 -  0
void Hub::sendPowerOnlyMessage(int antID, int power) {
    configureSendChannelBroadcastPM();
    powerEventCount++;
    accumulatedPower += power;
    if (powerEventCount > 255) {
        powerEventCount = 0;
    }
    if (accumulatedPower > 65535) {
        accumulatedPower = accumulatedPower - 65535;
    }
    uint8_t aucTxBuf[ANT_STANDARD_DATA_PAYLOAD_SIZE];  //8
    aucTxBuf[0] =  0x10;
    aucTxBuf[1] =  powerEventCount; //event count
    aucTxBuf[2] =  0xFF; //pedal power, not used
    aucTxBuf[3] =  0xFF; //instant cadence, not used
    aucTxBuf[4] =  (uint8_t)accumulatedPower;
    aucTxBuf[5] =  (uint8_t)(accumulatedPower >> 8);
    aucTxBuf[6] =  (uint8_t)power;
    aucTxBuf[7] =  (uint8_t)(power >> 8);
    pclMessageObject->SendBroadcastData(constants::pmChannelNumber, aucTxBuf);
}
void Hub::configureSendChannelBroadcastPM() {
    qDebug() << "configureSendChannelBroadcastPM Now";
    if (currentSendingChannel != constants::pmChannelNumber) {
        pclMessageObject->AssignChannel(constants::pmChannelNumber, 0, USER_NETWORK_NUM);
        currentSendingChannel = constants::pmChannelNumber;
    }
    pclMessageObject->SetChannelID(constants::pmChannelNumber, 0, constants::powerDeviceType, constants::transTypePower); //id=0 --> (wildcard so that any device accept the message)
} 
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com