|
Instrument Neutral Distributed Interface INDI 2.2.5
|
The WiFi class handles the WiFi settings of Pegasus Astro devices that share the WiFi command set, so they can be set up without the Unity Platform: hotspot, hotspot channel, WiFi client and network scan. It also logs in on the TCP command socket, which accepts the same commands as USB after the hotspot password. More...
#include <pegasus_wifi.h>
Public Types | |
| using | LoadConfig = std::function<void(const char *)> |
| using | SaveConfig = std::function<void(INDI::Property &)> |
Public Member Functions | |
| WiFi (INDI::DefaultDevice *device) | |
| void | initProperties (const char *tab, LoadConfig loadConfig, SaveConfig saveConfig) |
| Create the properties: the WiFi settings on tab, the TCP password on the connection tab. | |
| void | ISGetProperties () |
| Define the TCP password and load it once from the configuration. Call from ISGetProperties. | |
| void | updateProperties (bool connected, int portFD) |
| Define the WiFi properties and read the settings, or delete them on disconnect. | |
| bool | ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) |
| bool | ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) |
| bool | ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) |
| void | saveConfigItems (FILE *fp) |
| Save the TCP password; the device stores its WiFi settings itself. | |
| bool | login (int portFD) |
| Log in on the TCP command socket with the hotspot password. | |
| void | updateConnection () |
| Read the current WiFi connection again, e.g. on every poll. Does nothing while not connected. | |
| void | allowOpenNetworks (bool allow) |
| Allow joining an open network with an empty password. The device then gets the placeholder password "PASSWORD", as Pegasus' software sends to the FlatMaster Neo. | |
Static Public Member Functions | |
| 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 previous reply would otherwise start the next one. | |
Static Public Attributes | |
| static constexpr int | TCP_PORT {9999} |
| Port of the TCP command socket. | |
The WiFi class handles the WiFi settings of Pegasus Astro devices that share the WiFi command set, so they can be set up without the Unity Platform: hotspot, hotspot channel, WiFi client and network scan. It also logs in on the TCP command socket, which accepts the same commands as USB after the hotspot password.
Replies seen on Falcon V2 firmware 1.8, FocusCube 3 firmware 2.0 and FlatMaster Neo firmware 1.4: A? -> 0|1, AE:x -> 1, AL -> ssid:password, AN:/AP: -> 1, AC -> n, AC:n -> n (Neo: 1), WA -> 0 while not connected, WS -> 0 when no network is found, WN: -> the command echoed, WN:/WP: -> 0 on error. The FlatMaster Neo also echoes WP:<password>. Since the replies differ, for AN:/AP:, WN:/WP:, AE:x and AC:n only 0 counts as a failure.
Definition at line 54 of file pegasus_wifi.h.
| using PegasusAstro::WiFi::LoadConfig = std::function<void(const char *)> |
Load (by property name) and save a property in the driver configuration; these are protected in DefaultDevice.
Definition at line 58 of file pegasus_wifi.h.
| using PegasusAstro::WiFi::SaveConfig = std::function<void(INDI::Property &)> |
Definition at line 59 of file pegasus_wifi.h.
|
explicit |
Definition at line 42 of file pegasus_wifi.cpp.
|
inline |
Allow joining an open network with an empty password. The device then gets the placeholder password "PASSWORD", as Pegasus' software sends to the FlatMaster Neo.
Definition at line 95 of file pegasus_wifi.h.
|
static |
Discard pending input. tcflush() only works on a serial port, so over TCP a line end left behind by a previous reply would otherwise start the next one.
Definition at line 324 of file pegasus_wifi.cpp.
| void PegasusAstro::WiFi::initProperties | ( | const char * | tab, |
| LoadConfig | loadConfig, | ||
| SaveConfig | saveConfig ) |
Create the properties: the WiFi settings on tab, the TCP password on the connection tab.
Definition at line 46 of file pegasus_wifi.cpp.
| void PegasusAstro::WiFi::ISGetProperties | ( | ) |
Define the TCP password and load it once from the configuration. Call from ISGetProperties.
Definition at line 88 of file pegasus_wifi.cpp.
| bool PegasusAstro::WiFi::ISNewNumber | ( | const char * | dev, |
| const char * | name, | ||
| double | values[], | ||
| char * | names[], | ||
| int | n ) |
Definition at line 232 of file pegasus_wifi.cpp.
| bool PegasusAstro::WiFi::ISNewSwitch | ( | const char * | dev, |
| const char * | name, | ||
| ISState * | states, | ||
| char * | names[], | ||
| int | n ) |
Definition at line 131 of file pegasus_wifi.cpp.
| bool PegasusAstro::WiFi::ISNewText | ( | const char * | dev, |
| const char * | name, | ||
| char * | texts[], | ||
| char * | names[], | ||
| int | n ) |
Definition at line 179 of file pegasus_wifi.cpp.
| bool PegasusAstro::WiFi::login | ( | int | portFD | ) |
Log in on the TCP command socket with the hotspot password.
Definition at line 264 of file pegasus_wifi.cpp.
| void PegasusAstro::WiFi::saveConfigItems | ( | FILE * | fp | ) |
Save the TCP password; the device stores its WiFi settings itself.
Definition at line 259 of file pegasus_wifi.cpp.
| void PegasusAstro::WiFi::updateConnection | ( | ) |
Read the current WiFi connection again, e.g. on every poll. Does nothing while not connected.
Definition at line 340 of file pegasus_wifi.cpp.
| void PegasusAstro::WiFi::updateProperties | ( | bool | connected, |
| int | portFD ) |
Define the WiFi properties and read the settings, or delete them on disconnect.
Definition at line 98 of file pegasus_wifi.cpp.
|
staticconstexpr |
Port of the TCP command socket.
Definition at line 101 of file pegasus_wifi.h.