mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-20 00:32:37 +01:00
Extra power save feature (#1943)
* extra power save feature * update * fix w800 powersave
This commit is contained in:
committed by
GitHub
parent
acf0807423
commit
7fcfe795e4
3
platforms/RTL8710B/tools/.gitignore
vendored
3
platforms/RTL8710B/tools/.gitignore
vendored
@@ -1 +1,2 @@
|
||||
amebaz_ota_combine
|
||||
amebaz_ota_combine
|
||||
amebaz_ug_from_ota
|
||||
|
||||
Submodule sdk/OpenW600 updated: b5d3042cac...e7b2956e23
Submodule sdk/OpenW800 updated: 4f9b8c2b20...027b917ac7
@@ -143,24 +143,13 @@ static commandResult_t CMD_PowerSave(const void* context, const char* cmd, const
|
||||
else {
|
||||
bk_wlan_power_save_set_level(0);
|
||||
}
|
||||
#elif defined(PLATFORM_W600)
|
||||
#elif defined(PLATFORM_W600) || defined(PLATFORM_W800)
|
||||
if (bOn) {
|
||||
tls_wifi_set_psflag(1, 0); //Enable powersave but don't save to flash
|
||||
}
|
||||
else {
|
||||
tls_wifi_set_psflag(0, 0); //Disable powersave but don't save to flash
|
||||
}
|
||||
#elif defined(PLATFORM_W800)
|
||||
if(bOn)
|
||||
{
|
||||
uint8_t enable = 1;
|
||||
tls_param_set(TLS_PARAM_ID_PSM, (void*)&enable, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t enable = 0;
|
||||
tls_param_set(TLS_PARAM_ID_PSM, (void*)&enable, false);
|
||||
}
|
||||
#elif defined(PLATFORM_BL602)
|
||||
if (bOn) {
|
||||
wifi_mgmr_sta_ps_enter(2);
|
||||
@@ -942,6 +931,19 @@ commandResult_t CMD_DeepSleep_SetEdge(const void* context, const char* cmd, cons
|
||||
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
static commandResult_t CMD_PowerSave_WFI(const void* context, const char* cmd, const char* args, int cmdFlags)
|
||||
{
|
||||
int bOn = 1;
|
||||
Tokenizer_TokenizeString(args, 0);
|
||||
|
||||
if(Tokenizer_GetArgsCount() > 0)
|
||||
{
|
||||
bOn = Tokenizer_GetArgInteger(0);
|
||||
}
|
||||
extern bool g_use_wfi;
|
||||
g_use_wfi = (bOn);
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
|
||||
#if MQTT_USE_TLS
|
||||
static commandResult_t CMD_WebServer(const void* context, const char* cmd, const char* args, int cmdFlags) {
|
||||
@@ -1020,6 +1022,11 @@ void CMD_Init_Early() {
|
||||
//cmddetail:"fn":"CMD_PowerSave","file":"cmnds/cmd_main.c","requires":"",
|
||||
//cmddetail:"examples":""}
|
||||
CMD_RegisterCommand("PowerSave", CMD_PowerSave, NULL);
|
||||
//cmddetail:{"name":"PowerSave_WFI","args":"[Optional 1 or 0, by default 1 is assumed]",
|
||||
//cmddetail:"descr":"Extra power save by sleeping during idle. Available on Beken, BL602, XR8xx, Realteks, W600 and W800. Reduces current by 0.001-0.002A on Beken. Enabled by default on BL602/W600/W800 (SDK behaviour).",
|
||||
//cmddetail:"fn":"CMD_PowerSave_WFI","file":"cmnds/cmd_main.c","requires":"",
|
||||
//cmddetail:"examples":""}
|
||||
CMD_RegisterCommand("PowerSave_WFI", CMD_PowerSave_WFI, NULL);
|
||||
//cmddetail:{"name":"if","args":"[Condition]['then'][CommandA]['else'][CommandB]",
|
||||
//cmddetail:"descr":"Executed a conditional. Condition should be single line. You must always use 'then' after condition. 'else' is optional. Use aliases or quotes for commands with spaces",
|
||||
//cmddetail:"fn":"CMD_If","file":"cmnds/cmd_main.c","requires":"",
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "BkDriverWdg.h"
|
||||
|
||||
void bg_register_irda_check_func(FUNCPTR func);
|
||||
extern void WFI(void);
|
||||
#elif PLATFORM_BL602
|
||||
#include <bl_sys.h>
|
||||
#include <hosal_adc.h>
|
||||
@@ -108,6 +109,19 @@ int DRV_SSDP_Active = 0;
|
||||
|
||||
void Main_ForceUnsafeInit();
|
||||
|
||||
#if PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800
|
||||
#define DEF_USE_WFI 1
|
||||
#else
|
||||
#define DEF_USE_WFI 0
|
||||
#endif
|
||||
#if PLATFORM_BEKEN
|
||||
#define WFI_FUNC WFI
|
||||
#elif PLATFORM_BL602 || PLATFORM_REALTEK || PLATFORM_XRADIO || PLATFORM_W600 || PLATFORM_RDA5981
|
||||
#define WFI_FUNC() __asm volatile("wfi")
|
||||
#elif PLATFORM_W800
|
||||
#define WFI_FUNC __WFI
|
||||
#endif
|
||||
bool g_use_wfi = DEF_USE_WFI;
|
||||
|
||||
|
||||
// TEMPORARY
|
||||
@@ -1246,8 +1260,14 @@ int Main_IsConnectedToWiFi()
|
||||
|
||||
// called from idle thread each loop.
|
||||
// - just so we know it is running.
|
||||
#if PLATFORM_ESPIDF || PLATFORM_ESP8266 || PLATFORM_BL602 || (PLATFORM_REALTEK && !PLATFORM_REALTEK_NEW) || PLATFORM_XRADIO
|
||||
inline __attribute__((always_inline))
|
||||
#endif
|
||||
void isidle() {
|
||||
idleCount++;
|
||||
#ifdef WFI_FUNC
|
||||
if(g_use_wfi) WFI_FUNC();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool g_unsafeInitDone = false;
|
||||
@@ -1615,17 +1635,11 @@ void Main_Init()
|
||||
|
||||
}
|
||||
|
||||
#if PLATFORM_ESPIDF || PLATFORM_ESP8266 || PLATFORM_BL602 || (PLATFORM_REALTEK && !PLATFORM_REALTEK_NEW) || PLATFORM_XRADIO
|
||||
#if PLATFORM_ESPIDF || PLATFORM_ESP8266 || PLATFORM_BL602 || (PLATFORM_REALTEK && !PLATFORM_REALTEK_NEW) || PLATFORM_XRADIO || PLATFORM_W600 || PLATFORM_W800
|
||||
|
||||
void vApplicationIdleHook(void)
|
||||
{
|
||||
isidle();
|
||||
#if PLATFORM_BL602
|
||||
// sleep
|
||||
__asm volatile(
|
||||
" wfi "
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user