API Reference
The full C++ API on the global Pulsync instance.
Initialization
void setWiFi(const char *ssid, const char *password = nullptr);
void setServer(const char *server);
void setVersion(const char *version);
bool begin(const char *pairing_code = nullptr);
void loop(); Call setWiFi, setServer, and setVersion before begin(). begin() returns false if NVS is unavailable.
Scheduler
uint16_t setInterval(std::function<void()> cb, uint32_t interval_ms);
uint16_t setTimeout(std::function<void()> cb, uint32_t delay_ms);
bool clearInterval(uint16_t id);
bool clearTimeout(uint16_t id); Sending data
void send(const char *key, float value);
void send(const char *key, int value);
void send(const char *key, bool value);
void send(const char *key, const char *value);
// Grouped payload
void beginPayload();
void add(const char *key, float value); // also int / bool / const char*
void endPayload(); Receiving commands
Typed handlers unwrap {"command":"name","payload":{"value":X}}:
void onInt(const char *command, std::function<void(int)> handler);
void onFloat(const char *command, std::function<void(float)> handler);
void onBool(const char *command, std::function<void(bool)> handler);
void onString(const char *command, std::function<void(const char *)> handler);
void on(const char *command, std::function<void()> handler); // no value
void on(const char *command, std::function<void(Payload &)> handler); // full payload Remote config
void onConfig(const char *key, std::function<void(int)> cb, int default_val = 0);
// also float / bool / const char* overloads
int config(const char *key, int default_val);
float config(const char *key, float default_val);
bool config(const char *key, bool default_val); SoftAP (shared with the config portal)
One SoftAP. The config portal uses port 80. Your sketch may serve HTTP on another port on the same AP.
bool enableAP(const char *ssid, const char *password = nullptr);
void disableAP();
bool isAPEnabled();
const char *getAPIP(); // typically "192.168.4.1", or "" if AP is off - SoftAP is need-based: it stays up while the portal and/or your sketch needs it; otherwise the radio is STA-only.
- Portal priority: while the captive portal is open, it owns the SSID (
Pulsync-XXXX, open) and DNS.enableAPstill succeeds — it only registers your need. When the portal closes, your SSID/password are re-applied if you still hold the need. disableAPdrops SoftAP only if the portal is not open.- Empty/null password → open AP. Do not bind port 80 in the sketch (reserved for the portal).
Pulsync.enableAP("MyDevice", "secret");
WebServer server(8080); // not port 80
server.begin();
// phone joins MyDevice → http://192.168.4.1:8080 Configuration & status
void setHeartbeatInterval(uint32_t interval_ms); // min 30s
void setResetPin(int pin); // hold 3s to open the config portal
bool isConnected();
bool isWiFiConnected();
const char *getTransportName();
const char *getIP(); // STA IP
int queuedCount();
int queueCapacity(); Holding the reset pin for 3 seconds opens the config portal. It does not erase NVS. Factory reset is an action inside that portal.