-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #611 from avr39-ripe/feature/wifi_events
Add WifiEvents, add Basic_WebSkeletonApp, add "save" argument to Wifi*.enable() method
- Loading branch information
Showing
24 changed files
with
901 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* WifiEvents.cpp | ||
* | ||
* Created on: 19 февр. 2016 г. | ||
* Author: shurik | ||
*/ | ||
|
||
#include <WifiEvents.h> | ||
|
||
WifiEventsClass WifiEvents; | ||
|
||
WifiEventsClass::WifiEventsClass() | ||
{ | ||
wifi_set_event_handler_cb(staticWifiEventHandler); | ||
} | ||
|
||
void WifiEventsClass::onStationConnect(onStationConnectDelegate delegateFunction) | ||
{ | ||
onSTAConnect = delegateFunction; | ||
} | ||
|
||
void WifiEventsClass::onStationDisconnect(onStationDisconnectDelegate delegateFunction) | ||
{ | ||
onSTADisconnect = delegateFunction; | ||
} | ||
|
||
void WifiEventsClass::onStationAuthModeChange(onStationAuthModeChangeDelegate delegateFunction) | ||
{ | ||
onSTAAuthModeChange = delegateFunction; | ||
} | ||
|
||
void WifiEventsClass::onStationGotIP(onStationGotIPDelegate delegateFunction) | ||
{ | ||
onSTAGotIP = delegateFunction; | ||
} | ||
|
||
void WifiEventsClass::onAccessPointConnect(onAccessPointConnectDelegate delegateFunction) | ||
{ | ||
onSOFTAPConnect = delegateFunction; | ||
} | ||
|
||
void WifiEventsClass::onAccessPointDisconnect(onAccessPointDisconnectDelegate delegateFunction) | ||
{ | ||
onSOFTAPDisconnect = delegateFunction; | ||
} | ||
|
||
void WifiEventsClass::onAccessPointProbeReqRecved(onAccessPointProbeReqRecvedDelegate delegateFunction) | ||
{ | ||
onSOFTAPProbeReqRecved = delegateFunction; | ||
} | ||
|
||
void WifiEventsClass::staticWifiEventHandler(System_Event_t *evt) | ||
{ | ||
WifiEvents.WifiEventHandler(evt); | ||
} | ||
|
||
void WifiEventsClass::WifiEventHandler(System_Event_t *evt) | ||
{ | ||
debugf("event %x\n", evt->event); | ||
|
||
switch (evt->event) | ||
{ | ||
case EVENT_STAMODE_CONNECTED: | ||
debugf("connect to ssid %s, channel %d\n", | ||
evt->event_info.connected.ssid, | ||
evt->event_info.connected.channel); | ||
if (onSTAConnect) | ||
{ | ||
onSTAConnect((const char *)evt->event_info.connected.ssid, | ||
evt->event_info.connected.ssid_len, | ||
evt->event_info.connected.bssid, | ||
evt->event_info.connected.channel); | ||
} | ||
break; | ||
case EVENT_STAMODE_DISCONNECTED: | ||
debugf("disconnect from ssid %s, reason %d\n", | ||
evt->event_info.disconnected.ssid, | ||
evt->event_info.disconnected.reason); | ||
if (onSTADisconnect) | ||
{ | ||
onSTADisconnect((const char *)evt->event_info.disconnected.ssid, | ||
evt->event_info.disconnected.ssid_len, | ||
evt->event_info.disconnected.bssid, | ||
evt->event_info.disconnected.reason); | ||
} | ||
break; | ||
case EVENT_STAMODE_AUTHMODE_CHANGE: | ||
debugf("mode: %d -> %d\n", | ||
evt->event_info.auth_change.old_mode, | ||
evt->event_info.auth_change.new_mode); | ||
if (onSTAAuthModeChange) | ||
{ | ||
onSTAAuthModeChange(evt->event_info.auth_change.old_mode, | ||
evt->event_info.auth_change.new_mode); | ||
} | ||
break; | ||
case EVENT_STAMODE_GOT_IP: | ||
debugf("ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR, | ||
IP2STR(&evt->event_info.got_ip.ip), | ||
IP2STR(&evt->event_info.got_ip.mask), | ||
IP2STR(&evt->event_info.got_ip.gw)); | ||
debugf("\n"); | ||
if (onSTAGotIP) | ||
{ | ||
onSTAGotIP(evt->event_info.got_ip.ip, | ||
evt->event_info.got_ip.mask, | ||
evt->event_info.got_ip.gw); | ||
} | ||
break; | ||
case EVENT_SOFTAPMODE_STACONNECTED: | ||
debugf("station: " MACSTR "join, AID = %d\n", | ||
MAC2STR(evt->event_info.sta_connected.mac), | ||
evt->event_info.sta_connected.aid); | ||
if (onSOFTAPConnect) | ||
{ | ||
onSOFTAPConnect(evt->event_info.sta_connected.mac, evt->event_info.sta_connected.aid); | ||
} | ||
break; | ||
case EVENT_SOFTAPMODE_STADISCONNECTED: | ||
debugf("station: " MACSTR "leave, AID = %d\n", | ||
MAC2STR(evt->event_info.sta_disconnected.mac), | ||
evt->event_info.sta_disconnected.aid); | ||
if (onSOFTAPDisconnect) | ||
{ | ||
onSOFTAPDisconnect(evt->event_info.sta_disconnected.mac, evt->event_info.sta_disconnected.aid); | ||
} | ||
break; | ||
case EVENT_SOFTAPMODE_PROBEREQRECVED: | ||
if (onSOFTAPDisconnect) | ||
{ | ||
onSOFTAPProbeReqRecved(evt->event_info.ap_probereqrecved.rssi, evt->event_info.ap_probereqrecved.mac); | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* WifiEvents.h | ||
* | ||
* Created on: 19 февр. 2016 г. | ||
* Author: shurik | ||
*/ | ||
|
||
#ifndef SMINGCORE_PLATFORM_WIFIEVENTS_H_ | ||
#define SMINGCORE_PLATFORM_WIFIEVENTS_H_ | ||
|
||
#include "../SmingCore/Delegate.h" | ||
#include "../../Wiring/WString.h" | ||
#include "../../Wiring/IPAddress.h" | ||
|
||
//Define WifiEvents Delegates types | ||
typedef Delegate<void(String, uint8_t, uint8_t[6], uint8_t)> onStationConnectDelegate; | ||
typedef Delegate<void(String, uint8_t, uint8_t[6], uint8_t)> onStationDisconnectDelegate; | ||
typedef Delegate<void(uint8_t, uint8_t)> onStationAuthModeChangeDelegate; | ||
typedef Delegate<void(IPAddress, IPAddress, IPAddress)> onStationGotIPDelegate; | ||
typedef Delegate<void(uint8_t[6], uint8_t)> onAccessPointConnectDelegate; | ||
typedef Delegate<void(uint8_t[6], uint8_t)> onAccessPointDisconnectDelegate; | ||
typedef Delegate<void(int16_t, uint8_t[6])> onAccessPointProbeReqRecvedDelegate; | ||
|
||
class WifiEventsClass | ||
{ | ||
public: | ||
WifiEventsClass(); | ||
|
||
void onStationConnect(onStationConnectDelegate delegateFunction); | ||
void onStationDisconnect(onStationDisconnectDelegate delegateFunction); | ||
void onStationAuthModeChange(onStationAuthModeChangeDelegate delegateFunction); | ||
void onStationGotIP(onStationGotIPDelegate delegateFunction); | ||
void onAccessPointConnect(onAccessPointConnectDelegate delegateFunction); | ||
void onAccessPointDisconnect(onAccessPointDisconnectDelegate delegateFunction); | ||
void onAccessPointProbeReqRecved(onAccessPointProbeReqRecvedDelegate delegateFunction); | ||
|
||
private: | ||
static void staticWifiEventHandler(System_Event_t *evt); | ||
void WifiEventHandler(System_Event_t *evt); | ||
|
||
onStationConnectDelegate onSTAConnect = nullptr; | ||
onStationDisconnectDelegate onSTADisconnect = nullptr; | ||
onStationAuthModeChangeDelegate onSTAAuthModeChange = nullptr; | ||
onStationGotIPDelegate onSTAGotIP = nullptr; | ||
onAccessPointConnectDelegate onSOFTAPConnect = nullptr; | ||
onAccessPointDisconnectDelegate onSOFTAPDisconnect = nullptr; | ||
onAccessPointProbeReqRecvedDelegate onSOFTAPProbeReqRecved = nullptr; | ||
}; | ||
|
||
|
||
extern WifiEventsClass WifiEvents; | ||
#endif /* SMINGCORE_PLATFORM_WIFIEVENTS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> | ||
<storageModule moduleId="org.eclipse.cdt.core.settings"> | ||
<cconfiguration id="0.131700304"> | ||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.131700304" moduleId="org.eclipse.cdt.core.settings" name="Default"> | ||
<externalSettings/> | ||
<extensions> | ||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
</extensions> | ||
</storageModule> | ||
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> | ||
<configuration buildProperties="" description="" id="0.131700304" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg"> | ||
<folderInfo id="0.131700304." name="/" resourcePath=""> | ||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.481709424" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain"> | ||
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.481709424.1637922483" name=""/> | ||
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1861624051" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/> | ||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.927548352" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/> | ||
<tool id="org.eclipse.cdt.build.core.settings.holder.1318259878" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.49095807" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
</tool> | ||
<tool id="org.eclipse.cdt.build.core.settings.holder.451866905" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.952230018" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
</tool> | ||
<tool id="org.eclipse.cdt.build.core.settings.holder.639761705" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.2127747414" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
</tool> | ||
</toolChain> | ||
</folderInfo> | ||
</configuration> | ||
</storageModule> | ||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> | ||
</cconfiguration> | ||
</storageModule> | ||
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> | ||
<project id="Basic_WebSkeletonApp.null.1098635923" name="Basic_WebSkeletonApp"/> | ||
</storageModule> | ||
<storageModule moduleId="scannerConfiguration"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
<scannerConfigBuildInfo instanceId="0.2058741737"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
</scannerConfigBuildInfo> | ||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.mingw.base.1135534147;cdt.managedbuild.toolchain.gnu.mingw.base.1135534147.86962463;cdt.managedbuild.tool.gnu.c.compiler.mingw.base.2032390008;cdt.managedbuild.tool.gnu.c.compiler.input.1700912488"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
</scannerConfigBuildInfo> | ||
<scannerConfigBuildInfo instanceId="0.147001341"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
</scannerConfigBuildInfo> | ||
<scannerConfigBuildInfo instanceId="0.1962726862"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
</scannerConfigBuildInfo> | ||
<scannerConfigBuildInfo instanceId="0.358052692"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
</scannerConfigBuildInfo> | ||
<scannerConfigBuildInfo instanceId="0.131700304"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
</scannerConfigBuildInfo> | ||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.mingw.base.1135534147;cdt.managedbuild.toolchain.gnu.mingw.base.1135534147.86962463;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base.454898447;cdt.managedbuild.tool.gnu.cpp.compiler.input.501261625"> | ||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
</scannerConfigBuildInfo> | ||
</storageModule> | ||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> | ||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"> | ||
<buildTargets> | ||
<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||
<buildCommand>make</buildCommand> | ||
<buildArguments/> | ||
<buildTarget>all</buildTarget> | ||
<stopOnError>true</stopOnError> | ||
<useDefaultCommand>true</useDefaultCommand> | ||
<runAllBuilders>true</runAllBuilders> | ||
</target> | ||
<target name="rebuild" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||
<buildCommand>make</buildCommand> | ||
<buildArguments/> | ||
<buildTarget>rebuild</buildTarget> | ||
<stopOnError>true</stopOnError> | ||
<useDefaultCommand>true</useDefaultCommand> | ||
<runAllBuilders>true</runAllBuilders> | ||
</target> | ||
<target name="flash" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> | ||
<buildCommand>make</buildCommand> | ||
<buildArguments/> | ||
<buildTarget>flash</buildTarget> | ||
<stopOnError>true</stopOnError> | ||
<useDefaultCommand>true</useDefaultCommand> | ||
<runAllBuilders>true</runAllBuilders> | ||
</target> | ||
</buildTargets> | ||
</storageModule> | ||
</cproject> |
Oops, something went wrong.