Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
Diff: NetworkInterface.h
- Revision:
- 0:ea85c4bb5e1f
- Child:
- 1:6ec9998427ad
diff -r 000000000000 -r ea85c4bb5e1f NetworkInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NetworkInterface.h Mon Aug 11 09:58:24 2014 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright 2014, ACKme Networks + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior + * written permission of ACKme Networks. + */ + +#pragma once + + +#include "WiconnectTypes.h" +#include "types/ScanResultList.h" + + +namespace wiconnect { + + +class NetworkInterface +{ +public: + WiconnectResult startWebSetup(const char *ssid = NULL, const char *password = NULL, const Callback &completeHandler = Callback()); + WiconnectResult stopWebSetup(); + WiconnectResult isWebSetupRunning(bool *isRunningPtr); + + WiconnectResult join(const char* ssid = NULL, const char *password = NULL, const Callback &completeHandler = Callback()); + WiconnectResult leave(); + WiconnectResult getNetworkStatus(NetworkStatus *statusPtr); + +// WiconnectResult startSoftAp(const char* ssid = NULL, const char *password = NULL, const Callback &clientConnectedCallback = Callback()); +// WiconnectResult stopSoftAp(); +// WiconnectResult getSoftApClientList(); + + WiconnectResult scan(ScanResultList &resultList, const uint8_t *channelList = NULL, const char* ssid = NULL); + WiconnectResult ping(const char *domain = NULL, uint32_t *timeMsPtr = NULL); + WiconnectResult lookup(const char *domain, uint32_t *ipAddressPtr); + + WiconnectResult setDhcpEnabled(bool enabled); + WiconnectResult getDhcpEnabled(bool *enabledPtr); + WiconnectResult setIpSettings(uint32_t ip, uint32_t netmask, uint32_t gateway); + WiconnectResult setIpSettings(const char* ip, const char* netmask, const char* gateway); + WiconnectResult getIpSettings(uint32_t *ip, uint32_t *netmask, uint32_t *gateway); + WiconnectResult getSignalStrength(NetworkSignalStrength *signalStrengthPtr); + + static bool strToIp(const char *str, uint32_t *intPtr); + static const char* ipToStr(uint32_t ip, char *ipStrBuffer = NULL); + static const char* networkStatusToStr(NetworkStatus status); + static const char* signalStrengthToStr(NetworkSignalStrength signalStrenth); + static NetworkSignalStrength rssiToSignalStrength(int rssi); + static NetworkSecurity strToNetworkSecurity(const char *str); + static const char* networkSecurityToStr(NetworkSecurity security); + static bool strToSsid(const char *str, Ssid *ssid); + static const char* ssidToStr(const Ssid *ssid, char *ssidStrBuffer = NULL); + static bool strToMacAddress(const char *str, MacAddress *macAddress); + static const char* macAddressToStr(const MacAddress *macAddress, char *macStrBuffer = NULL); + +protected: + NetworkInterface(Wiconnect *wiconnect); + + WiconnectResult processScanResults(char *resultStr, ScanResultList &resultList); + +#ifdef WICONNECT_ASYNC_TIMER_ENABLED + Callback completeHandler; + PeriodicTimer monitorTimer; + + void webSetupStatusMonitor(); + void webSetupStatusCheckCallback(WiconnectResult result, void *arg1, void *arg2); + + void joinStatusMonitor(); + void joinStatusCheckCallback(WiconnectResult result, void *arg1, void *arg2); + + //void scanCompleteCallback(WiconnectResult result, void *arg1, void *arg2); +#endif + +private: + Wiconnect *wiconnect; +}; + +} +