瀏覽代碼

新增433声光报警器测试,修改无网络时门灯未使用默认配置问题

weizhengliang 1 年之前
父節點
當前提交
f83d23b0c2

+ 19 - 0
android_door/src/main/h10_3128/java/com/wdkl/app/ncs/callingdoor/activity/AppTextActivity.kt

@@ -3,6 +3,7 @@ package com.wdkl.app.ncs.callingbed.activity
 import android.graphics.Color
 import android.hardware.Camera
 import android.os.Bundle
+import android.text.TextUtils
 import android.text.method.ScrollingMovementMethod
 import android.view.SurfaceHolder
 import android.view.View
@@ -26,6 +27,7 @@ import kotlinx.android.synthetic.main.test_lay.*
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
+import serialporttest.utils.SerialPortUtil433
 
 
 @Router(path = "/callingdoor/text")
@@ -174,6 +176,23 @@ class AppTextActivity :BaseActivity<QrCodeFragmentPresenter, TestLayBinding>(),
             }
 
         }
+
+        //声光报警器测试
+        btn_flash_on.setOnClickListener {
+            val mac = edit_flash_mac.text.toString()
+            if (!TextUtils.isEmpty(mac)) {
+                val cmd = "$" + mac + "RELAY0,1F#"
+                SerialPortUtil433.getInstance().send(cmd)
+            }
+        }
+
+        btn_flash_off.setOnClickListener {
+            val mac = edit_flash_mac.text.toString()
+            if (!TextUtils.isEmpty(mac)) {
+                val cmd = "$" + mac + "RELAY0,0F#"
+                SerialPortUtil433.getInstance().send(cmd)
+            }
+        }
     }
     private fun startTest() {
         is_startTest=true

+ 18 - 0
android_door/src/main/h10_3128/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -276,6 +276,14 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                 SerialPortHelper.setSosLight("0")
                 //默认门灯白色
                 //SerialPortHelper.setDoorLight(1, "111")
+
+                Constant.inNursing = SettingConfig.getInNursing(activity)
+                if (Constant.inNursing) {
+                    nursingInteId = SettingConfig.getNursingId(activity)
+                    enterNursing()
+                } else {
+                    DoorLightHelper.resetDoorLight()
+                }
             }
 
             //设置默认时区为中国标准时间
@@ -600,6 +608,11 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                     showMessage(R.string.data_empty)
                 }
             }
+
+            //test code
+            //SerialPortUtil433.getInstance().send("$" + "RELAY0,0F#")
+            //SerialPortUtil433.getInstance().send("$29RELAY0,0F#")
+            //SerialPortUtil433.getInstance().send("$13RELAY0,0F#")
         }
 
         //护理按钮
@@ -643,6 +656,11 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
         room_action_nurse.setOnClickListener {
             showMessage(R.string.enter_nursing_tips)
+
+            //test code
+            //SerialPortUtil433.getInstance().send("$" + "RELAY0,1F#")
+            //SerialPortUtil433.getInstance().send("$29RELAY0,1F#")
+            //SerialPortUtil433.getInstance().send("$13RELAY0,1F#")
         }
 
         //增援按钮

+ 1 - 0
android_door/src/main/h10_3128/java/com/wdkl/app/ncs/callingdoor/helper/SerialPortHelper.java

@@ -47,6 +47,7 @@ public class SerialPortHelper {
      * @param color 0 表示灯灭  非0表示灯的颜色
      */
     public static void setDoorLight(int data, String color) {
+        //$DOORLED,200F#
         //if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
             String command;
             if (data == 0 || color == null) {

+ 31 - 0
android_door/src/main/h10_3128/res/layout/test_lay.xml

@@ -139,6 +139,37 @@
                 android:layout_below="@id/btn_reset"
                 android:textSize="20sp"
                 android:text="IP:"/>
+
+            <EditText
+                android:id="@+id/edit_flash_mac"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/tv_ip"
+                android:layout_toRightOf="@id/camera_preview_surface"
+                android:layout_marginLeft="10dp"
+                android:textSize="24sp"
+                android:text="13"
+                android:textColor="@color/black"/>
+
+            <Button
+                android:id="@+id/btn_flash_on"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/tv_ip"
+                android:layout_toRightOf="@id/edit_flash_mac"
+                android:layout_marginLeft="20dp"
+                android:text="开启声光报警器"
+                android:textSize="28sp"/>
+
+            <Button
+                android:id="@+id/btn_flash_off"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/tv_ip"
+                android:layout_toRightOf="@id/btn_flash_on"
+                android:layout_marginLeft="20dp"
+                android:text="关闭声光报警器"
+                android:textSize="28sp"/>
         </RelativeLayout>
 
         <TextView

+ 3 - 0
app/src/main/code/com/wdkl/app/ncs/application/Application.kt

@@ -113,6 +113,9 @@ class Application : BaseApplication() {
         } else if ("mk_h10_w_a133_1_chile".equals(BuildConfig.APP_DEVICE_TYPE) || "mk_h10_a133_1".equals(BuildConfig.APP_DEVICE_TYPE)) {
             //志合A133主板
             SerialPortUtil.getInstance().openSerialPort("/dev/ttyS2")
+
+            //打开433串口0
+            SerialPortUtil433.getInstance().openSerialPort()
         }
 
         // 初始化 Toast 框架

+ 3 - 3
bedlib/src/main/java/serialporttest/utils/SerialPortUtil433.java

@@ -134,16 +134,16 @@ public class SerialPortUtil433 {
      *
      * @param command 要发送的数据
      */
-    private void send(String command) {
+    public void send(String command) {
         try {
             if (isOpenSerialPortUtil) {
                 byte[] sendData = command.getBytes();
                 outputStream.write(sendData);
-                Log.d("serialPort","==command==" + command);
+                Log.d(TAG,"==command==" + command);
             }
         } catch (IOException e) {
             e.printStackTrace();
-            Log.d("serialPort","==command==" + command);
+            Log.d(TAG,"==command==" + command);
         }
     }
 

+ 1 - 1
common/build.gradle

@@ -191,7 +191,7 @@ dependencies {
     compile files('libs/chinese2py.jar')
 
     //toast 框架
-    compile files('libs/Toaster-12.2.aar')
+    api(name: 'Toaster-12.2', ext: 'aar')
 
     /**
      * 二维码扫描