Skip to main content

pamoja_mqtt_client_publish_with

Function pamoja_mqtt_client_publish_with 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_mqtt_client_publish_with( client: *mut PamojaMqttClient, topic: *const c_char, payload: *const u8, payload_len: usize, qos: PamojaQos, retain: bool, confirmed: bool, ) -> PamojaStatus
Expand description

Publishes a payload to a topic with options of its own, optionally waiting for the broker to acknowledge it.

§Arguments

  • client - the client.
  • topic - the destination topic, with no wildcard.
  • payload - the message.
  • payload_len - how many bytes payload holds.
  • qos - the quality of service for this message.
  • retain - whether the broker keeps it for clients that subscribe later; an empty retained message clears the one the broker holds.
  • confirmed - whether to return only once the broker acknowledges the message: its PUBACK at QoS 1, its PUBCOMP at QoS 2, and once the connection has taken it at QoS 0, where MQTT acknowledges nothing.

§Returns

PamojaStatus::Ok once the message is queued, or acknowledged when confirmed is set, or an error status. A confirmed publish whose connection ends first fails with PamojaStatus::Transport, when the message may or may not have arrived.

§Safety

client must be a live handle from pamoja_mqtt_client_new; topic must be a valid null-terminated UTF-8 string; and payload must point to at least payload_len bytes, or be null when payload_len is 0.