Skip to content

MQTT::Client

blocking, non-threaded client API

詳細情報

メンバー

Client()

Client::Client(Network &network, unsigned int command_timeout_ms=30000)

引数

  • Network & network - pointer to an instance of the Network class - must be connected to the endpoint before calling connect
  • unsigned int command_timeout_ms

setDefaultMessageHandler()

void MQTT::Client< Network, Timer, MAX_MQTT_PACKET_SIZE, MAX_MESSAGE_HANDLERS >::setDefaultMessageHandler(messageHandler mh)

引数

  • messageHandler mh - pointer to the callback function

connect()

Connect - send an connect packet down the network and wait for a Connack The nework object must be connected to the network endpoint before calling this Default connect options are used

int Client::connect()

戻り値

int success code -

connect()

int Client::connect(MQTTPacket_connectData &options)

引数

  • MQTTPacket_connectData& options - connect options

戻り値

int success code -

publish()

int Client::publish(const char *topicName, Message &message)

引数

  • constchar * topicName
  • Message& message - the message to send

戻り値

int success code -

publish()

int Client::publish(const char *topicName, void *payload, size_t payloadlen, enum QoS qos=QOS0, bool retained=false)

引数

  • constchar * topicName
  • void * payload - the data to send
  • size_t payloadlen - the length of the data
  • QoSenum qos - the QoS to send the publish at
  • bool retained - whether the message should be retained

戻り値

int success code -

publish()

int Client::publish(const char *topicName, void *payload, size_t payloadlen, unsigned short &id, enum QoS qos=QOS1, bool retained=false)

引数

  • constchar * topicName
  • void * payload - the data to send
  • size_t payloadlen - the length of the data
  • unsigned short & id - the packet id used - returned
  • QoSenum qos - the QoS to send the publish at
  • bool retained - whether the message should be retained

戻り値

int success code -

subscribe()

int Client::subscribe(const char *topicFilter, enum QoS qos, messageHandler mh)

引数

  • constchar * topicFilter - a topic pattern which can include wildcards
  • QoSenum qos - the QoS to subscribe at
  • messageHandler mh - the callback function to be invoked when a message is received for this subscription

戻り値

int success code -

unsubscribe()

int Client::unsubscribe(const char *topicFilter)

引数

  • constchar * topicFilter - a topic pattern which can include wildcards

戻り値

int success code -

disconnect()

Disconnect - send an disconnect packet, and clean up any state

int Client::disconnect()

戻り値

int success code -

yield()

int Client::yield(unsigned long timeout_ms=1000L)

引数

  • unsigned long timeout_ms the time to wait, in milliseconds

戻り値

int success code - on failure, this means the client has disconnected

isConnected()

Is the client connected?

bool MQTT::Client< Network, Timer, MAX_MQTT_PACKET_SIZE, MAX_MESSAGE_HANDLERS >::isConnected()

戻り値

bool flag - is the client connected or not?