|
@@ -25,13 +25,23 @@ static bool isNursing = false; // 用于启动时判断是否处于护理状态
|
|
|
static bool isNetreset = false;
|
|
|
static int netresetInt = 0;
|
|
|
static string callTid = "";
|
|
|
+
|
|
|
+
|
|
|
+static bool isConnectHandle = false;
|
|
|
+static bool isConnectSos = false;
|
|
|
+static bool isTriggerHandle = false;
|
|
|
+static bool isTriggerSos = false;
|
|
|
+
|
|
|
#define FUNCTION_TIMER_HANDLE 3 // 增援的定时器id
|
|
|
#define SOS_CLICK_TIME_HANDLE 4 // sos的定时器id
|
|
|
#define SOS_LAMP_TIME_HANDLE 5 // sos的门灯定时器id
|
|
|
#define EVENT_TIME_HANDLE 8 // 事件定时器
|
|
|
#define SLEEP_STRAT_TIME_HANDLE 9 // 息屏
|
|
|
#define SYS_RESTART_TIME_HANDLE 10 // 重启
|
|
|
-#define PROMPT_TIME_HANDLE 11 // 提示语
|
|
|
+#define PROMPT_TIME_HANDLE 11 // 提示语s
|
|
|
+
|
|
|
+#define HANDLE_TRIGGER_TIME_HANDLE 15
|
|
|
+#define SOS_TRIGGER_TIME_HANDLE 16
|
|
|
|
|
|
#define HTTP_SERVER_PORT 80
|
|
|
|
|
@@ -534,7 +544,7 @@ void setSleepTimerRegistered(bool result) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void scrrenOn() {
|
|
|
+void screenOn() {
|
|
|
isSleep = false;
|
|
|
BRIGHTNESSHELPER->screenOn();
|
|
|
}
|
|
@@ -543,6 +553,25 @@ void setCallTid(std::string tid) {
|
|
|
callTid = tid;
|
|
|
}
|
|
|
|
|
|
+void sosCall(string sosMsg) {
|
|
|
+ if (sosTimerRegistered) {
|
|
|
+ LOGD("TCP -> SOS_CALL");
|
|
|
+ sendSosCall(sosMsg);
|
|
|
+
|
|
|
+
|
|
|
+ // SOS亮红灯
|
|
|
+ lightControl("ULED", "1F");
|
|
|
+ // 门灯亮红灯
|
|
|
+ lightControl("DOORLED", "200F");
|
|
|
+
|
|
|
+ lightControl("CALLLED", "100F");
|
|
|
+
|
|
|
+ sosTimerRegistered = false;
|
|
|
+ mActivityPtr->registerUserTimer(SOS_CLICK_TIME_HANDLE, 10000); // 10秒后才能触发
|
|
|
+ mActivityPtr->registerUserTimer(SOS_LAMP_TIME_HANDLE, 120000); // 2分钟后才能触发
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//================================= IO 口操作
|
|
|
//紧急按钮灯,明/灭
|
|
|
void setSOS_A5(bool light){
|
|
@@ -774,33 +803,22 @@ static void onProtocolDataUpdate(const SProtocolData &data) {
|
|
|
if(UartContext::Uart3IsOpen()) { // 如果是true,表示串口打开了
|
|
|
string heartStr;
|
|
|
|
|
|
- //按下
|
|
|
- if (data.state=="0"){ // 0表示正被按下,1表示短按松开,2表示长按松开。
|
|
|
- if (data.cmd == "KEY5") { // key5是面板拨号按钮
|
|
|
- if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP") {
|
|
|
- setCheckbox("KEY5");
|
|
|
- return;
|
|
|
+ if (data.cmd == "KEY5") { // key5是面板拨号按钮
|
|
|
+ if (data.state == "0") {
|
|
|
+ if (isSleep) {
|
|
|
+ screenOn();
|
|
|
+ if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
|
|
|
- if (isSleep) {
|
|
|
- scrrenOn();
|
|
|
- }
|
|
|
- else {
|
|
|
- voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
- //拨打 或 挂断
|
|
|
- if (CallingStatus::instance()->busy()){
|
|
|
- callActivityFinish(CallFinishType::A1CLICK);
|
|
|
- } else {
|
|
|
- Intent* intent = new Intent();
|
|
|
- intent->putExtra(isOutgoing, "true");
|
|
|
- intent->putExtra(audioOnly, "true");
|
|
|
- EASYUICONTEXT->openActivity("callActivity", intent);
|
|
|
- }
|
|
|
- }
|
|
|
+ const char* currentAppName = EASYUICONTEXT->currentAppName();
|
|
|
+ string _currentAppName = currentAppName;
|
|
|
+ if (_currentAppName == "sipTestActivity") {
|
|
|
+ setCheckbox("KEY5");
|
|
|
+ return;
|
|
|
}
|
|
|
else {
|
|
|
- scrrenOn();
|
|
|
voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
//拨打 或 挂断
|
|
|
if (CallingStatus::instance()->busy()){
|
|
@@ -813,28 +831,29 @@ static void onProtocolDataUpdate(const SProtocolData &data) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- else if (data.cmd == "KEY6"){ // key6是手柄触发,手柄只有呼叫和挂断功能,没有取消功能,防止用户不停地按
|
|
|
-
|
|
|
- if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
|
|
|
- if (isSleep) {
|
|
|
- scrrenOn();
|
|
|
- }
|
|
|
- else {
|
|
|
- voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
- //拨打 或 挂断
|
|
|
- if (CallingStatus::instance()->busy()){
|
|
|
- callActivityFinish(CallFinishType::KEY6_CLICK);
|
|
|
- } else {
|
|
|
- Intent* intent = new Intent();
|
|
|
- intent->putExtra(isOutgoing, "true");
|
|
|
- intent->putExtra(audioOnly, "true");
|
|
|
- EASYUICONTEXT->openActivity("callActivity", intent);
|
|
|
- }
|
|
|
+ else if (data.cmd == "KEY6"){ // key6是手柄触发,手柄只有呼叫和挂断功能,没有取消功能,防止用户不停地按
|
|
|
+ if (data.state == "0") {
|
|
|
+ if (isSleep) {
|
|
|
+ screenOn();
|
|
|
+ if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
- scrrenOn();
|
|
|
+
|
|
|
+ const char* currentAppName = EASYUICONTEXT->currentAppName();
|
|
|
+ string _currentAppName = currentAppName;
|
|
|
+ if (_currentAppName == "sipTestActivity") {
|
|
|
+ setCheckbox("KEY6");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ isTriggerHandle = true;
|
|
|
+ mActivityPtr->registerUserTimer(HANDLE_TRIGGER_TIME_HANDLE, 5 * 1000);
|
|
|
+ }
|
|
|
+ else if (data.state == "1") {
|
|
|
+ if (isTriggerHandle) {
|
|
|
voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
//拨打 或 挂断
|
|
|
if (CallingStatus::instance()->busy()){
|
|
@@ -846,63 +865,67 @@ static void onProtocolDataUpdate(const SProtocolData &data) {
|
|
|
EASYUICONTEXT->openActivity("callActivity", intent);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- else if (data.cmd == "KEY7"){ // key7是紧急按钮
|
|
|
- if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP") {
|
|
|
- setCheckbox("KEY7");
|
|
|
+ else if (data.state == "3") {
|
|
|
+ LOGD("手柄在线");
|
|
|
+ isConnectHandle = true;
|
|
|
+ }
|
|
|
+ else if (data.state == "4") {
|
|
|
+ if (!isConnectHandle) {
|
|
|
return;
|
|
|
}
|
|
|
- if (isSleep) {
|
|
|
- scrrenOn();
|
|
|
+ sosCall(LANGUAGEMANAGER->getValue("HandleDisconnected"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (data.cmd == "KEY7"){ // key7是紧急按钮
|
|
|
+ if (data.state == "0") {
|
|
|
+ screenOn();
|
|
|
+
|
|
|
+ const char* currentAppName = EASYUICONTEXT->currentAppName();
|
|
|
+ string _currentAppName = currentAppName;
|
|
|
+ if (_currentAppName == "sipTestActivity") {
|
|
|
+ setCheckbox("KEY7");
|
|
|
+ return;
|
|
|
}
|
|
|
- if (sosTimerRegistered) {
|
|
|
- LOGD("TCP -> SOS_CALL");
|
|
|
- TcpModel tcpModel;
|
|
|
- tcpModel.type = TcpType::SOS;
|
|
|
- tcpModel.action = SosAction::CALL;
|
|
|
- tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID, 0);
|
|
|
- tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
|
|
|
- std::string req = getTcpModelString(tcpModel);
|
|
|
- LOGD("TCP SOS_CALL : %s",req.c_str());
|
|
|
- TcpClient::instance()->sendMsg(req.c_str());
|
|
|
-
|
|
|
- // SOS亮红灯
|
|
|
- lightControl("ULED", "1F");
|
|
|
- // 门灯亮红灯
|
|
|
- lightControl("DOORLED", "200F");
|
|
|
-
|
|
|
- lightControl("CALLLED", "100F");
|
|
|
-
|
|
|
- mActivityPtr->registerUserTimer(SOS_CLICK_TIME_HANDLE, 10000); // 10秒后才能触发
|
|
|
- mActivityPtr->registerUserTimer(SOS_LAMP_TIME_HANDLE, 120000); // 2分钟后才能触发
|
|
|
+ else {
|
|
|
+ if (sosTimerRegistered) {
|
|
|
+ isTriggerSos = true;
|
|
|
+ mActivityPtr->registerUserTimer(SOS_TRIGGER_TIME_HANDLE, 5 * 1000);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- else if (data.cmd == "KEY<") { //下左3,红
|
|
|
- if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP") {
|
|
|
- setCheckbox("KEY<");
|
|
|
+ else if (data.state == "1") {
|
|
|
+ sosCall("");
|
|
|
+ }
|
|
|
+ else if (data.state == "3") {
|
|
|
+ LOGD("紧急按钮在线");
|
|
|
+ isConnectHandle = true;
|
|
|
+ }
|
|
|
+ else if (data.state == "4") {
|
|
|
+ if (!isConnectHandle) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
|
|
|
- if (isSleep) {
|
|
|
- scrrenOn();
|
|
|
- }
|
|
|
- else {
|
|
|
- voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
- //拨打 或 挂断
|
|
|
- if (CallingStatus::instance()->busy()){
|
|
|
- callActivityFinish(CallFinishType::A1CLICK);
|
|
|
- } else {
|
|
|
- Intent* intent = new Intent();
|
|
|
- intent->putExtra(isOutgoing, "true");
|
|
|
- intent->putExtra(audioOnly, "true");
|
|
|
- EASYUICONTEXT->openActivity("callActivity", intent);
|
|
|
- }
|
|
|
+ sosCall(LANGUAGEMANAGER->getValue("SosDisconnected"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (data.cmd == "KEY<") { //下左3,红
|
|
|
+ if (data.state == "0") {
|
|
|
+ if (isSleep) {
|
|
|
+ screenOn();
|
|
|
+ if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ const char* currentAppName = EASYUICONTEXT->currentAppName();
|
|
|
+ string _currentAppName = currentAppName;
|
|
|
+ if (_currentAppName == "sipTestActivity") {
|
|
|
+ setCheckbox("KEY<");
|
|
|
+ return;
|
|
|
+ }
|
|
|
else {
|
|
|
- scrrenOn();
|
|
|
voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
//拨打 或 挂断
|
|
|
if (CallingStatus::instance()->busy()){
|
|
@@ -915,23 +938,22 @@ static void onProtocolDataUpdate(const SProtocolData &data) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (data.cmd == "KEY>") { // key>是面板挂断按钮
|
|
|
- if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
|
|
|
- if (isSleep) {
|
|
|
- scrrenOn();
|
|
|
- }
|
|
|
- else {
|
|
|
- voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
- //拨打 或 挂断
|
|
|
- if (CallingStatus::instance()->busy()){
|
|
|
- callActivityFinish(CallFinishType::A1CLICK);
|
|
|
-
|
|
|
- lightControl("DOORLED", "000F");
|
|
|
- }
|
|
|
+ }
|
|
|
+ else if (data.cmd == "KEY>") { // key>是面板挂断按钮
|
|
|
+ if (data.state == "0") {
|
|
|
+ if (isSleep) {
|
|
|
+ screenOn();
|
|
|
+ if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
+ const char* currentAppName = EASYUICONTEXT->currentAppName();
|
|
|
+ string _currentAppName = currentAppName;
|
|
|
+ if (_currentAppName == "sipTestActivity") {
|
|
|
+ setCheckbox("KEY>");
|
|
|
+ return;
|
|
|
+ }
|
|
|
else {
|
|
|
- scrrenOn();
|
|
|
voip::CallInfo info = GetTelephone()->GetCallInfo();
|
|
|
//拨打 或 挂断
|
|
|
if (CallingStatus::instance()->busy()){
|
|
@@ -941,18 +963,19 @@ static void onProtocolDataUpdate(const SProtocolData &data) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (data.cmd == "KEY;"){ //下左4,白
|
|
|
- if (isSleep) {
|
|
|
- scrrenOn();
|
|
|
- }
|
|
|
- lightControl("DOORLED", "111F");
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (data.cmd == "KEY;"){ //下左4,白
|
|
|
+ if (isSleep) {
|
|
|
+ screenOn();
|
|
|
}
|
|
|
- else {
|
|
|
- if (isSleep) {
|
|
|
- scrrenOn();
|
|
|
- }
|
|
|
-// lightControl("DOORLED", "000F");
|
|
|
+ lightControl("DOORLED", "111F");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (isSleep) {
|
|
|
+ screenOn();
|
|
|
}
|
|
|
+// lightControl("DOORLED", "000F");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1017,7 +1040,7 @@ static bool onUI_Timer(int id){
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case SYS_RESTART_TIME_HANDLE:
|
|
|
+ case SYS_RESTART_TIME_HANDLE: {
|
|
|
netresetInt += 1;
|
|
|
lightControl("NETRESET", "1F");
|
|
|
|
|
@@ -1027,7 +1050,17 @@ static bool onUI_Timer(int id){
|
|
|
sync();
|
|
|
reboot(RB_AUTOBOOT);
|
|
|
}
|
|
|
+ }
|
|
|
break;
|
|
|
+ case HANDLE_TRIGGER_TIME_HANDLE: {
|
|
|
+ isTriggerHandle = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SOS_TRIGGER_TIME_HANDLE: {
|
|
|
+ isTriggerSos = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
default:
|
|
|
break;
|
|
|
}
|