TcpTransportFactory

class TcpTransportFactory(configureTls: TLSConfigBuilder.() -> Unit? = null) : MqttTransportFactory

MqttTransportFactory that builds a TcpTransport for MqttEndpoint.Tcp endpoints.

Add org.meshtastic:mqtt-client-transport-tcp and pass an instance to org.meshtastic.mqtt.MqttConfig.Builder.transportFactory.

To trust a broker whose certificate chain is not in the platform CA store — a private or self-signed CA — supply configureTls. The scope is this MQTT connection only, unlike Android's app-wide network_security_config.xml trust anchors:

transportFactory = TcpTransportFactory { trustManager = myTrustManager } +
WebSocketTransportFactory { trustManager = myTrustManager }

Parameters

configureTls

optional hook applied to ktor's TLSConfigBuilder for every transport this factory creates. It runs after the SNI server name is set and before platform trust is configured, so on Android a trust manager installed here is reached through the hostname-aware checkServerTrusted overload rather than bypassing it. Note that installing a trust manager replaces the platform's trust decision — network-security-config anchors, pinning, and Certificate Transparency policy then hold only insofar as that manager enforces them. The wrapping is Android-only and is not subject-name matching; see applyMqttTls for the full picture before relying on it.

Constructors

Link copied to clipboard
constructor(configureTls: TLSConfigBuilder.() -> Unit? = null)
constructor()

Functions

Link copied to clipboard
open override fun create(endpoint: MqttEndpoint): MqttTransport
Link copied to clipboard
open override fun supports(endpoint: MqttEndpoint): Boolean