libPocuter 1.0 Support library for programming the Pocuter

Classes | Public Types | Public Member Functions | List of all members
PocuterWIFI Class Referenceabstract

Pocuter WIFI configurations. More...

`#include <PocuterWIFI.h>`

## Classes
struct | apInfo
struct | ipInfo
struct | wifiCredentials

## Public Types
enum | AUTH_MODE { WIFIAUTH_OPEN = 0, WIFIAUTH_WEP, WIFIAUTH_WPA_PSK, WIFIAUTH_WPA2_PSK, WIFIAUTH_WPA_WPA2_PSK, WIFIAUTH_WPA2_ENTERPRISE, WIFIAUTH_WPA3_PSK, WIFIAUTH_WPA2_WPA3_PSK, WIFIAUTH_WAPI_PSK, WIFIAUTH_MAX }
enum | WIFIERROR { WIFIERROR_OK = 0, WIFIERROR_INIT_FAILED, WIFIERROR_COULD_NOT_SET_WIFI_MODE, WIFIERROR_NO_CREDENTIALS, WIFIERROR_WPS_TIMEOUT, WIFIERROR_UNKNOWN }
enum | WIFIEVENT { WIFIEVENT_DISCONNECTED, WIFIEVENT_CONNECTED, WIFIEVENT_TRY_CONNECTING, WIFIEVENT_GOT_IP, WIFIEVENT_WPS_TIMEOUT, WIFIEVENT_WPS_FAILED }
enum | WIFI_STATE { WIFI_STATE_INIT_FAILED, WIFI_STATE_DISCONNECTED, WIFI_STATE_TRY_CONNECTING, WIFI_STATE_CONNECTED, WIFI_WAITING_WPS, WIFI_WAITING_AP }
typedef void() | wifiEventHandler(WIFIEVENT, void *data, void *userData)
| typedef of the event handler More...

## Public Member Functions
virtual WIFI_STATE | getState ()=0
| get the state of the WIFI More...
virtual void | registerEventHandler (wifiEventHandler *h, void *u)=0
| registers an event handler More...
virtual WIFIERROR | startWPS ()=0
| starts WPS request. More...
virtual WIFIERROR | startAccessPoint ()=0
| starts an access point to set the WIFI credentials More...
virtual WIFIERROR | getCredentials (wifiCredentials *c)=0
| get the current credentials More...
virtual WIFIERROR | connect ()=0
| connect to wifi with saved credentials More...
virtual WIFIERROR | connect (const wifiCredentials *c)=0
| connect to wifi with given credentials More...
virtual WIFIERROR | scanAPs (apInfo *i, uint16_t *size, uint16_t *totalAPs)=0
| scan for access points More...
virtual const ipInfo * | getIpInfo ()=0
| get ipInfo More...

## Detailed Description

Pocuter WIFI configurations.

## Member Typedef Documentation

## ◆ wifiEventHandler

typedef void() PocuterWIFI::wifiEventHandler(WIFIEVENT, void *data, void *userData)

typedef of the event handler

Parameters

  WIFIEVENT | the type of event
  data | additionally event data
  userData | a pointer to userdata, set by registerEventHandler

## Member Enumeration Documentation

## ◆ AUTH_MODE

enum PocuterWIFI::AUTH_MODE

Enumerator
WIFIAUTH_OPEN | authenticate mode : open
WIFIAUTH_WEP | authenticate mode : WEP
WIFIAUTH_WPA_PSK | authenticate mode : WPA_PSK
WIFIAUTH_WPA2_PSK | authenticate mode : WPA2_PSK
WIFIAUTH_WPA_WPA2_PSK | authenticate mode : WPA_WPA2_PSK
WIFIAUTH_WPA2_ENTERPRISE | authenticate mode : WPA2_ENTERPRISE
WIFIAUTH_WPA3_PSK | authenticate mode : WPA3_PSK
WIFIAUTH_WPA2_WPA3_PSK | authenticate mode : WPA2_WPA3_PSK
WIFIAUTH_WAPI_PSK | authenticate mode : WAPI_PSK
WIFIAUTH_MAX |

## ◆ WIFI_STATE

enum PocuterWIFI::WIFI_STATE

Enumerator
WIFI_STATE_INIT_FAILED |
WIFI_STATE_DISCONNECTED |
WIFI_STATE_TRY_CONNECTING |
WIFI_STATE_CONNECTED |
WIFI_WAITING_WPS |
WIFI_WAITING_AP |

## ◆ WIFIERROR

enum PocuterWIFI::WIFIERROR

Enumerator
WIFIERROR_OK |
WIFIERROR_INIT_FAILED |
WIFIERROR_COULD_NOT_SET_WIFI_MODE |
WIFIERROR_NO_CREDENTIALS |
WIFIERROR_WPS_TIMEOUT |
WIFIERROR_UNKNOWN |

## ◆ WIFIEVENT

enum PocuterWIFI::WIFIEVENT

Enumerator
WIFIEVENT_DISCONNECTED |
WIFIEVENT_CONNECTED |
WIFIEVENT_TRY_CONNECTING |
WIFIEVENT_GOT_IP |
WIFIEVENT_WPS_TIMEOUT |
WIFIEVENT_WPS_FAILED |

## Member Function Documentation

## ◆ connect() [1/2]

virtual WIFIERROR PocuterWIFI::connect | ( |  | ) |
| pure virtual

connect to wifi with saved credentials

Note
  The function will not block. You can see the current state by polling getState or setting the eventhandler.

Returns
  WIFIERROR_OK the access point is available WIFIERROR_INIT_FAILED could not init WIFI

## ◆ connect() [2/2]

virtual WIFIERROR PocuterWIFI::connect | ( | const wifiCredentials * | c | ) |
| pure virtual

connect to wifi with given credentials

Note
  The function will not block. You can see the current state by polling getState or setting the eventhandler.

Parameters

  c | a pointer to a wifiCredentials struct with credentials

Returns
  WIFIERROR_OK the access point is available WIFIERROR_INIT_FAILED could not init WIFI

## ◆ getCredentials()

virtual WIFIERROR PocuterWIFI::getCredentials | ( | wifiCredentials * | c | ) |
| pure virtual

get the current credentials

Parameters

  c | (out) a pointer to a wifiCredentials struct

Returns
  WIFIERROR_OK the access point is available

## ◆ getIpInfo()

virtual const ipInfo* PocuterWIFI::getIpInfo | ( |  | ) |
| pure virtual

get ipInfo

Note
  you will only get an ipInfo if you are connected. Otherwise you will get NULL.

Returns
  ipInfo the ipInfo struct NULL if you are not connected

## ◆ getState()

virtual WIFI_STATE PocuterWIFI::getState | ( |  | ) |
| pure virtual

get the state of the WIFI

Returns
  WIFI_STATE

## ◆ registerEventHandler()

virtual void PocuterWIFI::registerEventHandler | ( | wifiEventHandler * | h,
|  | void * | u
| ) |  |
| pure virtual

registers an event handler

Parameters

  h | a pointer to the callback function
  u | a pointer to user data sent to the event handler on each event

## ◆ scanAPs()

virtual WIFIERROR PocuterWIFI::scanAPs | ( | apInfo * | i,
|  | uint16_t * | size,
|  | uint16_t * | totalAPs
| ) |  |
| pure virtual

scan for access points

Note
  this function will block. You have to allocate the memory of the apInfo array and set the size in the size parameter.

Parameters

  i | an array of apInfo's already allocated
  size | (in and out) set this to the cont of the allocated apInfo elements and it will be set to the actually saved access point count.
  totalAPs | (out) the total number of access points found

Returns
  WIFIERROR_OK the access point is available WIFIERROR_INIT_FAILED could not init WIFI

## ◆ startAccessPoint()

virtual WIFIERROR PocuterWIFI::startAccessPoint | ( |  | ) |
| pure virtual

starts an access point to set the WIFI credentials

Note
  the access point will be called "Pocuter". The function will not block. The Pocter will restart when the credentials were set.

Returns
  WIFIERROR_OK the access point is available

## ◆ startWPS()

virtual WIFIERROR PocuterWIFI::startWPS | ( |  | ) |
| pure virtual

starts WPS request.

Note
  the function will block until a timeout or the WPS was successful

Returns
  WIFIERROR_WPS_TIMEOUT it timed out
  WIFIERROR_OK a new connection was established

The documentation for this class was generated from the following file:

- include/hal/PocuterWIFI.h