mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-20 00:32:37 +01:00
fix flags error?
This commit is contained in:
@@ -248,27 +248,22 @@ static commandResult_t CMD_SetFlag(const void* context, const char* cmd, const c
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
static commandResult_t CMD_Flags(const void* context, const char* cmd, const char* args, int cmdFlags) {
|
||||
union {
|
||||
long long newValue;
|
||||
struct {
|
||||
int ints[2];
|
||||
int dummy[2]; // just to be safe
|
||||
};
|
||||
} u;
|
||||
long long newValue;
|
||||
// TODO: check on other platforms, on Beken it's 8, 64 bit
|
||||
// On Windows simulator it's 8 as well
|
||||
//ADDLOG_INFO(LOG_FEATURE_CMD, "CMD_Flags: sizeof(newValue) = %i", sizeof(u.newValue));
|
||||
if (args && *args) {
|
||||
if (1 != sscanf(args, "%lld", &u.newValue)) {
|
||||
if (1 != sscanf(args, "%llu", &newValue)) {
|
||||
//ADDLOG_INFO(LOG_FEATURE_CMD, "Argument/sscanf error!");
|
||||
return CMD_RES_BAD_ARGUMENT;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ADDLOG_INFO(LOG_FEATURE_CMD, "Flags are %llu",&g_cfg.genericFlags);
|
||||
return CMD_RES_NOT_ENOUGH_ARGUMENTS;
|
||||
}
|
||||
|
||||
CFG_SetFlags(u.ints[0], u.ints[1]);
|
||||
int *ints = (int)&newValue;
|
||||
CFG_SetFlags(ints[0], ints[1]);
|
||||
ADDLOG_INFO(LOG_FEATURE_CMD, "New flags set!");
|
||||
|
||||
return CMD_RES_OK;
|
||||
|
||||
@@ -563,8 +563,8 @@ bool CFG_HasLoggerFlag(int flag) {
|
||||
int CFG_GetFlags() {
|
||||
return g_cfg.genericFlags;
|
||||
}
|
||||
unsigned long CFG_GetFlags64() {
|
||||
unsigned long* pAllGenericFlags = (unsigned long*)&g_cfg.genericFlags;
|
||||
unsigned long long CFG_GetFlags64() {
|
||||
unsigned long long* pAllGenericFlags = (unsigned long long*)&g_cfg.genericFlags;
|
||||
return *pAllGenericFlags;
|
||||
}
|
||||
bool CFG_HasFlag(int flag) {
|
||||
|
||||
@@ -76,7 +76,7 @@ void CFG_SetLoggerFlag(int flag, bool bValue);
|
||||
bool CFG_HasLoggerFlag(int flag);
|
||||
void CFG_SetMac(char *mac);
|
||||
int CFG_GetFlags();
|
||||
unsigned long CFG_GetFlags64();
|
||||
unsigned long long CFG_GetFlags64();
|
||||
const char* CFG_GetNTPServer();
|
||||
void CFG_SetNTPServer(const char *s);
|
||||
// BL0937, BL0942, etc constants
|
||||
|
||||
@@ -191,8 +191,13 @@ void Test_Commands_Generic() {
|
||||
CMD_ExecuteCommand("Flags 444", 0);
|
||||
SELFTEST_ASSERT(CFG_GetFlags() == 444);
|
||||
SELFTEST_ASSERT(CFG_GetFlags64() == 444);
|
||||
//CMD_ExecuteCommand("Flags 8589934592", 0);
|
||||
//SELFTEST_ASSERT(CFG_GetFlags64() == 8589934592);
|
||||
CMD_ExecuteCommand("Flags 8589934592", 0);
|
||||
SELFTEST_ASSERT(CFG_GetFlags64() == 8589934592);
|
||||
CMD_ExecuteCommand("Flags 8589934594", 0);
|
||||
SELFTEST_ASSERT(CFG_GetFlags64() == 8589934594);
|
||||
CMD_ExecuteCommand("Flags 8589934593", 0);
|
||||
SELFTEST_ASSERT(CFG_GetFlags64() == 8589934593);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ void SIM_ClearOBK(const char *flashPath) {
|
||||
Main_Init();
|
||||
}
|
||||
void Win_DoUnitTests() {
|
||||
Test_Commands_Generic();
|
||||
Test_TuyaMCU_Boolean();
|
||||
Test_TuyaMCU_DP22();
|
||||
|
||||
@@ -166,7 +167,6 @@ void Win_DoUnitTests() {
|
||||
Test_Demo_ButtonScrollingChannelValues();
|
||||
Test_CFG_Via_HTTP();
|
||||
Test_Commands_Calendar();
|
||||
Test_Commands_Generic();
|
||||
Test_Demo_SimpleShuttersScript();
|
||||
Test_Role_ToggleAll();
|
||||
Test_Demo_FanCyclingRelays();
|
||||
|
||||
Reference in New Issue
Block a user