瀏覽代碼

增加sos报警提示,增加sos cancel逻辑,修改离线判断逻辑

vothin 5 月之前
父節點
當前提交
31caec5d9a
共有 40 個文件被更改,包括 1001 次插入516 次删除
  1. 1 0
      i18n/en_US.tr
  2. 1 0
      i18n/es_ES-西班牙语.tr
  3. 1 0
      i18n/zh_CN.tr
  4. 20 1
      jni/logic/functionLogic.cc
  5. 417 325
      jni/logic/mainLogic.cc
  6. 496 182
      jni/logic/startLogic.cc
  7. 15 5
      jni/logic/statusbar.cc
  8. 26 0
      jni/net/tcp_client.cpp
  9. 1 0
      jni/net/tcp_client.h
  10. 1 1
      jni/net/tcp_model.cpp
  11. 1 0
      jni/net/tcp_model.h
  12. 12 0
      jni/net/tcp_util.cpp
  13. 2 0
      jni/net/tcp_util.h
  14. 4 2
      jni/service/BusinessConfig.h
  15. 3 0
      jni/uart/ProtocolSender.cpp
  16. 二進制
      libs/armeabi/libzkgui.so
  17. 二進制
      obj/activity/callActivity.o
  18. 二進制
      obj/activity/deviceInfoActivity.o
  19. 二進制
      obj/activity/functionActivity.o
  20. 二進制
      obj/activity/mainActivity.o
  21. 二進制
      obj/activity/medicalCareActivity.o
  22. 二進制
      obj/activity/moreActivity.o
  23. 二進制
      obj/activity/navibar.o
  24. 二進制
      obj/activity/promptActivity.o
  25. 二進制
      obj/activity/settingActivity.o
  26. 二進制
      obj/activity/sipTestActivity.o
  27. 二進制
      obj/activity/startActivity.o
  28. 二進制
      obj/activity/statusbar.o
  29. 二進制
      obj/activity/updateActivity.o
  30. 二進制
      obj/core/update_assistant.o
  31. 二進制
      obj/net/tcp_client.o
  32. 二進制
      obj/net/tcp_model.o
  33. 二進制
      obj/net/tcp_util.o
  34. 二進制
      obj/server/http_server.o
  35. 二進制
      obj/service/BusinessConfig.o
  36. 二進制
      obj/service/time.o
  37. 二進制
      obj/uart/ProtocolSender.o
  38. 二進制
      obj/uart/UartContext.o
  39. 二進制
      resources/icon/sos.png
  40. 二進制
      resources/sos4.MP3

+ 1 - 0
i18n/en_US.tr

@@ -99,6 +99,7 @@
     <string name="HandleDisconnected">Handle Disconnected</string>
     <string name="GainCall">Extension calling, click to answer</string>
     <string name="InitiateCall">Start Call</string>
+    <string name="SosCalling">The alarm has been triggered.</string>
     <!-- 医护界面 -->
     <string name="MedicalLoginMsg">Please enter the correct password to access healthcare functions</string>
     <string name="InputMedicalPassword">Enter Password to Access Healthcare</string>

+ 1 - 0
i18n/es_ES-西班牙语.tr

@@ -99,6 +99,7 @@
 	<string name="HandleDisconnected">Mando desconectado</string>
 	<string name="GainCall">Llamada de extensión, clic para responder</string>
 	<string name="InitiateCall">Iniciar Llamada</string>
+    <string name="SosCalling">La alarma ha sido activada.</string>
     <!-- 医护界面 -->
 	<string name="MedicalLoginMsg">Por favor, introduzca la contraseña correcta para acceder a las funciones de atención médica</string>
 	<string name="InputMedicalPassword">Introducir contraseña para acceder a la atención médica</string>

+ 1 - 0
i18n/zh_CN.tr

@@ -99,6 +99,7 @@
     <string name="HandleDisconnected">手柄已断连</string>
     <string name="GainCall">分机正在呼叫,可以点击接听按钮进行接听</string>
     <string name="InitiateCall">发起呼叫</string>
+    <string name="SosCalling">报警已发出</string>
     <!-- 医护界面 -->
     <string name="MedicalLoginMsg">请输入正确的密码,进入医护功能</string>
     <string name="InputMedicalPassword">输入密码进入医护</string>

+ 20 - 1
jni/logic/functionLogic.cc

@@ -306,6 +306,21 @@ void setLanguage(string functionText) {
 }
 
 
+void functionSosCall() {
+	mIconPainterPtr->setBackgroundPic("icon/sos.png");
+	mFunctionTextViewPtr->setText(LANGUAGEMANAGER->getValue("SosCalling"));
+	mStateTextViewPtr->setVisible(false);
+	mFunctionButtonPtr->setVisible(true);
+	mFunctionButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "button/elliptic_red.png");
+	mFunctionWindowPtr->showWnd();
+
+	mediaPlayer.Play(CONFIGMANAGER->getResFilePath("sos4.MP3"), "", 1000,
+	        base::MediaPlayer::PlayMode::Default);
+
+	mActivityPtr->registerUserTimer(FUNCTION_TIMER_HANDLE, 8 * 1000);
+}
+
+
 void addGainCallData(Json::Value data) {
 	gainCallDataList.append(data);
 	if (mActivityPtr != NULL) {
@@ -432,6 +447,9 @@ static void onUI_intent(const Intent *intentPtr) {
 		else if (_functionWindows == "gainCall") {
 			mGainCallWindowPtr->showWnd();
 		}
+		else if (_functionWindows == "sosCall") {
+			functionSosCall();
+		}
 		else {
 			_warnText = LANGUAGEMANAGER->getValue("NotActivity");
 			warn(_warnText);
@@ -612,7 +630,8 @@ static bool onButtonClick_FunctionButton(ZKButton *pButton) {
     if (_functionWindows == "help" ||
     		_functionWindows == "helpResonse" ||
 			_functionWindows == "position" ||
-			_functionWindows == "roomPatrol"
+			_functionWindows == "roomPatrol" ||
+			_functionWindows == "sosCall"
 			) {
     	mActivityPtr->unregisterUserTimer(FUNCTION_TIMER_HANDLE);
     	EASYUICONTEXT->closeActivity("functionActivity");

+ 417 - 325
jni/logic/mainLogic.cc

@@ -108,372 +108,466 @@ void setMainMode() {
 	}
 }
 
-static void getServerInfo(){
-
-	string url = getHttpGateway() + "/ncs_url/server_info";
-	LOGD("请求服务器信息. url = %s", url.c_str());
-	//发起HTTP GET请求
-	RestClient::Response r = RestClient::get(url);
-	//解析json
-	Json::Reader reader;
-	Json::Value root;
-	if (reader.parse(r.body, root, false)){
-		// http
-		StoragePreferences::putString(STORE_GATEWAY, root["http_local_ip"].asString());
-		StoragePreferences::putInt(STORE_HTTP_PORT, root["http_port"].asInt());
-
-		// tcp
-		StoragePreferences::putString(STORE_TCP_LOCAL_IP, root["tcp_local_ip"].asString());
-		StoragePreferences::putInt(STORE_TCP_PORT, root["tcp_port"].asInt());
-
-		// sip
-		StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());
-		StoragePreferences::putInt(SIP_REG_PORT, root["sip_port"].asInt());
-
-		serverInfo = false;	// 只有请求成功了,才不需要重复请求
+static net::Conn* udpConn;
+class UdpThread: public Thread {
+public:
+	static void getServerInfo(){
+
+		string url = getHttpGateway() + "/ncs_url/server_info";
+		LOGD("请求服务器信息. url = %s", url.c_str());
+		//发起HTTP GET请求
+		RestClient::Response r = RestClient::get(url);
+		//解析json
+		Json::Reader reader;
+		Json::Value root;
+		if (reader.parse(r.body, root, false)){
+			// http
+			StoragePreferences::putString(STORE_GATEWAY, root["http_local_ip"].asString());
+			StoragePreferences::putInt(STORE_HTTP_PORT, root["http_port"].asInt());
+
+			// tcp
+			StoragePreferences::putString(STORE_TCP_LOCAL_IP, root["tcp_local_ip"].asString());
+			StoragePreferences::putInt(STORE_TCP_PORT, root["tcp_port"].asInt());
+
+			// sip
+			StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());
+			StoragePreferences::putInt(SIP_REG_PORT, root["sip_port"].asInt());
+
+			serverInfo = false;	// 只有请求成功了,才不需要重复请求
+		}
 	}
-}
 
-// 读取空间缓存的数据
-static void getFrameInfo() {
-	mRoomNameTextViewPtr->setText(frameInfo["full_name"].asString());
-}
+	static void getDeviceInfo(){
+		if (dataInit){
+			getFrameInfo();
+			getBedCount();
+			setDirectorAndHeadNurse();
+			return;
+		}
+        if (!isConnectServer()) {
+            return;
+        }
+
+		string url = getHttpGateway() + "/deviceRoom/get_device_by_eth_mac/" + StoragePreferences::getString(STORE_MAC_ADDR, "0.0.0.0");
+		LOGD("请求设备信息. url = %s", url.c_str());
+		//发起HTTP GET请求
+		RestClient::Response r = RestClient::get(url);
+		LOGD("获得设备信息. result = %s", r.body.c_str());
+		//解析json
+		Json::Reader reader;
+		Json::Value root;
+		if (reader.parse(r.body, root, false)){
+			string partName = root["part_display"].asString();
+			StoragePreferences::putString(STORE_PARTNAME,partName);
+			NavibarSetPartName(partName);
+			//设备
+			StoragePreferences::putInt(STORE_DEVICE_ID, root["id"].asInt());
+			StoragePreferences::putInt(STORE_DEVICE_TYPE, root["device_type"].asInt());
+
+			//SIP存储
+	//			StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());	// 应该去找配置文件里的sip-ip
+			StoragePreferences::putString(SIP_REG_ACCOUNT,root["sip_id"].asString());
+			StoragePreferences::putString(SIP_REG_PASSWORD, root["sip_password"].asString());
+
+			frameInfo["frame_id"] = root["frame_id"].asInt();
+			frameInfo["full_name"] = root["full_name"].asString();
+			frameInfo["part_id"] = root["part_id"].asInt();
+			getFrameInfo();
+
+			//获取科室设置
+			string partId = root["part_id"].asString();
+			StoragePreferences::putString(STORE_PARTID, partId);
+			getPartSetting(partId);
+			getVersion();
+			getNfcInteraction();
+		}
+	}
 
-static void getBedCount() {
-	if (mActivityPtr == NULL) {
-		return;
+
+	// 读取空间缓存的数据
+	static void getFrameInfo() {
+		mRoomNameTextViewPtr->setText(frameInfo["full_name"].asString());
 	}
-	mInBedNumTextViewPtr->setText(inBedCount);
-	mEmptyBedNumTextViewPtr->setText(emptyBedCount);
-}
 
-static void getFrameRoom(int frame_id) {
-	string url = getHttpGateway() + "/deviceRoom/get_frame_room/" + to_string(frame_id);
-	LOGD("请求房间信息. url = %s", url.c_str());
-	//发起HTTP GET请求
-	RestClient::Response r = RestClient::get(url);
-	LOGD("获得房间信息. result = %s", r.body.c_str());
-	//解析json
-	Json::Reader reader;
-	Json::Value root;
-	if (reader.parse(r.body, root, false)){
-		frameRoom = root;
-		frameBedList = root["frame_bed_list"];
-
-		inBedCount = 0;
-		emptyBedCount = 0;
-		if (frameBedList.size() > 0) {
-			for (int i = 0; i < frameBedList.size(); i++) {
-				string customerId = frameBedList[i]["customer_id"].asString();
-				if (customerId != "") {
-					inBedCount += 1;
-				}
-			}
-			emptyBedCount = frameBedList.size() - inBedCount;
-			getBedCount();
+	static void getBedCount() {
+		if (mActivityPtr == NULL) {
+			return;
 		}
+		mInBedNumTextViewPtr->setText(inBedCount);
+		mEmptyBedNumTextViewPtr->setText(emptyBedCount);
+	}
 
-		if (mBedListViewPtr != NULL) {
-			if (mainModeInt == 1) {
-				mBedListViewPtr->refreshListView();
+	static void getFrameRoom(int frame_id) {
+		string url = getHttpGateway() + "/deviceRoom/get_frame_room/" + to_string(frame_id);
+		LOGD("请求房间信息. url = %s", url.c_str());
+		//发起HTTP GET请求
+		RestClient::Response r = RestClient::get(url);
+		LOGD("获得房间信息. result = %s", r.body.c_str());
+		//解析json
+		Json::Reader reader;
+		Json::Value root;
+		if (reader.parse(r.body, root, false)){
+			frameRoom = root;
+			frameBedList = root["frame_bed_list"];
+
+			inBedCount = 0;
+			emptyBedCount = 0;
+			if (frameBedList.size() > 0) {
+				for (int i = 0; i < frameBedList.size(); i++) {
+					string customerId = frameBedList[i]["customer_id"].asString();
+					if (customerId != "") {
+						inBedCount += 1;
+					}
+				}
+				emptyBedCount = frameBedList.size() - inBedCount;
+				getBedCount();
 			}
-			else if (mainModeInt == 2) {
-				if (frameBedList.size() <= 3) {
+
+			if (mBedListViewPtr != NULL) {
+				if (mainModeInt == 1) {
 					mBedListViewPtr->refreshListView();
-					mBedListViewPtr->setVisible(true);
-					mBedListView2Ptr->setVisible(false);
-					mBedListView3Ptr->setVisible(false);
 				}
-				else if (frameBedList.size() > 3 && frameBedList.size() <= 6) {
-					mBedListView2Ptr->refreshListView();
-					mBedListViewPtr->setVisible(false);
-					mBedListView2Ptr->setVisible(true);
-					mBedListView3Ptr->setVisible(false);
-
+				else if (mainModeInt == 2) {
+					if (frameBedList.size() <= 3) {
+						mBedListViewPtr->refreshListView();
+						mBedListViewPtr->setVisible(true);
+						mBedListView2Ptr->setVisible(false);
+						mBedListView3Ptr->setVisible(false);
+					}
+					else if (frameBedList.size() > 3 && frameBedList.size() <= 6) {
+						mBedListView2Ptr->refreshListView();
+						mBedListViewPtr->setVisible(false);
+						mBedListView2Ptr->setVisible(true);
+						mBedListView3Ptr->setVisible(false);
+
+					}
+					else {
+						mBedListView3Ptr->refreshListView();
+						mBedListViewPtr->setVisible(false);
+						mBedListView2Ptr->setVisible(false);
+						mBedListView3Ptr->setVisible(true);
+					}
 				}
-				else {
-					mBedListView3Ptr->refreshListView();
+				else if (mainModeInt == 3) {
+					mBedListView4Ptr->refreshListView();
 					mBedListViewPtr->setVisible(false);
-					mBedListView2Ptr->setVisible(false);
-					mBedListView3Ptr->setVisible(true);
+					mBedListView4Ptr->setVisible(true);
 				}
 			}
-			else if (mainModeInt == 3) {
-				mBedListView4Ptr->refreshListView();
-				mBedListViewPtr->setVisible(false);
-				mBedListView4Ptr->setVisible(true);
-			}
 		}
 	}
-}
 
 
-// 将医生和护士别称缓存起来
-static void setRightTitle(Json::Value partSetting) {
-	rightTitleInfo["doctor_title"] = partSetting["doctor_title"].asString();
-	rightTitleInfo["doctor_valid"] = partSetting["doctor_valid"].asInt();
-	rightTitleInfo["nurse_title"] = partSetting["nurse_title"].asString();
-	rightTitleInfo["nurse_valid"] = partSetting["nurse_valid"].asInt();
-}
+	// 将医生和护士别称缓存起来
+	static void setRightTitle(Json::Value partSetting) {
+		rightTitleInfo["doctor_title"] = partSetting["doctor_title"].asString();
+		rightTitleInfo["doctor_valid"] = partSetting["doctor_valid"].asInt();
+		rightTitleInfo["nurse_title"] = partSetting["nurse_title"].asString();
+		rightTitleInfo["nurse_valid"] = partSetting["nurse_valid"].asInt();
+	}
 
-static void setDirectorAndHeadNurse() {
-	mDirectorTextViewPtr->setText(partSetting.partDirector);
-	mNurseHeadTextViewPtr->setText(partSetting.partNurseHead);
-}
+	static void setDirectorAndHeadNurse() {
+		mDirectorTextViewPtr->setText(partSetting.partDirector);
+		mNurseHeadTextViewPtr->setText(partSetting.partNurseHead);
+	}
 
 
-static void getPartSetting(string partId){
-	string url = getHttpGateway() + "/deviceBed/getPartSetting/" + partId;
-	LOGD("请求科室信息. url = %s", url.c_str());
-	//发起HTTP GET请求
-	RestClient::Response r = RestClient::get(url);
-	LOGD("获得科室信息. result = %s", r.body.c_str());
-	//解析json
-	Json::Reader reader;
-	Json::Value root;
-	if (reader.parse(r.body, root, false)){
-		partSetting.partId = root["part_id"].asInt();
-		partSetting.dayStart = root["day_start"].asString();
-		partSetting.dayLight = root["day_light"].asInt();
-		partSetting.dayVol = root["day_vol"].asInt();
-		partSetting.dayRingVol = root["day_ring_vol"].asInt();
-		partSetting.dayRingTimes = root["day_ring_times"].asInt();
-		partSetting.dayNurseLed = root["day_nurse_led"].asInt();
-		partSetting.dayDoorVol = root["day_door_vol"].asInt();
-		partSetting.dayBedVol = root["day_bed_vol"].asInt();
-		partSetting.dayTransferBoxVol = root["day_transfer_box_vol"].asInt();
-		partSetting.dayTransferBoxSystemVol = root["day_transfer_box_system_vol"].asInt();
-		partSetting.nightStart = root["night_start"].asString();
-		partSetting.nightLight = root["night_light"].asInt();
-		partSetting.nightVol = root["night_vol"].asInt();
-		partSetting.nightRingVol = root["night_ring_vol"].asInt();
-		partSetting.nightRingTimes = root["night_ring_times"].asInt();
-		partSetting.nightNurseLed = root["night_nurse_led"].asInt();
-		partSetting.nightDoorVol = root["night_door_vol"].asInt();
-		partSetting.nightBedVol = root["night_bed_vol"].asInt();
-		partSetting.nightTransferBoxVol = root["night_transfer_box_vol"].asInt();
-		partSetting.nightTransferBoxSystemVol = root["night_transfer_box_system_vol"].asInt();
-		partSetting.sleepSecondsNurse = root["sleep_seconds_nurse"].asInt();
-		partSetting.sleepSecondsDoor = root["sleep_seconds_door"].asInt();
-		partSetting.sleepSecondsBed = root["sleep_seconds_bed"].asInt();
-		partSetting.sipOvertime = root["sip_overtime"].asInt();
-		partSetting.transferDuration = root["transfer_duration"].asInt();
-		partSetting.transferDurationLeader = root["transfer_duration_leader"].asInt();
-		partSetting.communicationModeBed = root["communication_mode_bed"].asInt();
-		partSetting.communicationModeNurse = root["communication_mode_nurse"].asInt();
-		partSetting.communicationModeMobile = root["communication_model_mobile"].asInt();
-		partSetting.customizeRoleCallFirst = root["customize_role_call_first"].asInt();
-		partSetting.customizeRoleCallSecond = root["customize_role_call_second"].asInt();
-		partSetting.customizeRoleCallThird = root["customize_role_call_third"].asInt();
-		partSetting.customizeRoleCallFourth = root["customize_role_call_fourth"].asInt();
-		partSetting.customizeRoleCallFifth = root["customize_role_call_fifth"].asInt();
-		partSetting.customizeHospitalCallFirst = root["customize_hospital_call_first"].asInt();
-		partSetting.customizeHospitalCallFirstName = root["customize_hospital_call_first_name"].asString();
-		partSetting.customizeHospitalCallSecond = root["customize_hospital_call_second"].asInt();
-		partSetting.customizeHospitalCallSecondName = root["customize_hospital_second_name"].asString();
-		partSetting.customizeHospitalCallThird = root["customize_hospital_call_third"].asInt();
-		partSetting.customizeHospitalCallThirdName = root["customize_hospital_call_third_name"].asString();
-		partSetting.doctorTitle = root["doctor_title"].asString();
-		partSetting.doctorValid = root["doctor_valid"].asInt();
-		partSetting.nurseTitle = root["nurse_title"].asString();
-		partSetting.nurseValid = root["nurse_valid"].asInt();
-		partSetting.doorNurseTitle = root["door_nurse_title"].asString();
-		partSetting.doorNurseValid = root["door_nurse_valid"].asInt();
-		partSetting.doorNursingTitle = root["door_nursing_title"].asString();
-		partSetting.doorNursingValid = root["door_nursing_valid"].asInt();
-		partSetting.partDirector = root["part_director"].asString();
-		partSetting.partNurseHead = root["part_nurse_head"].asString();
-		partSetting.upSeconds = root["up_seconds"].asInt();
-		partSetting.autoAccept = root["auto_accept"].asInt();
-		partSetting.eventForward = root["event_forward"].asInt();
-		partSetting.nursingColorRgb = root["nursing_color_rgb"].asString();
-		partSetting.twoColorDoorLightValid = root["two_color_door_light_valid"].asInt();
-		partSetting.qrUrl = root["qr_url"].asString();
-		partSetting.screenLight = root["screen_light"].asInt();
-		partSetting.roomCallBed = root["room_call_bed"].asInt();
-		partSetting.autoPosition = root["auto_position"].asInt();
-		partSetting.customerAgeHiddenOnDoor = root["customer_age_hidden_on_door"].asInt();
-
-		if (root.isMember("linux_bed_volume_native")) {
-			partSetting.linuxDoorVolumeNative = root["linux_door_volume_native"].asInt();
-			partSetting.linuxDoorGainSize = root["linux_door_gain_size"].asInt();
-
-			zk_audio_input_set_volume_native(0, 0);
-			zk_audio_input_set_volume_native(1, partSetting.linuxDoorVolumeNative);
-			GetTelephone()->SetInputPcmGainSize(partSetting.linuxDoorGainSize);
-
-			StoragePreferences::putInt(STORE_VOLUME_NATIVE, partSetting.linuxDoorVolumeNative);
-			StoragePreferences::putInt(STORE_GAIN_SIZE, partSetting.linuxDoorGainSize);
-		}
+	static void getPartSetting(string partId){
+		string url = getHttpGateway() + "/deviceBed/getPartSetting/" + partId;
+		LOGD("请求科室信息. url = %s", url.c_str());
+		//发起HTTP GET请求
+		RestClient::Response r = RestClient::get(url);
+		LOGD("获得科室信息. result = %s", r.body.c_str());
+		//解析json
+		Json::Reader reader;
+		Json::Value root;
+		if (reader.parse(r.body, root, false)){
+			partSetting.partId = root["part_id"].asInt();
+			partSetting.dayStart = root["day_start"].asString();
+			partSetting.dayLight = root["day_light"].asInt();
+			partSetting.dayVol = root["day_vol"].asInt();
+			partSetting.dayRingVol = root["day_ring_vol"].asInt();
+			partSetting.dayRingTimes = root["day_ring_times"].asInt();
+			partSetting.dayNurseLed = root["day_nurse_led"].asInt();
+			partSetting.dayDoorVol = root["day_door_vol"].asInt();
+			partSetting.dayBedVol = root["day_bed_vol"].asInt();
+			partSetting.dayTransferBoxVol = root["day_transfer_box_vol"].asInt();
+			partSetting.dayTransferBoxSystemVol = root["day_transfer_box_system_vol"].asInt();
+			partSetting.nightStart = root["night_start"].asString();
+			partSetting.nightLight = root["night_light"].asInt();
+			partSetting.nightVol = root["night_vol"].asInt();
+			partSetting.nightRingVol = root["night_ring_vol"].asInt();
+			partSetting.nightRingTimes = root["night_ring_times"].asInt();
+			partSetting.nightNurseLed = root["night_nurse_led"].asInt();
+			partSetting.nightDoorVol = root["night_door_vol"].asInt();
+			partSetting.nightBedVol = root["night_bed_vol"].asInt();
+			partSetting.nightTransferBoxVol = root["night_transfer_box_vol"].asInt();
+			partSetting.nightTransferBoxSystemVol = root["night_transfer_box_system_vol"].asInt();
+			partSetting.sleepSecondsNurse = root["sleep_seconds_nurse"].asInt();
+			partSetting.sleepSecondsDoor = root["sleep_seconds_door"].asInt();
+			partSetting.sleepSecondsBed = root["sleep_seconds_bed"].asInt();
+			partSetting.sipOvertime = root["sip_overtime"].asInt();
+			partSetting.transferDuration = root["transfer_duration"].asInt();
+			partSetting.transferDurationLeader = root["transfer_duration_leader"].asInt();
+			partSetting.communicationModeBed = root["communication_mode_bed"].asInt();
+			partSetting.communicationModeNurse = root["communication_mode_nurse"].asInt();
+			partSetting.communicationModeMobile = root["communication_model_mobile"].asInt();
+			partSetting.customizeRoleCallFirst = root["customize_role_call_first"].asInt();
+			partSetting.customizeRoleCallSecond = root["customize_role_call_second"].asInt();
+			partSetting.customizeRoleCallThird = root["customize_role_call_third"].asInt();
+			partSetting.customizeRoleCallFourth = root["customize_role_call_fourth"].asInt();
+			partSetting.customizeRoleCallFifth = root["customize_role_call_fifth"].asInt();
+			partSetting.customizeHospitalCallFirst = root["customize_hospital_call_first"].asInt();
+			partSetting.customizeHospitalCallFirstName = root["customize_hospital_call_first_name"].asString();
+			partSetting.customizeHospitalCallSecond = root["customize_hospital_call_second"].asInt();
+			partSetting.customizeHospitalCallSecondName = root["customize_hospital_second_name"].asString();
+			partSetting.customizeHospitalCallThird = root["customize_hospital_call_third"].asInt();
+			partSetting.customizeHospitalCallThirdName = root["customize_hospital_call_third_name"].asString();
+			partSetting.doctorTitle = root["doctor_title"].asString();
+			partSetting.doctorValid = root["doctor_valid"].asInt();
+			partSetting.nurseTitle = root["nurse_title"].asString();
+			partSetting.nurseValid = root["nurse_valid"].asInt();
+			partSetting.doorNurseTitle = root["door_nurse_title"].asString();
+			partSetting.doorNurseValid = root["door_nurse_valid"].asInt();
+			partSetting.doorNursingTitle = root["door_nursing_title"].asString();
+			partSetting.doorNursingValid = root["door_nursing_valid"].asInt();
+			partSetting.partDirector = root["part_director"].asString();
+			partSetting.partNurseHead = root["part_nurse_head"].asString();
+			partSetting.upSeconds = root["up_seconds"].asInt();
+			partSetting.autoAccept = root["auto_accept"].asInt();
+			partSetting.eventForward = root["event_forward"].asInt();
+			partSetting.nursingColorRgb = root["nursing_color_rgb"].asString();
+			partSetting.twoColorDoorLightValid = root["two_color_door_light_valid"].asInt();
+			partSetting.qrUrl = root["qr_url"].asString();
+			partSetting.screenLight = root["screen_light"].asInt();
+			partSetting.roomCallBed = root["room_call_bed"].asInt();
+			partSetting.autoPosition = root["auto_position"].asInt();
+			partSetting.customerAgeHiddenOnDoor = root["customer_age_hidden_on_door"].asInt();
+
+			if (root.isMember("linux_bed_volume_native")) {
+				partSetting.linuxDoorVolumeNative = root["linux_door_volume_native"].asInt();
+				partSetting.linuxDoorGainSize = root["linux_door_gain_size"].asInt();
+
+				zk_audio_input_set_volume_native(0, 0);
+				zk_audio_input_set_volume_native(1, partSetting.linuxDoorVolumeNative);
+				GetTelephone()->SetInputPcmGainSize(partSetting.linuxDoorGainSize);
+
+				StoragePreferences::putInt(STORE_VOLUME_NATIVE, partSetting.linuxDoorVolumeNative);
+				StoragePreferences::putInt(STORE_GAIN_SIZE, partSetting.linuxDoorGainSize);
+			}
 
-		StoragePreferences::putString(STORE_DAY_START, partSetting.dayStart);
-		StoragePreferences::putInt(STORE_DAY_LIGHT,partSetting.dayLight);
-		StoragePreferences::putInt(STORE_DAY_VOL,partSetting.dayDoorVol);
-		StoragePreferences::putInt(STORE_DAY_RING_TIMES,partSetting.dayRingTimes);
+			StoragePreferences::putString(STORE_DAY_START, partSetting.dayStart);
+			StoragePreferences::putInt(STORE_DAY_LIGHT,partSetting.dayLight);
+			StoragePreferences::putInt(STORE_DAY_VOL,partSetting.dayDoorVol);
+			StoragePreferences::putInt(STORE_DAY_RING_TIMES,partSetting.dayRingTimes);
 
-		StoragePreferences::putString(STORE_NIGHT_START, partSetting.nightStart);
-		StoragePreferences::putInt(STORE_NIGHT_LIGHT,partSetting.nightLight);
-		StoragePreferences::putInt(STORE_NIGHT_VOL,partSetting.nightDoorVol);
-		StoragePreferences::putInt(STORE_NIGHT_RING_TIMES,partSetting.nightRingTimes);
+			StoragePreferences::putString(STORE_NIGHT_START, partSetting.nightStart);
+			StoragePreferences::putInt(STORE_NIGHT_LIGHT,partSetting.nightLight);
+			StoragePreferences::putInt(STORE_NIGHT_VOL,partSetting.nightDoorVol);
+			StoragePreferences::putInt(STORE_NIGHT_RING_TIMES,partSetting.nightRingTimes);
 
-		StoragePreferences::putInt(STORE_SLEEP_TIME, partSetting.sleepSecondsDoor);
+			StoragePreferences::putInt(STORE_SLEEP_TIME, partSetting.sleepSecondsDoor);
 
-		StoragePreferences::putString(STORE_DOCTOR_TITLE, partSetting.doctorTitle);
-		StoragePreferences::putBool(STORE_DOCTOR_VISIBLE, partSetting.doctorValid==1);
-		StoragePreferences::putString(STORE_NURSE_TITLE, partSetting.nurseTitle);
-		StoragePreferences::putBool(STORE_NURSE_VISIBLE, partSetting.nurseValid==1);
+			StoragePreferences::putString(STORE_DOCTOR_TITLE, partSetting.doctorTitle);
+			StoragePreferences::putBool(STORE_DOCTOR_VISIBLE, partSetting.doctorValid==1);
+			StoragePreferences::putString(STORE_NURSE_TITLE, partSetting.nurseTitle);
+			StoragePreferences::putBool(STORE_NURSE_VISIBLE, partSetting.nurseValid==1);
 
-		StoragePreferences::putString(STORE_NURSING_COLOR_RGB, partSetting.nursingColorRgb);
-		StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
-		StoragePreferences::putInt(STORE_SCREEN_LIGHT, partSetting.screenLight);
-		StoragePreferences::putInt(STORE_ROOM_CALL_BED, partSetting.roomCallBed);
-		StoragePreferences::putInt(STORE_AUTO_POSITION, partSetting.autoPosition);
+			StoragePreferences::putString(STORE_NURSING_COLOR_RGB, partSetting.nursingColorRgb);
+			StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
+			StoragePreferences::putInt(STORE_SCREEN_LIGHT, partSetting.screenLight);
+			StoragePreferences::putInt(STORE_ROOM_CALL_BED, partSetting.roomCallBed);
+			StoragePreferences::putInt(STORE_AUTO_POSITION, partSetting.autoPosition);
 
-		setRightTitle(root);
-//		callBedButtonSetVisible();
-		setDirectorAndHeadNurse();
+			setRightTitle(root);
+	//		callBedButtonSetVisible();
+			setDirectorAndHeadNurse();
 
-		getFrameRoom(frameInfo["frame_id"].asInt());
+			getFrameRoom(frameInfo["frame_id"].asInt());
 
-		dataInit = true;
+			dataInit = true;
+		}
 	}
-}
 
-static void getVersion() {
-	std::string url = getHttpGateway() + "/deviceRoom/get_app_version?device_type=303&part_id=" + StoragePreferences::getString(STORE_PARTID, "");
-	std::string content_type = std::string("application/json");
+	static void getVersion() {
+		std::string url = getHttpGateway() + "/deviceRoom/get_app_version?device_type=303&part_id=" + StoragePreferences::getString(STORE_PARTID, "");
+		std::string content_type = std::string("application/json");
 
-	LOGD("请求版本信息. url = %s", url.c_str());
-	//发起HTTP POST请求
-	RestClient::Response r = RestClient::post(url, content_type, "");
-	if (r.code != 200) {
-		LOGD("请求版本信息-> 错误代码: %d", r.code);
-		return;
-	}
+		LOGD("请求版本信息. url = %s", url.c_str());
+		//发起HTTP POST请求
+		RestClient::Response r = RestClient::post(url, content_type, "");
+		if (r.code != 200) {
+			LOGD("请求版本信息-> 错误代码: %d", r.code);
+			return;
+		}
 
-	LOGD("获得版本信息. result = %s", r.body.c_str());
-	//解析json
-	Json::Reader reader;
-	Json::Value root;
-
-	if(reader.parse(r.body, root, false)) {
-		int currentVersionNo = getVersionNo();
-		int responseVersionNo = root["version_no"].asInt();
-		std::string responseVersion = root["version_code"].asString();
-		LOGD("服务器版本 : %s %d, 当前设备版本: %d", responseVersion.c_str(), responseVersionNo, currentVersionNo);
-
-		if (currentVersionNo < responseVersionNo) {
-			Intent* intent = new Intent();
-			intent->putExtra(appUpdate, "true");
-			EASYUICONTEXT->openActivity("updateActivity", intent);
+		LOGD("获得版本信息. result = %s", r.body.c_str());
+		//解析json
+		Json::Reader reader;
+		Json::Value root;
+
+		if(reader.parse(r.body, root, false)) {
+			int currentVersionNo = getVersionNo();
+			int responseVersionNo = root["version_no"].asInt();
+			std::string responseVersion = root["version_code"].asString();
+			LOGD("服务器版本 : %s %d, 当前设备版本: %d", responseVersion.c_str(), responseVersionNo, currentVersionNo);
+
+			if (currentVersionNo < responseVersionNo) {
+				Intent* intent = new Intent();
+				intent->putExtra(appUpdate, "true");
+				EASYUICONTEXT->openActivity("updateActivity", intent);
+			}
 		}
 	}
-}
 
-static void getNfcInteraction() {
-	std::string url = getHttpGateway() + "/deviceRoom/get_nfc_interaction_end_time_is_null/" + to_string(StoragePreferences::getInt(STORE_DEVICE_ID,0));
+	static void getNfcInteraction() {
+		std::string url = getHttpGateway() + "/deviceRoom/get_nfc_interaction_end_time_is_null/" + to_string(StoragePreferences::getInt(STORE_DEVICE_ID,0));
 
-	LOGD("请求未完成的nfc记录. url = %s", url.c_str());
-	//发起HTTP POST请求
-	RestClient::Response r = RestClient::get(url);
-	if (r.code != 200) {
-		LOGD("请求未完成的nfc记录-> 错误代码: %d", r.code);
-		return;
-	}
+		LOGD("请求未完成的nfc记录. url = %s", url.c_str());
+		//发起HTTP POST请求
+		RestClient::Response r = RestClient::get(url);
+		if (r.code != 200) {
+			LOGD("请求未完成的nfc记录-> 错误代码: %d", r.code);
+			return;
+		}
 
-	LOGD("获得未完成的nfc记录. result = %s", r.body.c_str());
-	//解析json
-	Json::Reader reader;
-	Json::Value root;
-
-	if(reader.parse(r.body, root, false)) {
-		int clerkId = 0;
-		for (int i = 0; i < root.size(); i++) {
-			if (root[i]["components_type"].asCString() == TcpType::AUTH) {
-				clerkId = root[i]["clerk_id"].asInt();
-				setClerk(root[i]["clerk_name"].asCString(), root[i]["pass_no"].asCString(), root[i]["id"].asInt());
-			}
-			else if (root[i]["components_type"].asString() == "POSITION_COMPONENT") {
-				setPosistionItId(root[i]["id"].asInt());
-				setPositionButton(true);
+		LOGD("获得未完成的nfc记录. result = %s", r.body.c_str());
+		//解析json
+		Json::Reader reader;
+		Json::Value root;
+
+		if(reader.parse(r.body, root, false)) {
+			int clerkId = 0;
+			for (int i = 0; i < root.size(); i++) {
+				if (root[i]["components_type"].asCString() == TcpType::AUTH) {
+					clerkId = root[i]["clerk_id"].asInt();
+					setClerk(root[i]["clerk_name"].asCString(), root[i]["pass_no"].asCString(), root[i]["id"].asInt());
+				}
+				else if (root[i]["components_type"].asString() == "POSITION_COMPONENT") {
+					setPosistionItId(root[i]["id"].asInt());
+					setPositionButton(true);
+				}
+				else if (root[i]["components_type"].asString() == "ROOMCHECK_COMPONENT") {
+					setRoomCheckItId(root[i]["id"].asInt());
+					setRoomPatrolButton(true);
+				}
+				else if (root[i]["components_type"].asString() == "SCREEN_TIP_SET_COMPONENT") {
+					time_t now = TimeHelper::getDateline();
+					if (now <= 0) {
+						continue;
+					}
+
+					Json::Reader Reader;
+					Json::Value operationData;
+					Reader.parse(root[i]["operation_data"].asString(), operationData);
+					int seconds = operationData["seconds"].asInt();
+
+					if (now - root[i]["start_time"].asInt() < seconds) {
+						setPromptTimeItId(root[i]["id"].asInt());
+
+						Intent* intent = new Intent();
+						intent->putExtra(promptText2, operationData["tips"].asString());
+						intent->putExtra(promptTime2, to_string(seconds - (now - root[i]["start_time"].asInt())));
+						EASYUICONTEXT->openActivity("promptActivity", intent);
+					}
+					else {
+						sendPromptQuit(root[i]["id"].asInt());
+					}
+				}
 			}
-			else if (root[i]["components_type"].asString() == "ROOMCHECK_COMPONENT") {
-				setRoomCheckItId(root[i]["id"].asInt());
-				setRoomPatrolButton(true);
+			if (clerkId != 0) {
+				goCare();
 			}
-			else if (root[i]["components_type"].asString() == "SCREEN_TIP_SET_COMPONENT") {
-				time_t now = TimeHelper::getDateline();
-				if (now <= 0) {
-					continue;
-				}
+		}
+	}
 
-				Json::Reader Reader;
-				Json::Value operationData;
-				Reader.parse(root[i]["operation_data"].asString(), operationData);
-				int seconds = operationData["seconds"].asInt();
 
-				if (now - root[i]["start_time"].asInt() < seconds) {
-					setPromptTimeItId(root[i]["id"].asInt());
+	/**
+	 * 线程创建成功后会调用该函数,可以在该函数中做一些初始化操作
+	 * return true   继续线程
+	 *        false  退出线程
+	 */
+	virtual bool readyToRun() {
+		LOGD("Thread 已经创建完成");
+		return true;
+	}
 
-					Intent* intent = new Intent();
-					intent->putExtra(promptText2, operationData["tips"].asString());
-					intent->putExtra(promptTime2, to_string(seconds - (now - root[i]["start_time"].asInt())));
-					EASYUICONTEXT->openActivity("promptActivity", intent);
-				}
-				else {
-					sendPromptQuit(root[i]["id"].asInt());
+	/**
+	 * 线程循环函数
+	 *
+	 * return true  继续线程循环
+	 *        false 推出线程
+	 */
+	virtual bool threadLoop() {
+		LOGD("线程循环函数");
+
+		//检查是否有退出线程的请求,如果有,则返回false,立即退出线程
+		if (exitPending()) {
+			return false;
+		}
+
+		udpConn = net::Dial("udp", "192.168.1.255:10010");
+		if (udpConn) {
+			byte buf[1024] = {0};
+			const char* req = "search_server";
+			//发送
+			udpConn->Write((byte*)req, strlen(req));
+			while (true && !exitPending()) {
+				//读取,超时10*1000毫秒
+				int n = udpConn->Read(buf, sizeof(buf) - 1, 10*1000);
+				if (n > 0) {
+					buf[n] = 0;
+					char serverStr[1024];
+					sprintf(serverStr,"%s",buf);
+					LOGD("读取 %d字节: %s", n, serverStr);
+
+					//解析json
+					Json::Reader reader;
+					Json::Value root;
+					if (reader.parse(serverStr, root, false)){
+						if (root.isMember("success") && root["success"].asBool()){
+							serverIP = root["data"]["third_server"].asString();
+							serverHttpPort = root["data"]["third_server_port"].asInt();
+
+							StoragePreferences::putString(STORE_GATEWAY, serverIP);
+							StoragePreferences::putInt(STORE_HTTP_PORT, serverHttpPort);
+
+							//先获取服务器信息
+							//getServerInfo();
+							//就当在获取服务器信息完成后获取用户信息,这里测试用
+							//getCustomerInfo();
+							//退出UDP线程
+							pthread_exit(NULL);
+							break;
+						}
+					}
+				} else if (n == 0) {
+					LOGD("连接正常断开");
+					break;
+				} else if (n == net::E_TIMEOUT) {
+					udpConn->Write((byte*)req, strlen(req));
+					LOGD("读取超时");
+				} else {
+					LOGD("出错");
+					break;
 				}
 			}
+			//关闭连接
+			udpConn->Close();
+			//释放内存
+			delete udpConn;
+			udpConn = NULL;
 		}
-		if (clerkId != 0) {
-			goCare();
-		}
+
+		//返回真,继续下次线程循环
+		return true;
 	}
-}
+};
+
+static UdpThread udp_thread;
 
 
 
-static void getDeviceInfo(){
-	if (dataInit){
-		getFrameInfo();
-		getBedCount();
-		setDirectorAndHeadNurse();
-		return;
-	}
-	string url = getHttpGateway() + "/deviceRoom/get_device_by_eth_mac/" + StoragePreferences::getString(STORE_MAC_ADDR, "0.0.0.0");
-	LOGD("请求设备信息. url = %s", url.c_str());
-	//发起HTTP GET请求
-	RestClient::Response r = RestClient::get(url);
-	LOGD("获得设备信息. result = %s", r.body.c_str());
-	//解析json
-	Json::Reader reader;
-	Json::Value root;
-	if (reader.parse(r.body, root, false)){
-		string partName = root["part_display"].asString();
-		StoragePreferences::putString(STORE_PARTNAME,partName);
-		NavibarSetPartName(partName);
-		//设备
-		StoragePreferences::putInt(STORE_DEVICE_ID, root["id"].asInt());
-		StoragePreferences::putInt(STORE_DEVICE_TYPE, root["device_type"].asInt());
-
-		//SIP存储
-//			StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());	// 应该去找配置文件里的sip-ip
-		StoragePreferences::putString(SIP_REG_ACCOUNT,root["sip_id"].asString());
-		StoragePreferences::putString(SIP_REG_PASSWORD, root["sip_password"].asString());
-
-		frameInfo["frame_id"] = root["frame_id"].asInt();
-		frameInfo["full_name"] = root["full_name"].asString();
-		frameInfo["part_id"] = root["part_id"].asInt();
-		getFrameInfo();
-
-		//获取科室设置
-		string partId = root["part_id"].asString();
-		StoragePreferences::putString(STORE_PARTID, partId);
-		getPartSetting(partId);
-		getVersion();
-		getNfcInteraction();
-	}
-}
 
 Json::Value getFrame() {
 	return frameRoom;
@@ -488,15 +582,15 @@ void dataRefresh() {
 	}
 
 	if (serverInfo) {
-		getServerInfo();
+		udp_thread.getServerInfo();
 	}
 	dataInit = false;
-	getDeviceInfo();
+	udp_thread.getDeviceInfo();
 	mBedListViewPtr->refreshListView();
 }
 
 void getPartSetting() {
-	getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
+	udp_thread.getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
 }
 
 
@@ -517,12 +611,10 @@ static void onUI_init(){
 	//run("this is thread name");
 	//测试用
 	LOGD("进入mainLogic页面, 触发 onUI_init");
-	if (ETHERNETMANAGER->isConnected() || WIFIMANAGER->isConnected()) {
-		if(serverInfo) {	// 如果是false,就是不需要
-			getServerInfo();
-		}
-		getDeviceInfo();
-	}
+    if(serverInfo && isConnectServer()) {    // 如果是false,就是不需要
+        udp_thread.getServerInfo();
+    }
+    udp_thread.getDeviceInfo();
 	setMainMode();
 
 }

+ 496 - 182
jni/logic/startLogic.cc

@@ -28,11 +28,27 @@ static bool isNetreset = false;
 static int netresetInt = 0;
 static string callTid = "";
 
+Json::Value sosInteraction;
+
+struct DeviceButtonFunctionTypeAndValue {
+	string type;
+	string value;
+};
+static std::unordered_map<string, DeviceButtonFunctionTypeAndValue> deviceButtonFunction;
+
 
 static bool isConnectHandle = false;
 static bool isConnectSos = false;
-static bool isTriggerHandle = false;
-static bool isTriggerSos = false;
+
+static bool isTriggerKey5 = false;
+static bool isTriggerKey6 = false;
+static bool isTriggerKey7 = false;
+static bool isTriggerKey8 = false;
+static bool isTriggerKey9 = false;
+static bool isTriggerKey10 = false;
+static bool isTriggerKey11 = false;
+static bool isTriggerKey12 = false;
+static bool isTriggerKey13 = false;
 
 #define FUNCTION_TIMER_HANDLE 3	// 增援的定时器id
 #define SOS_CLICK_TIME_HANDLE 4	// sos的定时器id
@@ -42,8 +58,15 @@ static bool isTriggerSos = false;
 #define SYS_RESTART_TIME_HANDLE 10	// 重启
 #define PROMPT_TIME_HANDLE 11	// 提示语s
 
-#define HANDLE_TRIGGER_TIME_HANDLE 15
-#define SOS_TRIGGER_TIME_HANDLE 16
+#define KEY5_TRIGGER_TIME_HANDLE 15
+#define KEY6_TRIGGER_TIME_HANDLE 16
+#define KEY7_TRIGGER_TIME_HANDLE 17
+#define KEY8_TRIGGER_TIME_HANDLE 18
+#define KEY9_TRIGGER_TIME_HANDLE 19
+#define KEY10_TRIGGER_TIME_HANDLE 20
+#define KEY11_TRIGGER_TIME_HANDLE 21
+#define KEY12_TRIGGER_TIME_HANDLE 22
+#define KEY13_TRIGGER_TIME_HANDLE 23
 
 #define HTTP_SERVER_PORT  80
 
@@ -236,20 +259,13 @@ void lightControl(std::string typeStr, std::string lightColorStr) {
 
 // 接收tcp消息
 void handleMsg(byte* inBytes){
-	LOGD("TCP received: %s", inBytes);
-	const char* cstr = reinterpret_cast<const char*>(inBytes);
-	string str = cstr;
-	if (str == "1"){
-		LOGD("get a heart beat");
-		return;
-	}
-
 	TcpModel tcpModel;
 	tcpModel = getTcpModel(inBytes);
 	LOGD("tcp model: %s, %s", tcpModel.type.c_str(), tcpModel.action.c_str());
 	if (tcpModel.type == TcpType::OTHER) {
 		LOGD("trans tcp json failed");
-	} else if (tcpModel.type == TcpType::TIME) {
+	}
+	else if (tcpModel.type == TcpType::TIME) {
 		if (tcpModel.action == TimeAction::SYNC) {
 			string serverTime = "";
 			if (tcpModel.data != ""){
@@ -469,6 +485,9 @@ void handleMsg(byte* inBytes){
 			mActivityPtr->registerUserTimer(SOS_CLICK_TIME_HANDLE, 10000);		// 10秒后才能触发
 			mActivityPtr->registerUserTimer(SOS_LAMP_TIME_HANDLE, 120000);		// 2分钟后才能触发
 
+			if (tcpModel.json["fromEthMac"].asString() == StoragePreferences::getString(STORE_MAC_ADDR, "0.0.0.0")) {
+				sosInteraction = tcpModel.json;
+			}
 		}
 		else if (tcpModel.action == SideAction::SOS_CANCEL) {
 			// 进行门灯还原
@@ -643,6 +662,203 @@ void sosCall(string sosMsg) {
 		sosTimerRegistered = false;
 		mActivityPtr->registerUserTimer(SOS_CLICK_TIME_HANDLE, 10000);		// 10秒后才能触发
 		mActivityPtr->registerUserTimer(SOS_LAMP_TIME_HANDLE, 120000);		// 2分钟后才能触发
+
+        Intent* intent = new Intent();
+        intent->putExtra(functionWindows, "sosCall");
+        EASYUICONTEXT->openActivity("functionActivity", intent);
+	}
+}
+
+
+
+void clearDeviceButtonFunction() {
+	deviceButtonFunction.clear();
+}
+
+void setDeviceButtonFunction(std::string deviceButtonFunctionStr) {
+	LOGD("deviceButtonFunctionStr ==========> %s", deviceButtonFunctionStr.c_str());
+	Json::Reader reader;
+	Json::Value deviceButtonFunctionJson;
+	if (reader.parse(deviceButtonFunctionStr, deviceButtonFunctionJson)) {
+		for (Json::Value json : deviceButtonFunctionJson) {
+			const std::string key = json["key"].asString();
+			const std::string type = json["type"].asString();
+			DeviceButtonFunctionTypeAndValue typeAndValue;
+			typeAndValue.type = type;
+			if (type == "EVENT") {
+				int value = json["value"].asInt();
+				std::stringstream valueStr;
+				valueStr << value;
+				typeAndValue.value = valueStr.str();
+				LOGD("key:%s  type:%s  value:%d ", key.c_str(), type.c_str(), value);
+			}
+			else {
+				string valueStr = json["value"].asString();
+				typeAndValue.value = valueStr;
+				LOGD("key:%s  type:%s  value:%s ", key.c_str(), type.c_str(), valueStr.c_str());
+			}
+			deviceButtonFunction[key] = typeAndValue;
+		}
+	}
+}
+
+
+
+void handleCall(string key, string roleType) {
+    if (isSleep) {
+        screenOn();
+        if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
+            return;
+        }
+    }
+
+	if (roleType == "CANCEL") {
+		voip::CallInfo info = GetTelephone()->GetCallInfo();
+		//拨打 或 挂断
+		if (CallingStatus::instance()->busy()){
+			lightControl("DOORLED", "000F");
+
+			callActivityFinish(CallFinishType::A1CLICK);
+		}
+	}
+	else {
+		voip::CallInfo info = GetTelephone()->GetCallInfo();
+		//拨打 或 挂断
+		if (CallingStatus::instance()->busy()){
+			lightControl("DOORLED", "000F");
+
+			callActivityFinish(CallFinishType::A1CLICK);
+		} else {
+			lightControl("DOORLED", "200F");
+
+			Intent* intent = new Intent();
+			intent->putExtra(callRoleType, roleType);
+			intent->putExtra(callActivityType, "fromCall");
+			EASYUICONTEXT->openActivity("callActivity", intent);
+		}
+	}
+}
+
+
+void handleSosCancel(string key) {
+	LOGD("Trigger sos cancel");
+	if (sosInteraction > 0 && sosInteraction.isMember("id")) {
+		sendSosCancel(sosInteraction["id"].asString());
+
+		sosInteraction = Json::Value();
+	}
+}
+
+
+void handleSos(string value) {
+	screenOn();
+	if (value == "SOS_CANCEL") {
+		handleSosCancel("");
+	}
+	else {
+        sosCall("");
+	}
+}
+
+void handleEvent(string key, string id) {
+	if (isSleep) {
+		screenOn();
+		if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
+			return;
+		}
+	}
+}
+
+
+void handleReinforce(string key) {
+	if (isSleep) {
+		screenOn();
+		if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
+			return;
+		}
+	}
+
+    sendReinforceCall();
+
+	Intent* intent = new Intent();
+	intent->putExtra(functionWindows, "help");
+	EASYUICONTEXT->openActivity("functionActivity", intent);
+}
+
+
+void handleNursing(string key, string time) {
+	if (isSleep) {
+		screenOn();
+		if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
+			return;
+		}
+	}
+}
+
+void handleBlueCode() {
+	if (isSleep) {
+		screenOn();
+	}
+}
+
+
+
+void getDeviceButtonFunction(string key) {
+	const char* currentAppName = EASYUICONTEXT->currentAppName();
+	string _currentAppName = currentAppName;
+	if (_currentAppName == "sipTestActivity") {
+	    if (isSleep) {
+	        screenOn();
+	        if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
+	            return;
+	        }
+	    }
+		setCheckbox(key);
+		return;
+	}
+
+    if (!isConnectServer()) {
+        return;
+    }
+
+	if (deviceButtonFunction.find(key) != deviceButtonFunction.end()) {
+		DeviceButtonFunctionTypeAndValue typeAndValue = deviceButtonFunction[key];
+		LOGD("typeAndValue.type: %s     typeAndValue.value: %s", typeAndValue.type.c_str(), typeAndValue.value.c_str());
+		if (typeAndValue.type == "SOS") {
+			handleSos(typeAndValue.value);
+		}
+		else if (typeAndValue.type == "VOICE") {
+			handleCall(key, typeAndValue.value);
+		}
+		else if (typeAndValue.type == "EVENT") {
+			handleEvent(key, typeAndValue.value);
+		}
+		else if (typeAndValue.type == "REINFORCE") {
+			handleReinforce(key);
+		}
+		else if (typeAndValue.type == "NURSING") {
+			handleNursing(key, typeAndValue.value);
+		}
+		else if (typeAndValue.type == "BLUE_CODE") {
+			handleBlueCode();
+		}
+	}
+	else {
+		if (key == "KEY5") {
+			handleCall(key, "NURSE");
+		}
+		else if (key == "KEY6") {
+			handleCall(key, "NURSE");
+		}
+		else if (key == "KEY7" || key == "KEY;") {
+			handleSos(key);
+		}
+		else if (key == "KEY>") {
+			handleCall(key, "CANCEL");
+		}
+		else if (key == "KEY@") {
+			handleSosCancel(key);
+		}
 	}
 }
 
@@ -868,187 +1084,295 @@ static void onUI_quit() {
  */
 static void onProtocolDataUpdate(const SProtocolData &data) {
 	LOGD("cmd = %s", data.cmd.c_str());
+    if (getIsUpdate()) {
+        LOGD("处于升级过程中,串口不可使用");
+        return;
+    }
 	if (data.state!=""){
 		LOGD("state = %s",data.state.c_str());
 	}
-//	if (data.msg != ""){
-//		LOGD("msg = %s", data.msg.c_str());
-//	}
-	if(UartContext::Uart3IsOpen()) {	// 如果是true,表示串口打开了
-		string heartStr;
-
-		if (data.cmd == "KEY5") {	// key5是面板拨号按钮
-			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("KEY5");
-					return;
-				}
-				else {
-					voip::CallInfo info = GetTelephone()->GetCallInfo();
-					//拨打 或 挂断
-					if (CallingStatus::instance()->busy()){
-						callActivityFinish(CallFinishType::A1CLICK);
-					} else {
-						Intent* intent = new Intent();
-						intent->putExtra(callActivityType, "fromCall");
-						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;
-					}
-				}
-
-				const char* currentAppName = EASYUICONTEXT->currentAppName();
-				string _currentAppName = currentAppName;
-				if (_currentAppName == "sipTestActivity") {
-					setCheckbox("KEY6");
-					return;
-				}
 
-				isTriggerHandle = true;
-				mActivityPtr->registerUserTimer(HANDLE_TRIGGER_TIME_HANDLE, 5 * 1000);
+	if (data.state == "0" || data.state == "1") {
+		if (data.cmd == "KEY5") {
+			if (isTriggerKey5) {
+				isTriggerKey5 = false;
+				getDeviceButtonFunction(data.cmd);
 			}
-			else if (data.state == "1") {
-				if (isTriggerHandle) {
-					voip::CallInfo info = GetTelephone()->GetCallInfo();
-					//拨打 或 挂断
-					if (CallingStatus::instance()->busy()){
-						callActivityFinish(CallFinishType::KEY6_CLICK);
-					} else {
-						Intent* intent = new Intent();
-						intent->putExtra(callActivityType, "fromCall");
-						EASYUICONTEXT->openActivity("callActivity", intent);
-					}
-				}
-			}
-			else if (data.state == "3") {
-				LOGD("手柄在线");
-				isConnectHandle = true;
+			else {
+				isTriggerKey5 = true;
+				mActivityPtr->registerUserTimer(KEY5_TRIGGER_TIME_HANDLE, 3 * 1000);
 			}
-			else if (data.state == "4") {
-				if (!isConnectHandle) {
-					return;
-				}
-				sosCall(LANGUAGEMANAGER->getValue("HandleDisconnected"));
+		}
+		else if (data.cmd == "KEY6") {
+			if (isTriggerKey6) {
+				isTriggerKey6 = false;
+				getDeviceButtonFunction(data.cmd);
+				return;
 			}
-
+			isTriggerKey6 = true;
+			mActivityPtr->registerUserTimer(KEY6_TRIGGER_TIME_HANDLE, 3 * 1000);
 
 		}
-		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;
-				}
-				else {
-					if (sosTimerRegistered) {
-						isTriggerSos = true;
-						mActivityPtr->registerUserTimer(SOS_TRIGGER_TIME_HANDLE, 5 * 1000);
-					}
-				}
-			}
-			else if (data.state == "1") {
-				sosCall("");
+		else if (data.cmd == "KEY7") {
+			if (isTriggerKey7) {
+				isTriggerKey7 = false;
+				getDeviceButtonFunction(data.cmd);
+				return;
 			}
-			else if (data.state == "3") {
-				LOGD("紧急按钮在线");
-				isConnectHandle = true;
+			isTriggerKey7 = true;
+			mActivityPtr->registerUserTimer(KEY7_TRIGGER_TIME_HANDLE, 3 * 1000);
+		}
+		else if (data.cmd == "KEY>") {
+			if (isTriggerKey8) {
+				isTriggerKey8 = false;
+				getDeviceButtonFunction(data.cmd);
+				return;
 			}
-			else if (data.state == "4") {
-				if (!isConnectHandle) {
-					return;
-				}
-				sosCall(LANGUAGEMANAGER->getValue("SosDisconnected"));
+			isTriggerKey8 = true;
+			mActivityPtr->registerUserTimer(KEY8_TRIGGER_TIME_HANDLE, 3 * 1000);
+		}
+		else if (data.cmd == "KEY<") {
+			if (isTriggerKey9) {
+				isTriggerKey9 = false;
+				getDeviceButtonFunction(data.cmd);
+				return;
 			}
+			isTriggerKey9 = true;
+			mActivityPtr->registerUserTimer(KEY9_TRIGGER_TIME_HANDLE, 3 * 1000);
 		}
-		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 {
-					voip::CallInfo info = GetTelephone()->GetCallInfo();
-					//拨打 或 挂断
-					if (CallingStatus::instance()->busy()){
-						callActivityFinish(CallFinishType::A1CLICK);
-					} else {
-						Intent* intent = new Intent();
-						intent->putExtra(callActivityType, "fromCall");
-						EASYUICONTEXT->openActivity("callActivity", intent);
-					}
-				}
+		else if (data.cmd == "KEY;") {
+			if (isTriggerKey10) {
+				isTriggerKey10 = false;
+				getDeviceButtonFunction(data.cmd);
+				return;
 			}
+			isTriggerKey10 = true;
+			mActivityPtr->registerUserTimer(KEY10_TRIGGER_TIME_HANDLE, 3 * 1000);
 		}
-		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 {
-					voip::CallInfo info = GetTelephone()->GetCallInfo();
-					//拨打 或 挂断
-					if (CallingStatus::instance()->busy()){
-						callActivityFinish(CallFinishType::A1CLICK);
-
-						lightControl("DOORLED", "000F");
-					}
-				}
+		else if (data.cmd == "KEY?") {
+			if (isTriggerKey11) {
+				isTriggerKey11 = false;
+				getDeviceButtonFunction(data.cmd);
+				return;
 			}
-
+			isTriggerKey11 = true;
+			mActivityPtr->registerUserTimer(KEY11_TRIGGER_TIME_HANDLE, 3 * 1000);
 		}
-		else if (data.cmd == "KEY;"){	//下左4,白
-			if (isSleep) {
-				screenOn();
+		else if (data.cmd == "KEY=") {
+			if (isTriggerKey12) {
+				isTriggerKey12 = false;
+				getDeviceButtonFunction(data.cmd);
+				return;
 			}
-			lightControl("DOORLED", "111F");
+			isTriggerKey12 = true;
+			mActivityPtr->registerUserTimer(KEY12_TRIGGER_TIME_HANDLE, 3 * 1000);
 		}
-		else {
-			if (isSleep) {
-				screenOn();
+		else if (data.cmd == "KEY@") {
+			if (isTriggerKey13) {
+				isTriggerKey13 = false;
+				getDeviceButtonFunction(data.cmd);
+				return;
 			}
-//				lightControl("DOORLED", "000F");
+			isTriggerKey13 = true;
+			mActivityPtr->registerUserTimer(KEY13_TRIGGER_TIME_HANDLE, 3 * 1000);
+		}
+	}
+	else if (data.state == "3") {
+		if (data.cmd == "KEY6") {
+			isConnectHandle = true;
+		}
+		else if (data.cmd == "KEY7") {
+			isConnectSos = true;
+		}
+	}
+	else if (data.state == "4") {
+		if (data.cmd == "KEY6" && isConnectHandle) {
+			Json::Value frame = getFrame();
+			sendDataRemindOhter(frame["full_name"].asString() + " " + LANGUAGEMANAGER->getValue("HandleDisconnected"));
+		}
+		else if (data.cmd == "KEY7" && isConnectSos) {
+			Json::Value frame = getFrame();
+			sendDataRemindOhter(frame["full_name"].asString() + " " + LANGUAGEMANAGER->getValue("SosDisconnected"));
 		}
 	}
+
+
+
+//	if(UartContext::Uart3IsOpen()) {	// 如果是true,表示串口打开了
+//		string heartStr;
+//
+//		if (data.cmd == "KEY5") {	// key5是面板拨号按钮
+//			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("KEY5");
+//					return;
+//				}
+//				else {
+//					voip::CallInfo info = GetTelephone()->GetCallInfo();
+//					//拨打 或 挂断
+//					if (CallingStatus::instance()->busy()){
+//						callActivityFinish(CallFinishType::A1CLICK);
+//					} else {
+//						Intent* intent = new Intent();
+//						intent->putExtra(callActivityType, "fromCall");
+//						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;
+//					}
+//				}
+//
+//				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()){
+//						callActivityFinish(CallFinishType::KEY6_CLICK);
+//					} else {
+//						Intent* intent = new Intent();
+//						intent->putExtra(callActivityType, "fromCall");
+//						EASYUICONTEXT->openActivity("callActivity", intent);
+//					}
+//				}
+//			}
+//			else if (data.state == "3") {
+//				LOGD("手柄在线");
+//				isConnectHandle = true;
+//			}
+//			else if (data.state == "4") {
+//				if (!isConnectHandle) {
+//					return;
+//				}
+//				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;
+//				}
+//				else {
+//					if (sosTimerRegistered) {
+//						isTriggerSos = true;
+//						mActivityPtr->registerUserTimer(SOS_TRIGGER_TIME_HANDLE, 5 * 1000);
+//					}
+//				}
+//			}
+//			else if (data.state == "1") {
+//				sosCall("");
+//			}
+//			else if (data.state == "3") {
+//				LOGD("紧急按钮在线");
+//				isConnectHandle = true;
+//			}
+//			else if (data.state == "4") {
+//				if (!isConnectHandle) {
+//					return;
+//				}
+//				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 {
+//					voip::CallInfo info = GetTelephone()->GetCallInfo();
+//					//拨打 或 挂断
+//					if (CallingStatus::instance()->busy()){
+//						callActivityFinish(CallFinishType::A1CLICK);
+//					} else {
+//						Intent* intent = new Intent();
+//						intent->putExtra(callActivityType, "fromCall");
+//						EASYUICONTEXT->openActivity("callActivity", intent);
+//					}
+//				}
+//			}
+//		}
+//		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 {
+//					voip::CallInfo info = GetTelephone()->GetCallInfo();
+//					//拨打 或 挂断
+//					if (CallingStatus::instance()->busy()){
+//						callActivityFinish(CallFinishType::A1CLICK);
+//
+//						lightControl("DOORLED", "000F");
+//					}
+//				}
+//			}
+//
+//		}
+//		else if (data.cmd == "KEY;"){	//下左4,白
+//			if (isSleep) {
+//				screenOn();
+//			}
+//			lightControl("DOORLED", "111F");
+//		}
+//		else {
+//			if (isSleep) {
+//				screenOn();
+//			}
+////				lightControl("DOORLED", "000F");
+//		}
+//	}
 }
 
 /**
@@ -1121,16 +1445,6 @@ static bool onUI_Timer(int id){
 	    }
 	}
 		break;
-    case HANDLE_TRIGGER_TIME_HANDLE: {
-    	isTriggerHandle = false;
-    	return false;
-    }
-    	break;
-    case SOS_TRIGGER_TIME_HANDLE: {
-    	isTriggerSos = false;
-    	return false;
-    }
-    	break;
     case SIP_RECONNECT_TIME_HANDLE: {
     	removeSipCallStateListener();
     	removeSipRegisterStateListener();

+ 15 - 5
jni/logic/statusbar.cc

@@ -44,6 +44,9 @@
 
  */
 
+#define ETHERNETMANAGER		NETMANAGER->getEthernetManager()
+#define WIFIMANAGER			NETMANAGER->getWifiManager()
+
 static bool networkConnect = false;
 static bool networkNowConnect = false;
 static bool tcpConnect = false;
@@ -51,6 +54,16 @@ static bool tcpNowConnect = false;
 static bool sipConnect = true;
 static bool sipNowConnect = false;
 
+
+bool isConnectServer() {
+    if (ETHERNETMANAGER->isConnected() || WIFIMANAGER->isConnected()) {
+        if (tcpConnect) {
+            return true;
+        }
+    }
+    return false;
+}
+
 void statusLight() {
     if (!networkConnect) {
         lightControl("CALLLED", "200F");
@@ -71,9 +84,6 @@ void statusLight() {
 }
 
 
-#define ETHERNETMANAGER		NETMANAGER->getEthernetManager()
-#define WIFIMANAGER			NETMANAGER->getWifiManager()
-
 static bool isLight = false;
 static net::DhcpClient _s_wifi_dhcp_client;
 static net::DhcpClient _s_eth_dhcp_client;
@@ -184,7 +194,7 @@ static void updateNetState(){
 		mRestartTimeTextViewPtr->setText(restartTimeStr);
 	}
 
-	if (ETHERNETMANAGER->isConnected() || WIFIMANAGER->isConnected()){
+	if (isConnectServer()){
 		netOffCount = 0;
 		if (isDataRefresh) {
 			dataRefresh();
@@ -291,7 +301,7 @@ void addSipRegisterStateListener() {
 }
 
 void tcpStatus(){
-	if (TcpClient::instance()->connected()){
+	if (TcpClient::instance()->isConnect()){
 		mTextViewTCPPtr->setBackgroundColor(0xFF37C127);
 		tcpConnect = true;
         if (tcpNowConnect != tcpConnect) {

+ 26 - 0
jni/net/tcp_client.cpp

@@ -37,6 +37,8 @@ TcpClient* TcpClient::instance() {
 }
 
 static net::Conn* conn;
+static bool isTcpConnect = false;
+static int heartbeatTime = 0;
 
 void TcpClient::sendMsg(const char* msg){
 	instance()->internalSendMsg(msg);
@@ -122,15 +124,35 @@ public:
 			while (true && !exitPending()) {
 				//读取,超时1000毫秒
 				int n = conn->Read(buf, sizeof(buf) - 1, 1000);
+
+                heartbeatTime += 1;
+                if (heartbeatTime >= 90) {
+                    isTcpConnect = false;
+                    heartbeatTime = 0;
+                    LOGD("心跳超时断开");
+                    break;
+                }
 				if (n > 0) {
+					isTcpConnect = true;
 					buf[n] = 0;
+
+					LOGD("TCP received: %s", buf);
+					const char* cstr = reinterpret_cast<const char*>(buf);
+				    std::string str = cstr;
+				    if (str == "1"){
+				    	heartbeatTime = 0;
+						LOGD("get a heart beat");
+						continue;
+					}
 					handleMsg(buf);
 				} else if (n == 0) {
+					isTcpConnect = false;
 					LOGD("连接正常断开");
 					break;
 				} else if (n == net::E_TIMEOUT) {
 //					LOGD("读取超时");
 				} else {
+					isTcpConnect = false;
 					LOGD("出错");
 					break;
 				}
@@ -173,4 +195,8 @@ bool TcpClient::connected() {
 	return conn != NULL;
 }
 
+bool TcpClient::isConnect() {
+	return isTcpConnect;
+}
+
 

+ 1 - 0
jni/net/tcp_client.h

@@ -26,6 +26,7 @@ public:
   void sendMsgWithCb(const char* msg, TcpCallback callback);
 
   static bool connected();
+  static bool isConnect();
   static bool busy();
 private:
   TcpClient();

+ 1 - 1
jni/net/tcp_model.cpp

@@ -43,7 +43,7 @@ std::string getTcpModelString(TcpModel model){
 
 TcpModel getTcpModel(byte* inBytes){
 	//解析json
-	Json::Reader reader;
+	Json::Reader reader(Json::Features::strictMode());
 	Json::Value root;
 	TcpModel tcpModel;
 	const char* str = reinterpret_cast<const char*>(inBytes);

+ 1 - 0
jni/net/tcp_model.h

@@ -86,6 +86,7 @@ public:
 class DataAction {
 public:
 	inline static std::string REFRESH = "REFRESH";
+	inline static std::string REMIND_OTHER = "REMIND_OTHER";
 };
 
 class ReinforceAction {

+ 12 - 0
jni/net/tcp_util.cpp

@@ -250,3 +250,15 @@ void sendSosCancel(std::string sosId) {
 	sendTcpModel(tcpModel);
 }
 
+void sendDataRemindOhter(std::string msg) {
+	TcpModel tcpModel;
+	tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
+	tcpModel.type = TcpType::DATA;
+	tcpModel.action = DataAction::REMIND_OTHER;
+	tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID, 0);
+    tcpModel.to_id = 0;
+	tcpModel.data = msg;
+
+	sendTcpModel(tcpModel);
+}
+

+ 2 - 0
jni/net/tcp_util.h

@@ -34,5 +34,7 @@ void sendVoiceGainCall(std::string tid, Json::Value it);
 void sendSosCall(std::string sosMsg);
 void sendSosCancel(std::string sosId);
 
+void sendDataRemindOhter(std::string msg);
+
 
 #endif /* JNI_NET_TCP_UTIL_H_ */

+ 4 - 2
jni/service/BusinessConfig.h

@@ -80,8 +80,8 @@ static uint32_t whiteColour = 0xFFFFFFFF;
 static int defaultThemeInt = 1;
 static int defaultModeInt = 3;
 
-static std::string versionCode = "v2.0.15";
-static int versionNo = 62;
+static std::string versionCode = "v2.0.16";
+static int versionNo = 63;
 static std::string serverIP = "172.28.100.100";
 static std::string tcpIP = "172.28.100.100";
 static int serverHttpPort = 8006;
@@ -203,6 +203,8 @@ void systemRestart();
 void addGainCallData(Json::Value data);
 void deleteGainCallData(std::string id);
 
+bool isConnectServer();
+
 enum CallFinishType {
 	CANCEL,
 	REJECT,

+ 3 - 0
jni/uart/ProtocolSender.cpp

@@ -9,6 +9,9 @@
 #include "uart/UartContext.h"
 #include "utils/Log.h"
 #include <stdio.h>
+#include <string>
+#include <string.h>
+#include "service/BusinessConfig.h"
 
 extern BYTE getCheckSum(const BYTE *pData, int len);
 

二進制
libs/armeabi/libzkgui.so


二進制
obj/activity/callActivity.o


二進制
obj/activity/deviceInfoActivity.o


二進制
obj/activity/functionActivity.o


二進制
obj/activity/mainActivity.o


二進制
obj/activity/medicalCareActivity.o


二進制
obj/activity/moreActivity.o


二進制
obj/activity/navibar.o


二進制
obj/activity/promptActivity.o


二進制
obj/activity/settingActivity.o


二進制
obj/activity/sipTestActivity.o


二進制
obj/activity/startActivity.o


二進制
obj/activity/statusbar.o


二進制
obj/activity/updateActivity.o


二進制
obj/core/update_assistant.o


二進制
obj/net/tcp_client.o


二進制
obj/net/tcp_model.o


二進制
obj/net/tcp_util.o


二進制
obj/server/http_server.o


二進制
obj/service/BusinessConfig.o


二進制
obj/service/time.o


二進制
obj/uart/ProtocolSender.o


二進制
obj/uart/UartContext.o


二進制
resources/icon/sos.png


二進制
resources/sos4.MP3