Skip to content

Commit 858d6fd

Browse files
author
yichone
committed
Merge branch 'master' into master
2 parents 6d87ef5 + 7e0f839 commit 858d6fd

File tree

3 files changed

+86
-10
lines changed

3 files changed

+86
-10
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,43 @@ void ESP8266WiFiClass::_smartConfigCallback(uint32_t st, void* result)
897897
}
898898
}
899899

900+
901+
//--------------------------------------------------------------
902+
903+
/**
904+
* set Sleep mode
905+
* @param type sleep_type_t
906+
* @return bool
907+
*/
908+
bool ESP8266WiFiClass::setSleepMode(WiFiSleepType_t type) {
909+
return wifi_set_sleep_type((sleep_type_t)type);
910+
}
911+
912+
/**
913+
* get Sleep mode
914+
* @return sleep_type_t
915+
*/
916+
WiFiSleepType_t ESP8266WiFiClass::getSleepMode() {
917+
return (WiFiSleepType_t)wifi_get_sleep_type();
918+
}
919+
920+
/**
921+
* set phy Mode
922+
* @param mode phy_mode_t
923+
* @return bool
924+
*/
925+
bool ESP8266WiFiClass::setPhyMode(WiFiPhyMode_t mode) {
926+
return wifi_set_phy_mode((phy_mode_t)mode);
927+
}
928+
929+
/**
930+
* get phy Mode
931+
* @return phy_mode_t
932+
*/
933+
WiFiPhyMode_t ESP8266WiFiClass::getPhyMode() {
934+
return (WiFiPhyMode_t)wifi_get_phy_mode();
935+
}
936+
900937
//--------------------------------------------------------------
901938

902939
void ESP8266WiFiClass::_eventCallback(void* arg)

libraries/ESP8266WiFi/src/ESP8266WiFi.h

+39
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,21 @@ extern "C" {
3636
#define WIFI_SCAN_RUNNING (-1)
3737
#define WIFI_SCAN_FAILED (-2)
3838

39+
40+
// Note:
41+
// this enums need to be in sync with the SDK!
42+
3943
enum WiFiMode { WIFI_OFF = 0, WIFI_STA = 1, WIFI_AP = 2, WIFI_AP_STA = 3 };
4044

45+
typedef enum {
46+
WIFI_PHY_MODE_11B = 1, WIFI_PHY_MODE_11G = 2, WIFI_PHY_MODE_11N = 3
47+
} WiFiPhyMode_t;
48+
49+
typedef enum {
50+
WIFI_NONE_SLEEP = 0, WIFI_LIGHT_SLEEP = 2, WIFI_MODEM_SLEEP = 3
51+
} WiFiSleepType_t;
52+
53+
4154
class ESP8266WiFiClass
4255
{
4356
public:
@@ -375,6 +388,32 @@ class ESP8266WiFiClass
375388
friend class WiFiClient;
376389
friend class WiFiServer;
377390

391+
/**
392+
* set Sleep mode
393+
* @param type WiFiPhyMode_t
394+
* @return bool
395+
*/
396+
bool setSleepMode(WiFiSleepType_t type);
397+
398+
/**
399+
* get Sleep mode
400+
* @return sleep_type_t
401+
*/
402+
WiFiSleepType_t getSleepMode();
403+
404+
/**
405+
* set phy Mode
406+
* @param mode phy_mode_t
407+
* @return bool
408+
*/
409+
bool setPhyMode(WiFiPhyMode_t mode);
410+
411+
/**
412+
* get phy Mode
413+
* @return phy_mode_t
414+
*/
415+
WiFiPhyMode_t getPhyMode();
416+
378417
protected:
379418
void _mode(WiFiMode);
380419
static void _scanDone(void* result, int status);

tools/sdk/include/user_interface.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -333,30 +333,30 @@ void wifi_set_promiscuous_rx_cb(wifi_promiscuous_cb_t cb);
333333

334334
void wifi_promiscuous_set_mac(const uint8_t *address);
335335

336-
enum phy_mode {
336+
typedef enum {
337337
PHY_MODE_11B = 1,
338338
PHY_MODE_11G = 2,
339339
PHY_MODE_11N = 3
340-
};
340+
} phy_mode_t;
341341

342-
enum phy_mode wifi_get_phy_mode(void);
343-
bool wifi_set_phy_mode(enum phy_mode mode);
342+
phy_mode_t wifi_get_phy_mode(void);
343+
bool wifi_set_phy_mode(phy_mode_t mode);
344344

345-
enum sleep_type {
345+
typedef enum {
346346
NONE_SLEEP_T = 0,
347347
LIGHT_SLEEP_T,
348348
MODEM_SLEEP_T
349-
};
349+
} sleep_type_t;
350350

351-
bool wifi_set_sleep_type(enum sleep_type type);
352-
enum sleep_type wifi_get_sleep_type(void);
351+
bool wifi_set_sleep_type(sleep_type_t type);
352+
sleep_type_t wifi_get_sleep_type(void);
353353

354354
void wifi_fpm_open(void);
355355
void wifi_fpm_close(void);
356356
void wifi_fpm_do_wakeup(void);
357357
sint8 wifi_fpm_do_sleep(uint32 sleep_time_in_us);
358-
void wifi_fpm_set_sleep_type(enum sleep_type type);
359-
enum sleep_type wifi_fpm_get_sleep_type(void);
358+
void wifi_fpm_set_sleep_type(sleep_type_t type);
359+
sleep_type_t wifi_fpm_get_sleep_type(void);
360360

361361
enum {
362362
EVENT_STAMODE_CONNECTED = 0,

0 commit comments

Comments
 (0)