Server connection vs device connection

Connecting to a device covers connectDevice() — one specific device. This page is one level up: connecting to the INDI server itself, and to every device at once.

connectIndi(): connect to the server, used everywhere a module can (re)connect manually

Called from a module’s own constructor (when it wants to connect eagerly, independent of the startup.indiatstart flag covered below) and from action handlers wiring a manual reconnect button — Guider does both, right at the top of its own init routine:

// src/modules/guider/guider.cpp
setStateEvent(OST::Busy, "init", "intialisation", "Guider initialize");
if (connectDevice(getString("devices", "camera")))
{
    connectIndi();
    connectDevice(getString("devices", "camera"));
    connectDevice(getString("devices", "guider"));
    ...

Navigator, Allsky, Meteo, Parkmanager and Inspector all call it the same way, each right before the device-level connectDevice() calls that actually need a live server connection first.

connectAllDevices(): every registered device at once, used standalone by Meteo

// src/modules/meteo/meteo.cpp
giveMeAParms();
giveMeAnActions();
connectIndi();
connectAllDevices();

Meteo calls both directly in its constructor — no startup flag involved, it simply always wants every device connected as soon as it’s instantiated.

The fully automatic path: onAfterInit()’s own startup chain

Identity, startup and disk space already covers onAfterInit() as an override point. Its default IndiModule implementation is what actually implements indiatstart/devatstart/confsatstart (Connecting to a device) — nothing here needs to be called by a module, it already runs once for every module right after construction:

// libs/indimodule.cpp
void IndiModule::onAfterInit()
{
    if (!getBool("startup", "indiatstart")) return;
    connectIndi();
    // connectIndi() itself already schedules OnAfterIndiConnectIndiTimer()
    // 500ms out (device enumeration isn't complete the instant
    // connectServer() returns - INDI streams defDevice/defProperty
    // progressively) - OnStartupConnectDevices() rides the same delay
    // rather than acting on a still-empty device list, but is its own
    // separate one-shot...
    if (getBool("startup", "devatstart") || getBool("startup", "confsatstart"))
        QTimer::singleShot(500, this, &IndiModule::OnStartupConnectDevices);
}

void IndiModule::OnStartupConnectDevices()
{
    if (!getBool("startup", "devatstart")) return;
    connectAllDevices();
    if (getBool("startup", "confsatstart")) loadDevicesConfs();
}

connectIndiTimer(), OnAfterIndiConnectIndiTimer() and OnStartupConnectDevices() are declared as public slots only because Qt’s timer/signal machinery requires that — no core module calls any of the three directly, they exist purely as the automatic retry/startup machinery wired internally by IndiModule itself.

disconnectIndi(), disconnectAllDevices(), loadDevicesConfs() follow the server/device action pair

These three (and connectAllDevices()’s own generic dispatch) are also what IndiModule calls internally in response to the standard serveractions/devicesactions buttons (connect/disconnect server, connect/disconnect/reload-config all devices) — the protocol-level actions themselves, not something a module’s own code calls on itself. Meteo’s direct connectAllDevices() call above is the one exception: a module choosing to run the same logic unconditionally at construction time, outside that button-driven path entirely.