| 65 | } // namespace |
| 66 | |
| 67 | void init() |
| 68 | { |
| 69 | Serial.begin(SERIAL_BAUD_RATE); |
| 70 | Serial.systemDebugOutput(true); // Allow debug print to serial |
| 71 | Serial.println(_F("Sming. Let's do smart things!")); |
| 72 | |
| 73 | // Set system ready callback method |
| 74 | System.onReady(ready); |
| 75 | |
| 76 | // Soft access point |
| 77 | WifiAccessPoint.enable(true); |
| 78 | WifiAccessPoint.config(_F("Sming InternetOfThings"), nullptr, AUTH_OPEN); |
| 79 | |
| 80 | // Station - WiFi client |
| 81 | WifiStation.enable(true); |
| 82 | WifiStation.config(_F(WIFI_SSID), _F(WIFI_PWD)); |
| 83 | |
| 84 | // Optional: Change IP addresses (and disable DHCP) |
| 85 | WifiAccessPoint.setIP(IpAddress(192, 168, 2, 1)); |
| 86 | WifiStation.setIP(IpAddress(192, 168, 1, 171)); |
| 87 | |
| 88 | // Optional: Print details of any incoming probe requests |
| 89 | WifiEvents.onAccessPointProbeReqRecved([](int rssi, MacAddress mac) { |
| 90 | Serial << _F("Probe request: RSSI = ") << rssi << _F(", mac = ") << mac << endl; |
| 91 | }); |
| 92 | |
| 93 | // Set callback that should be triggered when we have assigned IP |
| 94 | WifiEvents.onStationGotIP(connectOk); |
| 95 | |
| 96 | // Set callback that should be triggered if we are disconnected or connection attempt failed |
| 97 | WifiEvents.onStationDisconnect(connectFail); |
| 98 | } |
nothing calls this directly
no test coverage detected