コード例 #1
0
bool Adafruit_MQTT::ping(uint8_t times) {
  while (times) {
    // Construct and send ping packet.
    uint8_t len = pingPacket(buffer);
    if (!sendPacket(buffer, len))
      return false;

    // Process ping reply.
    len = readPacket(buffer, 2, PING_TIMEOUT_MS);
    if (buffer[0] == (MQTT_CTRL_PINGRESP << 4))
      return true;
  }
  return false;
}
コード例 #2
0
ファイル: Adafruit_MQTT.cpp プロジェクト: Bobbs/Basic
bool Adafruit_MQTT::ping(uint8_t num) {
  flushIncoming(100);

  while (num--) {
    // Construct and send ping packet.
    uint8_t len = pingPacket(buffer);
    if (!sendPacket(buffer, len))
      continue;
    
    // Process ping reply.
    len = readPacket(buffer, 2, PING_TIMEOUT_MS);
    if (buffer[0] == (MQTT_CTRL_PINGRESP << 4))
      return true;
  }
    
  return false;
}