ESP32  1.0.4
WiFiGenericClass クラス

#include <WiFiGeneric.h>

WiFiGenericClass の継承関係図
WiFiClass

公開メンバ関数

 WiFiGenericClass ()
 
wifi_event_id_t onEvent (WiFiEventCb cbEvent, system_event_id_t event=SYSTEM_EVENT_MAX)
 
wifi_event_id_t onEvent (WiFiEventFuncCb cbEvent, system_event_id_t event=SYSTEM_EVENT_MAX)
 
wifi_event_id_t onEvent (WiFiEventSysCb cbEvent, system_event_id_t event=SYSTEM_EVENT_MAX)
 
void removeEvent (WiFiEventCb cbEvent, system_event_id_t event=SYSTEM_EVENT_MAX)
 
void removeEvent (WiFiEventSysCb cbEvent, system_event_id_t event=SYSTEM_EVENT_MAX)
 
void removeEvent (wifi_event_id_t id)
 
int32_t channel (void)
 
void persistent (bool persistent)
 
bool enableSTA (bool enable)
 
bool enableAP (bool enable)
 
bool setSleep (bool enable)
 
bool getSleep ()
 
bool setTxPower (wifi_power_t power)
 
wifi_power_t getTxPower ()
 

静的公開メンバ関数

static int getStatusBits ()
 
static int waitStatusBits (int bits, uint32_t timeout_ms)
 
static bool mode (wifi_mode_t)
 
static wifi_mode_t getMode ()
 
static esp_err_t _eventCallback (void *arg, system_event_t *event)
 
static int hostByName (const char *aHostname, IPAddress &aResult)
 
static IPAddress calculateNetworkID (IPAddress ip, IPAddress subnet)
 
static IPAddress calculateBroadcast (IPAddress ip, IPAddress subnet)
 
static uint8_t calculateSubnetCIDR (IPAddress subnetMask)
 

静的限定公開メンバ関数

static int setStatusBits (int bits)
 
static int clearStatusBits (int bits)
 

静的限定公開変数類

static bool _persistent = true
 
static wifi_mode_t _forceSleepLastMode = WIFI_MODE_NULL
 

フレンド

class WiFiSTAClass
 
class WiFiScanClass
 
class WiFiAPClass
 

詳解

WiFiGeneric.h68 行目に定義があります。

構築子と解体子

◆ WiFiGenericClass()

WiFiGenericClass::WiFiGenericClass ( )

WiFiGeneric.cpp195 行目に定義があります。

196 {
197 
198 }

関数詳解

◆ _eventCallback()

esp_err_t WiFiGenericClass::_eventCallback ( void *  arg,
system_event_t event 
)
static

WiFiGeneric.cpp334 行目に定義があります。

335 {
336  if(event->event_id < 26) {
337  log_d("Event: %d - %s", event->event_id, system_event_names[event->event_id]);
338  }
339  if(event->event_id == SYSTEM_EVENT_SCAN_DONE) {
341 
342  } else if(event->event_id == SYSTEM_EVENT_STA_START) {
344  setStatusBits(STA_STARTED_BIT);
345  } else if(event->event_id == SYSTEM_EVENT_STA_STOP) {
347  clearStatusBits(STA_STARTED_BIT | STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT);
348  } else if(event->event_id == SYSTEM_EVENT_STA_CONNECTED) {
350  setStatusBits(STA_CONNECTED_BIT);
351  } else if(event->event_id == SYSTEM_EVENT_STA_DISCONNECTED) {
352  uint8_t reason = event->event_info.disconnected.reason;
353  log_w("Reason: %u - %s", reason, reason2str(reason));
354  if(reason == WIFI_REASON_NO_AP_FOUND) {
356  } else if(reason == WIFI_REASON_AUTH_FAIL || reason == WIFI_REASON_ASSOC_FAIL) {
358  } else if(reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) {
360  } else if(reason == WIFI_REASON_AUTH_EXPIRE) {
361 
362  } else {
364  }
365  clearStatusBits(STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT);
366  if(((reason == WIFI_REASON_AUTH_EXPIRE) ||
367  (reason >= WIFI_REASON_BEACON_TIMEOUT && reason != WIFI_REASON_AUTH_FAIL)) &&
369  {
370  WiFi.disconnect();
371  WiFi.begin();
372  }
373  } else if(event->event_id == SYSTEM_EVENT_STA_GOT_IP) {
374 #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
375  uint8_t * ip = (uint8_t *)&(event->event_info.got_ip.ip_info.ip.addr);
376  uint8_t * mask = (uint8_t *)&(event->event_info.got_ip.ip_info.netmask.addr);
377  uint8_t * gw = (uint8_t *)&(event->event_info.got_ip.ip_info.gw.addr);
378  log_d("STA IP: %u.%u.%u.%u, MASK: %u.%u.%u.%u, GW: %u.%u.%u.%u",
379  ip[0], ip[1], ip[2], ip[3],
380  mask[0], mask[1], mask[2], mask[3],
381  gw[0], gw[1], gw[2], gw[3]);
382 #endif
384  setStatusBits(STA_HAS_IP_BIT | STA_CONNECTED_BIT);
385  } else if(event->event_id == SYSTEM_EVENT_STA_LOST_IP) {
387  clearStatusBits(STA_HAS_IP_BIT);
388 
389  } else if(event->event_id == SYSTEM_EVENT_AP_START) {
390  setStatusBits(AP_STARTED_BIT);
391  } else if(event->event_id == SYSTEM_EVENT_AP_STOP) {
392  clearStatusBits(AP_STARTED_BIT | AP_HAS_CLIENT_BIT);
393  } else if(event->event_id == SYSTEM_EVENT_AP_STACONNECTED) {
394  setStatusBits(AP_HAS_CLIENT_BIT);
395  } else if(event->event_id == SYSTEM_EVENT_AP_STADISCONNECTED) {
396  wifi_sta_list_t clients;
397  if(esp_wifi_ap_get_sta_list(&clients) != ESP_OK || !clients.num){
398  clearStatusBits(AP_HAS_CLIENT_BIT);
399  }
400 
401  } else if(event->event_id == SYSTEM_EVENT_ETH_START) {
402  setStatusBits(ETH_STARTED_BIT);
403  } else if(event->event_id == SYSTEM_EVENT_ETH_STOP) {
404  clearStatusBits(ETH_STARTED_BIT | ETH_CONNECTED_BIT | ETH_HAS_IP_BIT | ETH_HAS_IP6_BIT);
405  } else if(event->event_id == SYSTEM_EVENT_ETH_CONNECTED) {
406  setStatusBits(ETH_CONNECTED_BIT);
407  } else if(event->event_id == SYSTEM_EVENT_ETH_DISCONNECTED) {
408  clearStatusBits(ETH_CONNECTED_BIT | ETH_HAS_IP_BIT | ETH_HAS_IP6_BIT);
409  } else if(event->event_id == SYSTEM_EVENT_ETH_GOT_IP) {
410 #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
411  uint8_t * ip = (uint8_t *)&(event->event_info.got_ip.ip_info.ip.addr);
412  uint8_t * mask = (uint8_t *)&(event->event_info.got_ip.ip_info.netmask.addr);
413  uint8_t * gw = (uint8_t *)&(event->event_info.got_ip.ip_info.gw.addr);
414  log_d("ETH IP: %u.%u.%u.%u, MASK: %u.%u.%u.%u, GW: %u.%u.%u.%u",
415  ip[0], ip[1], ip[2], ip[3],
416  mask[0], mask[1], mask[2], mask[3],
417  gw[0], gw[1], gw[2], gw[3]);
418 #endif
419  setStatusBits(ETH_CONNECTED_BIT | ETH_HAS_IP_BIT);
420 
421  } else if(event->event_id == SYSTEM_EVENT_GOT_IP6) {
422  if(event->event_info.got_ip6.if_index == TCPIP_ADAPTER_IF_AP){
423  setStatusBits(AP_HAS_IP6_BIT);
424  } else if(event->event_info.got_ip6.if_index == TCPIP_ADAPTER_IF_STA){
425  setStatusBits(STA_CONNECTED_BIT | STA_HAS_IP6_BIT);
426  } else if(event->event_info.got_ip6.if_index == TCPIP_ADAPTER_IF_ETH){
427  setStatusBits(ETH_CONNECTED_BIT | ETH_HAS_IP6_BIT);
428  }
429  }
430 
431  for(uint32_t i = 0; i < cbEventList.size(); i++) {
432  WiFiEventCbList_t entry = cbEventList[i];
433  if(entry.cb || entry.fcb || entry.scb) {
434  if(entry.event == (system_event_id_t) event->event_id || entry.event == SYSTEM_EVENT_MAX) {
435  if(entry.cb) {
436  entry.cb((system_event_id_t) event->event_id);
437  } else if(entry.fcb) {
438  entry.fcb((system_event_id_t) event->event_id, (system_event_info_t) event->event_info);
439  } else {
440  entry.scb(event);
441  }
442  }
443  }
444  }
445  return ESP_OK;
446 }
esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta)
Get STAs associated with soft-AP
system_event_id_t
static void _scanDone()
Definition: WiFiScan.cpp:109
#define log_w(format,...)
#define ESP_OK
Definition: esp_err.h:27
static int setStatusBits(int bits)
wl_status_t begin(const char *ssid, const char *passphrase=NULL, int32_t channel=0, const uint8_t *bssid=NULL, bool connect=true)
Definition: WiFiSTA.cpp:115
bool getAutoReconnect()
Definition: WiFiSTA.cpp:381
__uint32_t uint32_t
Definition: stdint.h:45
#define log_d(format,...)
Definition: esp32-hal-log.h:92
static int clearStatusBits(int bits)
WiFiClass WiFi
Definition: WiFi.cpp:91
null_event event
Definition: event.hpp:36
static void _setStatus(wl_status_t status)
Definition: WiFiSTA.cpp:78
Definition: search.h:16
__uint8_t uint8_t
Definition: stdint.h:21
const char * system_event_names[]
List of stations associated with the ESP32 Soft-AP
bool disconnect(bool wifioff=false, bool eraseap=false)
Definition: WiFiSTA.cpp:245
#define reason2str(r)

◆ calculateBroadcast()

IPAddress WiFiGenericClass::calculateBroadcast ( IPAddress  ip,
IPAddress  subnet 
)
static

WiFiGeneric.cpp668 行目に定義があります。

668  {
669  IPAddress broadcastIp;
670 
671  for (int i = 0; i < 4; i++)
672  broadcastIp[i] = ~subnet[i] | ip[i];
673 
674  return broadcastIp;
675 }

◆ calculateNetworkID()

IPAddress WiFiGenericClass::calculateNetworkID ( IPAddress  ip,
IPAddress  subnet 
)
static

WiFiGeneric.cpp659 行目に定義があります。

659  {
660  IPAddress networkID;
661 
662  for (size_t i = 0; i < 4; i++)
663  networkID[i] = subnet[i] & ip[i];
664 
665  return networkID;
666 }

◆ calculateSubnetCIDR()

uint8_t WiFiGenericClass::calculateSubnetCIDR ( IPAddress  subnetMask)
static

WiFiGeneric.cpp677 行目に定義があります。

677  {
678  uint8_t CIDR = 0;
679 
680  for (uint8_t i = 0; i < 4; i++) {
681  if (subnetMask[i] == 0x80) // 128
682  CIDR += 1;
683  else if (subnetMask[i] == 0xC0) // 192
684  CIDR += 2;
685  else if (subnetMask[i] == 0xE0) // 224
686  CIDR += 3;
687  else if (subnetMask[i] == 0xF0) // 242
688  CIDR += 4;
689  else if (subnetMask[i] == 0xF8) // 248
690  CIDR += 5;
691  else if (subnetMask[i] == 0xFC) // 252
692  CIDR += 6;
693  else if (subnetMask[i] == 0xFE) // 254
694  CIDR += 7;
695  else if (subnetMask[i] == 0xFF) // 255
696  CIDR += 8;
697  }
698 
699  return CIDR;
700 }
__uint8_t uint8_t
Definition: stdint.h:21

◆ channel()

int32_t WiFiGenericClass::channel ( void  )

Return the current channel associated with the network

戻り値
channel (1-13)

WiFiGeneric.cpp452 行目に定義があります。

453 {
454  uint8_t primaryChan = 0;
456  if(!lowLevelInitDone){
457  return primaryChan;
458  }
459  esp_wifi_get_channel(&primaryChan, &secondChan);
460  return primaryChan;
461 }
wifi_second_chan_t
__uint8_t uint8_t
Definition: stdint.h:21
esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second)
Get the primary/secondary channel of ESP32

◆ clearStatusBits()

int WiFiGenericClass::clearStatusBits ( int  bits)
staticprotected

WiFiGeneric.cpp207 行目に定義があります。

207  {
208  if(!_network_event_group){
209  return 0;
210  }
211  return xEventGroupClearBits(_network_event_group, bits);
212 }
EventBits_t xEventGroupClearBits(EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear) PRIVILEGED_FUNCTION

◆ enableAP()

bool WiFiGenericClass::enableAP ( bool  enable)

control AP mode

引数
enablebool
戻り値
ok

WiFiGeneric.cpp543 行目に定義があります。

544 {
545 
546  wifi_mode_t currentMode = getMode();
547  bool isEnabled = ((currentMode & WIFI_MODE_AP) != 0);
548 
549  if(isEnabled != enable) {
550  if(enable) {
551  return mode((wifi_mode_t)(currentMode | WIFI_MODE_AP));
552  }
553  return mode((wifi_mode_t)(currentMode & (~WIFI_MODE_AP)));
554  }
555  return true;
556 }
static wifi_mode_t getMode()
static bool mode(wifi_mode_t)
wifi_mode_t

◆ enableSTA()

bool WiFiGenericClass::enableSTA ( bool  enable)

control STA mode

引数
enablebool
戻り値
ok

WiFiGeneric.cpp523 行目に定義があります。

524 {
525 
526  wifi_mode_t currentMode = getMode();
527  bool isEnabled = ((currentMode & WIFI_MODE_STA) != 0);
528 
529  if(isEnabled != enable) {
530  if(enable) {
531  return mode((wifi_mode_t)(currentMode | WIFI_MODE_STA));
532  }
533  return mode((wifi_mode_t)(currentMode & (~WIFI_MODE_STA)));
534  }
535  return true;
536 }
static wifi_mode_t getMode()
static bool mode(wifi_mode_t)
wifi_mode_t

◆ getMode()

wifi_mode_t WiFiGenericClass::getMode ( )
static

get WiFi mode

戻り値
WiFiMode

WiFiGeneric.cpp505 行目に定義があります。

506 {
507  if(!_esp_wifi_started){
508  return WIFI_MODE_NULL;
509  }
512  log_w("WiFi not started");
513  return WIFI_MODE_NULL;
514  }
515  return mode;
516 }
#define log_w(format,...)
static bool mode(wifi_mode_t)
esp_err_t esp_wifi_get_mode(wifi_mode_t *mode)
Get current operating mode of WiFi
#define ESP_ERR_WIFI_NOT_INIT
Definition: esp_wifi.h:71
wifi_mode_t

◆ getSleep()

bool WiFiGenericClass::getSleep ( )

get modem sleep enabled

戻り値
true if modem sleep is enabled

WiFiGeneric.cpp576 行目に定義があります。

577 {
578  wifi_ps_type_t ps;
579  if((getMode() & WIFI_MODE_STA) == 0){
580  log_w("STA has not been started");
581  return false;
582  }
583  if(esp_wifi_get_ps(&ps) == ESP_OK){
584  return ps == WIFI_PS_MIN_MODEM;
585  }
586  return false;
587 }
static wifi_mode_t getMode()
#define log_w(format,...)
#define ESP_OK
Definition: esp_err.h:27
wifi_ps_type_t
esp_err_t esp_wifi_get_ps(wifi_ps_type_t *type)
Get current WiFi power save type

◆ getStatusBits()

int WiFiGenericClass::getStatusBits ( )
static

WiFiGeneric.cpp214 行目に定義があります。

214  {
215  if(!_network_event_group){
216  return 0;
217  }
218  return xEventGroupGetBits(_network_event_group);
219 }
#define xEventGroupGetBits(xEventGroup)
Definition: event_groups.h:685

◆ getTxPower()

wifi_power_t WiFiGenericClass::getTxPower ( )

WiFiGeneric.cpp602 行目に定義があります。

602  {
603  int8_t power;
604  if((getStatusBits() & (STA_STARTED_BIT | AP_STARTED_BIT)) == 0){
605  log_w("Neither AP or STA has been started");
606  return WIFI_POWER_19_5dBm;
607  }
608  if(esp_wifi_get_max_tx_power(&power)){
609  return WIFI_POWER_19_5dBm;
610  }
611  return (wifi_power_t)power;
612 }
#define log_w(format,...)
static int getStatusBits()
__int8_t int8_t
Definition: stdint.h:20
esp_err_t esp_wifi_get_max_tx_power(int8_t *power)
Get maximum WiFi transmiting power
wifi_power_t
Definition: WiFiGeneric.h:37

◆ hostByName()

int WiFiGenericClass::hostByName ( const char *  aHostname,
IPAddress aResult 
)
static

Resolve the given hostname to an IP address.

引数
aHostnameName to be resolved
aResultIPAddress structure to store the returned IP address
戻り値
1 if aIPAddrString was successfully converted to an IP address, else error code

WiFiGeneric.cpp639 行目に定義があります。

640 {
641  ip_addr_t addr;
642  aResult = static_cast<uint32_t>(0);
643  waitStatusBits(WIFI_DNS_IDLE_BIT, 5000);
644  clearStatusBits(WIFI_DNS_IDLE_BIT);
645  err_t err = dns_gethostbyname(aHostname, &addr, &wifi_dns_found_callback, &aResult);
646  if(err == ERR_OK && addr.u_addr.ip4.addr) {
647  aResult = addr.u_addr.ip4.addr;
648  } else if(err == ERR_INPROGRESS) {
649  waitStatusBits(WIFI_DNS_DONE_BIT, 4000);
650  clearStatusBits(WIFI_DNS_DONE_BIT);
651  }
652  setStatusBits(WIFI_DNS_IDLE_BIT);
653  if((uint32_t)aResult == 0){
654  log_e("DNS Failed for %s", aHostname);
655  }
656  return (uint32_t)aResult != 0;
657 }
static int setStatusBits(int bits)
__uint32_t uint32_t
Definition: stdint.h:45
static int clearStatusBits(int bits)
#define log_e(format,...)
s8_t err_t
Definition: err.h:57
ip6_addr_t ip_addr_t
Definition: ip_addr.h:295
Definition: err.h:63
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
static int waitStatusBits(int bits, uint32_t timeout_ms)

◆ mode()

bool WiFiGenericClass::mode ( wifi_mode_t  m)
static

set new mode

引数
mWiFiMode_t

WiFiGeneric.cpp478 行目に定義があります。

479 {
480  wifi_mode_t cm = getMode();
481  if(cm == m) {
482  return true;
483  }
484  if(!cm && m){
485  if(!espWiFiStart(_persistent)){
486  return false;
487  }
488  } else if(cm && !m){
489  return espWiFiStop();
490  }
491 
492  esp_err_t err;
493  err = esp_wifi_set_mode(m);
494  if(err){
495  log_e("Could not set mode! %d", err);
496  return false;
497  }
498  return true;
499 }
static wifi_mode_t getMode()
static bool _persistent
Definition: WiFiGeneric.h:102
#define log_e(format,...)
esp_err_t esp_wifi_set_mode(wifi_mode_t mode)
Set the WiFi operating mode
wifi_mode_t
int32_t esp_err_t
Definition: esp_err.h:24

◆ onEvent() [1/3]

wifi_event_id_t WiFiGenericClass::onEvent ( WiFiEventCb  cbEvent,
system_event_id_t  event = SYSTEM_EVENT_MAX 
)

set callback function

引数
cbEventWiFiEventCb
eventoptional filter (WIFI_EVENT_MAX is all events)

WiFiGeneric.cpp238 行目に定義があります。

239 {
240  if(!cbEvent) {
241  return 0;
242  }
243  WiFiEventCbList_t newEventHandler;
244  newEventHandler.cb = cbEvent;
245  newEventHandler.fcb = NULL;
246  newEventHandler.scb = NULL;
247  newEventHandler.event = event;
248  cbEventList.push_back(newEventHandler);
249  return newEventHandler.id;
250 }
WiFiEventCb cb
#define NULL
Definition: def.h:70
WiFiEventSysCb scb
system_event_id_t event
null_event event
Definition: event.hpp:36
WiFiEventFuncCb fcb
wifi_event_id_t id

◆ onEvent() [2/3]

wifi_event_id_t WiFiGenericClass::onEvent ( WiFiEventFuncCb  cbEvent,
system_event_id_t  event = SYSTEM_EVENT_MAX 
)

WiFiGeneric.cpp252 行目に定義があります。

253 {
254  if(!cbEvent) {
255  return 0;
256  }
257  WiFiEventCbList_t newEventHandler;
258  newEventHandler.cb = NULL;
259  newEventHandler.fcb = cbEvent;
260  newEventHandler.scb = NULL;
261  newEventHandler.event = event;
262  cbEventList.push_back(newEventHandler);
263  return newEventHandler.id;
264 }
WiFiEventCb cb
#define NULL
Definition: def.h:70
WiFiEventSysCb scb
system_event_id_t event
null_event event
Definition: event.hpp:36
WiFiEventFuncCb fcb
wifi_event_id_t id

◆ onEvent() [3/3]

wifi_event_id_t WiFiGenericClass::onEvent ( WiFiEventSysCb  cbEvent,
system_event_id_t  event = SYSTEM_EVENT_MAX 
)

WiFiGeneric.cpp266 行目に定義があります。

267 {
268  if(!cbEvent) {
269  return 0;
270  }
271  WiFiEventCbList_t newEventHandler;
272  newEventHandler.cb = NULL;
273  newEventHandler.fcb = NULL;
274  newEventHandler.scb = cbEvent;
275  newEventHandler.event = event;
276  cbEventList.push_back(newEventHandler);
277  return newEventHandler.id;
278 }
WiFiEventCb cb
#define NULL
Definition: def.h:70
WiFiEventSysCb scb
system_event_id_t event
null_event event
Definition: event.hpp:36
WiFiEventFuncCb fcb
wifi_event_id_t id

◆ persistent()

void WiFiGenericClass::persistent ( bool  persistent)

store WiFi config in SDK flash area

引数
persistent

WiFiGeneric.cpp468 行目に定義があります。

469 {
471 }
void persistent(bool persistent)
static bool _persistent
Definition: WiFiGeneric.h:102

◆ removeEvent() [1/3]

void WiFiGenericClass::removeEvent ( WiFiEventCb  cbEvent,
system_event_id_t  event = SYSTEM_EVENT_MAX 
)

removes a callback form event handler

引数
cbEventWiFiEventCb
eventoptional filter (WIFI_EVENT_MAX is all events)

WiFiGeneric.cpp285 行目に定義があります。

286 {
287  if(!cbEvent) {
288  return;
289  }
290 
291  for(uint32_t i = 0; i < cbEventList.size(); i++) {
292  WiFiEventCbList_t entry = cbEventList[i];
293  if(entry.cb == cbEvent && entry.event == event) {
294  cbEventList.erase(cbEventList.begin() + i);
295  }
296  }
297 }
__uint32_t uint32_t
Definition: stdint.h:45
null_event event
Definition: event.hpp:36
Definition: search.h:16

◆ removeEvent() [2/3]

void WiFiGenericClass::removeEvent ( WiFiEventSysCb  cbEvent,
system_event_id_t  event = SYSTEM_EVENT_MAX 
)

WiFiGeneric.cpp299 行目に定義があります。

300 {
301  if(!cbEvent) {
302  return;
303  }
304 
305  for(uint32_t i = 0; i < cbEventList.size(); i++) {
306  WiFiEventCbList_t entry = cbEventList[i];
307  if(entry.scb == cbEvent && entry.event == event) {
308  cbEventList.erase(cbEventList.begin() + i);
309  }
310  }
311 }
__uint32_t uint32_t
Definition: stdint.h:45
null_event event
Definition: event.hpp:36
Definition: search.h:16

◆ removeEvent() [3/3]

void WiFiGenericClass::removeEvent ( wifi_event_id_t  id)

WiFiGeneric.cpp313 行目に定義があります。

314 {
315  for(uint32_t i = 0; i < cbEventList.size(); i++) {
316  WiFiEventCbList_t entry = cbEventList[i];
317  if(entry.id == id) {
318  cbEventList.erase(cbEventList.begin() + i);
319  }
320  }
321 }
__uint32_t uint32_t
Definition: stdint.h:45
Definition: search.h:16

◆ setSleep()

bool WiFiGenericClass::setSleep ( bool  enable)

control modem sleep when only in STA mode

引数
enablebool
戻り値
ok

WiFiGeneric.cpp563 行目に定義があります。

564 {
565  if((getMode() & WIFI_MODE_STA) == 0){
566  log_w("STA has not been started");
567  return false;
568  }
570 }
static wifi_mode_t getMode()
#define log_w(format,...)
#define ESP_OK
Definition: esp_err.h:27
esp_err_t esp_wifi_set_ps(wifi_ps_type_t type)
Set current WiFi power save type

◆ setStatusBits()

int WiFiGenericClass::setStatusBits ( int  bits)
staticprotected

WiFiGeneric.cpp200 行目に定義があります。

200  {
201  if(!_network_event_group){
202  return 0;
203  }
204  return xEventGroupSetBits(_network_event_group, bits);
205 }
EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet) PRIVILEGED_FUNCTION

◆ setTxPower()

bool WiFiGenericClass::setTxPower ( wifi_power_t  power)

control wifi tx power

引数
powerenum maximum wifi tx power
戻り値
ok

WiFiGeneric.cpp594 行目に定義があります。

594  {
595  if((getStatusBits() & (STA_STARTED_BIT | AP_STARTED_BIT)) == 0){
596  log_w("Neither AP or STA has been started");
597  return false;
598  }
599  return esp_wifi_set_max_tx_power(power) == ESP_OK;
600 }
#define log_w(format,...)
#define ESP_OK
Definition: esp_err.h:27
static int getStatusBits()
esp_err_t esp_wifi_set_max_tx_power(int8_t power)
Set maximum WiFi transmitting power

◆ waitStatusBits()

int WiFiGenericClass::waitStatusBits ( int  bits,
uint32_t  timeout_ms 
)
static

WiFiGeneric.cpp221 行目に定義があります。

221  {
222  if(!_network_event_group){
223  return 0;
224  }
225  return xEventGroupWaitBits(
226  _network_event_group, // The event group being tested.
227  bits, // The bits within the event group to wait for.
228  pdFALSE, // BIT_0 and BIT_4 should be cleared before returning.
229  pdTRUE, // Don't wait for both bits, either bit will do.
230  timeout_ms / portTICK_PERIOD_MS ) & bits; // Wait a maximum of 100ms for either bit to be set.
231 }
#define pdTRUE
Definition: projdefs.h:83
#define portTICK_PERIOD_MS
Definition: portmacro.h:298
EventBits_t xEventGroupWaitBits(EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
#define pdFALSE
Definition: projdefs.h:82

フレンドと関連関数の詳解

◆ WiFiAPClass

friend class WiFiAPClass
friend

WiFiGeneric.h118 行目に定義があります。

◆ WiFiScanClass

friend class WiFiScanClass
friend

WiFiGeneric.h117 行目に定義があります。

◆ WiFiSTAClass

friend class WiFiSTAClass
friend

WiFiGeneric.h116 行目に定義があります。

メンバ詳解

◆ _forceSleepLastMode

wifi_mode_t WiFiGenericClass::_forceSleepLastMode = WIFI_MODE_NULL
staticprotected

WiFiGeneric.h103 行目に定義があります。

◆ _persistent

bool WiFiGenericClass::_persistent = true
staticprotected

WiFiGeneric.h102 行目に定義があります。


このクラス詳解は次のファイルから抽出されました: