Library reference
Every call in the MaxwellTrack library, grouped by what it does.
Start
begin(deviceId, authToken, ssid, pass)voidStart. With a network name the library keeps WiFi connected; with
ssidandpassleft out, your sketch manages the network.MaxwellTrackClass MaxwellTrack(client);declarationAny other network: declare your own instance with a connected secure
Client, such asTinyGsmClientSecure. Replaces the built-in WiFi instance.run()voidCall on every pass of
loop(). Keeps the connection up, delivers commands and updates, sends heartbeats and buffered readings.
Send
write(key, value)boolSend one value to a datastream's key.
valuemay be any integer type,float,double,const char*orString.falseonly when the message is refused (too large, or out of memory).virtualWrite(key, value)boolThe same as
write().sendBatch(json)boolSeveral values in one message with one timestamp, such as
{"temperature":25.1,"humidity":60}.
Receive
onWrite(handler)voidvoid handler(String key, String value), called for every command to a key without its own handler.onWrite(key, handler)voidA handler for one key. Takes priority over the general handler.
onConnectionChange(handler)voidvoid handler(bool online), called when the cloud connection goes up or down.
Equipment and cameras
useModbus(port, dePin)voidModbus equipment on an RS-485 port. Open
portat the equipment's speed first;dePindrives the transceiver's DE/RE pins,-1for an adapter that switches by itself. The equipment and local rules are set up in the console. See Local rules and equipment.sendImage(jpeg, len)boolSend one JPEG picture, up to 200 KB, to the device's camera widgets.
falsewhile offline. See Cameras.onCameraRequest(handler)voidvoid handler(bool live, unsigned int seconds), called when someone opens live view (live = true, forseconds) or presses Take picture (live = false).
Status
connected()booltruewhile connected to the cloud.connectionState()intThe connection state as a number. See Connection status.
queuedMessages()size_tMessages waiting in the offline buffer.
droppedMessages()unsigned longMessages dropped because the buffer was full.
Configure
Call these before begin() unless noted.
setQueueSize(bytes)voidOffline buffer size. Defaults per board in Supported boards.
setMaxPayload(bytes)voidLargest single message, 64 to 65535 bytes.
setHeartbeatInterval(ms)voidDefault
10000. Keep it well under 30 seconds.setSignal(rssi)voidCellular signal strength to report with heartbeats. Call any time.
setRootCA(pem)voidPrivate deployments only: replace the built-in root certificates with your own (PEM). ESP32, ESP8266, UNO R4 WiFi and Pico W.
useTransport(client)voidSwitch an existing instance to another network
Client.
Version
MAXWELLTRACK_FW_VERSION#defineYour code's version, shown in the console. Define it before
#include <maxwelltrack.h>. Set for you by the MCode IDE.MAXWELLTRACK_NO_WIFI#defineUNO R4 WiFi, Pico W, MKR WiFi 1010 and Nano 33 IoT connecting through a modem: define it before
#include <maxwelltrack.h>so the library leaves WiFi alone.
Something unclear or out of date on this page? Tell support.
