23 changed files with 361 additions and 123 deletions
-
33README.md
-
1app_protocols/app_protocols.h
-
4app_protocols/bean/hand_acid_remoter_key_event.h
-
2app_protocols/ble_through/ble_proto.h
-
3app_protocols/ble_through/ble_proto_utils.c
-
2uappbase/base.hpp
-
21uappbase/bean/event.hpp
-
2uappbase/service/app_event_bus.cpp
-
2uappbase/service/app_event_bus.hpp
-
37uappbase/service/config_service_utils.cpp
-
7uappbase/service/config_service_utils.hpp
-
40uappbase/service/gstate_mgr.cpp
-
36uappbase/service/gstate_mgr.hpp
-
48usrc/service/app_core.cpp
-
5usrc/service/app_core.hpp
-
34usrc/service/pump_ctrl_service.cpp
-
8usrc/service/pump_ctrl_service.hpp
-
71usrc/service/remote_controler.cpp
-
4usrc/service/remote_controler.hpp
-
30usrc/service/remote_controler_event_processer.cpp
-
20usrc/service/remote_controler_event_processer.hpp
-
49usrc/service/remote_controler_state_sync_service.cpp
-
25usrc/service/remote_controler_state_sync_service.hpp
@ -0,0 +1,37 @@ |
|||
#include "config_service_utils.hpp"
|
|||
namespace iflytop { |
|||
int32_t getMotorULToTruns(int32_t motorid) { |
|||
switch (motorid) { |
|||
case 0: |
|||
return getCfgInt(kcfg_1ulTrunsM0); |
|||
case 1: |
|||
return getCfgInt(kcfg_1ulTrunsM1); |
|||
case 2: |
|||
return getCfgInt(kcfg_1ulTrunsM2); |
|||
case 3: |
|||
return getCfgInt(kcfg_1ulTrunsM3); |
|||
default: |
|||
ZASSERT(0); |
|||
return 0; |
|||
} |
|||
} |
|||
void setMotorULToTruns(int motorid, int32_t val) { |
|||
//
|
|||
switch (motorid) { |
|||
case 0: |
|||
CS->setcfg(kcfg_1ulTrunsM0, val); |
|||
break; |
|||
case 1: |
|||
CS->setcfg(kcfg_1ulTrunsM1, val); |
|||
break; |
|||
case 2: |
|||
CS->setcfg(kcfg_1ulTrunsM2, val); |
|||
break; |
|||
case 3: |
|||
CS->setcfg(kcfg_1ulTrunsM3, val); |
|||
break; |
|||
default: |
|||
ZASSERT(0); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
#pragma once
|
|||
#include "config_service.hpp"
|
|||
namespace iflytop { |
|||
int32_t getMotorULToTruns(int32_t motorid); |
|||
void setMotorULToTruns(int32_t motorid, int32_t val); |
|||
|
|||
} // namespace iflytop
|
@ -0,0 +1,40 @@ |
|||
#include "gstate_mgr.hpp"
|
|||
|
|||
#include "app_event_bus.hpp"
|
|||
|
|||
using namespace std; |
|||
using namespace iflytop; |
|||
#define GSM GStateMgr::ins()
|
|||
|
|||
void GStateMgr::setLogin(bool isAdmin, const char* loginUsr) { |
|||
m_isLogin = true; |
|||
m_isAdmin = isAdmin; |
|||
if (loginUsr) { |
|||
strncpy(this->m_loginUsr, loginUsr, MAX_USR_NAME_SIZE); |
|||
} |
|||
} |
|||
void GStateMgr::setUnLogin() { |
|||
m_isLogin = false; |
|||
m_isAdmin = false; |
|||
memset(m_loginUsr, 0, MAX_USR_NAME_SIZE + 1); |
|||
} |
|||
|
|||
bool GStateMgr::isLogin() { return m_isLogin; } |
|||
bool GStateMgr::isAdmin() { return m_isAdmin; } |
|||
const char* GStateMgr::getLoginUsr() { return m_loginUsr; } |
|||
|
|||
void GStateMgr::setAcidState(int32_t state) { m_AcidState = state; } |
|||
void GStateMgr::setRemoterS(int32_t state) { m_RemoterS = state; } |
|||
void GStateMgr::setRunMode(hand_acid_mode_t mode) { |
|||
if (m_RunMode != mode) { |
|||
m_RunMode = mode; |
|||
AppEventBus::ins()->pushEvent(createAppEvent(kAppEvent_RunModeChangeEvent)); |
|||
} |
|||
} |
|||
|
|||
int32_t GStateMgr::getAcidState() { return m_AcidState; } |
|||
int32_t GStateMgr::getRemoterS() { return m_RemoterS; } |
|||
hand_acid_mode_t GStateMgr::getRunMode() { return m_RunMode; } |
|||
|
|||
void GStateMgr::setPumpSelectState(int32_t index, bool state) { pumpSelectState[index] = state; } |
|||
bool GStateMgr::getPumpSelectState(int32_t index) { return pumpSelectState[index]; } |
@ -1,30 +0,0 @@ |
|||
#include "remote_controler_event_processer.hpp"
|
|||
#include "remote_controler.hpp"
|
|||
using namespace iflytop; |
|||
void RemoterControlerEventProcesser::initialize() { |
|||
//
|
|||
RemoteControlerUpper::ins()->regOnReport([this](uint8_t* rx, int32_t len) { //
|
|||
onPacket((zble_proto_packet_t*)rx); |
|||
}); |
|||
} |
|||
|
|||
void RemoterControlerEventProcesser::onPacket(zble_proto_packet_t* packet) { |
|||
// kproto_report_key_event
|
|||
// kproto_report_connected_event
|
|||
|
|||
// if (packet->cmd == kproto_report_connected_event) {
|
|||
// static AppEvent_t event;
|
|||
// if (packet->data.connected_event.connected) {
|
|||
// /**
|
|||
// * @brief ͬ²½×´Ì¬µ½±Ê¶Ë
|
|||
// */
|
|||
|
|||
// event.type = kAppEvent_RemoterControlerConnected;
|
|||
// AppEventBus::ins()->pushEvent(event);
|
|||
|
|||
// } else {
|
|||
// event.type = kAppEvent_RemoterControlerDisConnected;
|
|||
// AppEventBus::ins()->pushEvent(event);
|
|||
// }
|
|||
// }
|
|||
} |
@ -1,20 +0,0 @@ |
|||
#pragma once
|
|||
#include "apphardware/apphardware.hpp"
|
|||
#include "uappbase/base.hpp"
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
|
|||
class RemoterControlerEventProcesser { |
|||
public: |
|||
static RemoterControlerEventProcesser* ins() { |
|||
static RemoterControlerEventProcesser instance; |
|||
return &instance; |
|||
} |
|||
|
|||
void initialize(); |
|||
|
|||
private: |
|||
void onPacket(zble_proto_packet_t* packet); |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -0,0 +1,49 @@ |
|||
#include "remote_controler_state_sync_service.hpp"
|
|||
|
|||
#include "pump_ctrl_service.hpp"
|
|||
#include "remote_controler.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
|
|||
void RemoteControlerStateSyncService::initialize() { |
|||
AppEventBus::ins()->regOnEvent([this](AppEvent_t* event) { |
|||
if (event->type == kAppEvent_BleConnectedStateChangeEvent) { |
|||
zlock_guard lck(m_forceUpdateflagLock); |
|||
m_forceUpdateflag = true; |
|||
} |
|||
}); |
|||
|
|||
bleStateUpdateThread.init("bleStateUpdateThread"); |
|||
} |
|||
|
|||
void RemoteControlerStateSyncService::startSync() { |
|||
bleStateUpdateThread.start([this]() { |
|||
//
|
|||
hand_acid_mode_t runmode = khand_acid_m_unset_mode; |
|||
bool workState = false; |
|||
bool forceupdate = false; |
|||
|
|||
while (true) { |
|||
if (!RCTRL->isConnected()) { |
|||
osDelay(100); |
|||
continue; |
|||
} |
|||
|
|||
{ |
|||
zlock_guard lck(m_forceUpdateflagLock); |
|||
forceupdate = m_forceUpdateflag; |
|||
m_forceUpdateflag = false; |
|||
} |
|||
|
|||
if (runmode != GSM->getRunMode() || workState != PUMPCS->isWorking()) { |
|||
runmode = GSM->getRunMode(); |
|||
workState = PUMPCS->isWorking(); |
|||
RCTRL->setRemoterState(runmode, workState); |
|||
} else if (forceupdate) { |
|||
RCTRL->setRemoterState(runmode, workState); |
|||
} |
|||
|
|||
osDelay(500); |
|||
} |
|||
}); |
|||
} |
@ -0,0 +1,25 @@ |
|||
#pragma once
|
|||
|
|||
#include "apphardware/apphardware.hpp"
|
|||
#include "uappbase/base.hpp"
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
class RemoteControlerStateSyncService { |
|||
private: |
|||
/* data */ |
|||
ZThread bleStateUpdateThread; |
|||
bool m_forceUpdateflag = false; |
|||
zmutex m_forceUpdateflagLock; |
|||
|
|||
public: |
|||
static RemoteControlerStateSyncService* ins() { |
|||
static RemoteControlerStateSyncService instance; |
|||
return &instance; |
|||
} |
|||
|
|||
void initialize(); |
|||
void startSync(); |
|||
|
|||
public: |
|||
}; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue