73 bool ISNewText(
const char *dev,
const char *name,
char *texts[],
char *names[],
int n);
74 bool ISNewNumber(
const char *dev,
const char *name,
double values[],
char *names[],
int n);
80 bool login(
int portFD);
86 static void drain(
int portFD);
97 m_AllowOpenNetworks = allow;
105 bool sendCommand(
const char *
cmd,
char *res,
int len,
int timeout = 3,
bool secret =
false);
106 bool readHotspotStatus();
107 bool readHotspotCredentials();
109 bool readConnection();
112 static std::string formatScan(
const char *reply);
113 bool setHotspotCredentials(
const char *ssid,
const char *password);
114 bool connectToNetwork(
const char *ssid,
const char *password);
115 static bool validText(
const char *text,
size_t maxLength);
116 static void readConnectionLater(
void *context);
122 bool m_PasswordLoaded {
false};
123 bool m_Connected {
false};
124 bool m_AllowOpenNetworks {
false};
126 INDI::PropertySwitch HotspotSP {2};
127 INDI::PropertyText HotspotTP {2};
128 INDI::PropertyNumber ChannelNP {1};
129 INDI::PropertyText ConnectionTP {1};
130 INDI::PropertySwitch ScanSP {1};
131 INDI::PropertyText ScanTP {1};
132 INDI::PropertyText NetworkTP {2};
133 INDI::PropertySwitch ConnectSP {1};
134 INDI::PropertyText PasswordTP {1};
136 static constexpr int LEN {128};
137 static constexpr int SCAN_LEN {4096};
139 static constexpr int SCAN_TIMEOUT {16};
140 static constexpr int SCAN_RETRIES {4};
142 static constexpr int CONNECT_CHECK_MS {10000};
143 static constexpr useconds_t SCAN_RETRY_DELAY_US {3000000};
144 static constexpr const char *DEFAULT_PASSWORD {
"12345678"};
145 static constexpr const char *OPEN_NETWORK_PASSWORD {
"PASSWORD"};
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides generic container for INDI properties.
static constexpr int TCP_PORT
Port of the TCP command socket.
void updateConnection()
Read the current WiFi connection again, e.g. on every poll. Does nothing while not connected.
void saveConfigItems(FILE *fp)
Save the TCP password; the device stores its WiFi settings itself.
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
void ISGetProperties()
Define the TCP password and load it once from the configuration. Call from ISGetProperties.
std::function< void(INDI::Property &)> SaveConfig
void initProperties(const char *tab, LoadConfig loadConfig, SaveConfig saveConfig)
Create the properties: the WiFi settings on tab, the TCP password on the connection tab.
static void drain(int portFD)
Discard pending input. tcflush() only works on a serial port, so over TCP a line end left behind by a...
bool login(int portFD)
Log in on the TCP command socket with the hotspot password.
void updateProperties(bool connected, int portFD)
Define the WiFi properties and read the settings, or delete them on disconnect.
bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
std::function< void(const char *)> LoadConfig
WiFi(INDI::DefaultDevice *device)
void allowOpenNetworks(bool allow)
Allow joining an open network with an empty password. The device then gets the placeholder password "...
*brief user defined string literal for JSON values *sa std::size_t n
Namespace to encapsulate INDI client, drivers, and mediator classes.