MCPcopy Create free account
hub / github.com/SmingHub/Sming / init

Function init

samples/Basic_WiFi/app/application.cpp:67–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65} // namespace
66
67void 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}

Callers

nothing calls this directly

Calls 11

systemDebugOutputMethod · 0.80
printlnMethod · 0.80
onReadyMethod · 0.80
onStationGotIPMethod · 0.80
onStationDisconnectMethod · 0.80
IpAddressClass · 0.50
beginMethod · 0.45
enableMethod · 0.45
configMethod · 0.45
setIPMethod · 0.45

Tested by

no test coverage detected