Forráskód Böngészése

添加日志提示

slambb 10 hónapja
szülő
commit
ab155e749a

+ 1 - 0
Assets/BowArrow/Resources/Textures/GameIcon/Prefabs/Views/Home/HomeView.prefab

@@ -4321,6 +4321,7 @@ MonoBehaviour:
   titleImage: {fileID: 7715748591454465399}
   cnTitleSprite: {fileID: 21300000, guid: 6340bf22d55fccf40b0dbfffac139134, type: 3}
   enTitleSprite: {fileID: 21300000, guid: cac406f692a3cd94f9c38d68077a42a7, type: 3}
+  IconConnect: {fileID: 6420294424194915235}
 --- !u!1 &3405687114444825116
 GameObject:
   m_ObjectHideFlags: 0

+ 1 - 1
Assets/BowArrow/Scenes/Entry.unity

@@ -510,7 +510,7 @@ MonoBehaviour:
   IsAutoOpen: 1
   OpenMethod: 2
   ReadProtocol: 1
-  BaudRate: 460800
+  BaudRate: 115200
   Parity: 0
   StopBit: 0
   DataBit: 8

+ 43 - 2
Assets/BowArrow/Scripts/ArrowSerialPort.cs

@@ -7,9 +7,9 @@ public class ArrowSerialPort : MonoBehaviour
 {
     private SerialPortUtilityPro serialPortUtility;
     private SerialPortUtilityPro.OpenSystem openMode = SerialPortUtilityPro.OpenSystem.PCI;
-    //private int baudrate = 115200;
+    private int baudrate = 115200;
     //private int baudrate = 921600;
-    private int baudrate = 460800;
+    //private int baudrate = 460800;
     private string PortName = "/dev/ttyS0";
     private static Dictionary<string, int> _isInit = new();
     public bool testMode = true;
@@ -147,7 +147,23 @@ public class ArrowSerialPort : MonoBehaviour
                     OnDeviceInfoBack(bytes);
                     break;
                 case 0x81://射击消息
+                    if (CommonConfig.bDisableBluetooth) {
+                        // 获取当前时间
+                        DateTime currentTime1 = DateTime.Now;
+                        // 打印带毫秒的时间戳
+                        Debug.Log("CurrentTime1:" + currentTime1 + ",format: " + currentTime1.ToString("yyyy-MM-dd HH:mm:ss.fff"));
+                    }
+
                     OnDeviceShoot(bytes);
+
+                    if (CommonConfig.bDisableBluetooth) {
+                        //3 - APP在收到射箭消息后,立即回复相同的内容给设备端;
+                        serialPortUtility?.Write(bytes);
+                        // 获取当前时间
+                        DateTime currentTime2 = DateTime.Now;
+                        // 打印带毫秒的时间戳
+                        Debug.Log("CurrentTime2:" + currentTime2 + ",format: " + currentTime2.ToString("yyyy-MM-dd HH:mm:ss.fff"));
+                    }
                     break;
                 case 0x82://按键消息
                     OnDeviceButton(bytes);
@@ -160,6 +176,31 @@ public class ArrowSerialPort : MonoBehaviour
                     break;
             }
         }
+        else 
+        {
+            if (CommonConfig.bDisableBluetooth) {
+                //byte[] bytes = new byte[] { 0x0A, 0x00, 0x00, 0x00, // 1st timestamp
+                //                           0x0B, 0x00, 0x00, 0x00, // 2nd timestamp
+                //                           0x00, 0x01, 0x00, 0x00  // 3rd timestamp
+                //};
+                if (bytes.Length == 12)
+                {
+                    // 解析并转换时间戳
+                    for (int i = 0; i < bytes.Length; i += 4)
+                    {
+                        // 提取 4 字节的时间戳
+                        uint timestamp = BitConverter.ToUInt32(bytes, i);
+
+                        // 转换为毫秒(单位是 100us)
+                        float timeInMilliseconds = timestamp * 0.1f;
+
+                        // 打印转换结果
+                        Debug.Log($"Timestamp (U32): {timestamp} => Time: {timeInMilliseconds} ms");
+                    }
+                }
+            }
+            
+        }
     }
 
     bool lightWaitClose = false;

+ 8 - 4
Assets/BowArrow/Scripts/Bluetooth/DevicesHolder.cs

@@ -49,10 +49,14 @@ public class DevicesHolder : MonoBehaviour
     /// <param name="deviceType"></param>
     public void SwitchDeviceByType(AimDeviceType deviceType) {
         bConnected = true;
-        //打开图标
-        SimulateMouseController.ins?.SetBleConnected(true);
-        //打靶和打猎需要设置为false
-        BowCamera.isTouchMode = false;
+        //去除蓝牙连接之后才设置这里
+        if (CommonConfig.bDisableBluetooth) {
+            //打开图标
+            SimulateMouseController.ins?.SetBleConnected(true);
+            //打靶和打猎需要设置为false
+            BowCamera.isTouchMode = false;
+        }
+   
         //切换后算连接成功
         PopupMgr.ins.ClearAllTip();
 

+ 5 - 0
Assets/BowArrow/Scripts/View/BScript/LayoutManager.cs

@@ -13,6 +13,7 @@ public class LayoutManager : MonoBehaviour
     public Sprite cnTitleSprite;
     public Sprite enTitleSprite;
 
+    public GameObject IconConnect;
     void Start()
     {
         // ´¦ÀíÓïÑԱ仯µÄÂß¼­
@@ -27,6 +28,10 @@ public class LayoutManager : MonoBehaviour
             titleImage.SetNativeSize();
         }
         TextAutoLanguage2.OnLanguageChanged += HandleLanguageChange;
+
+        if (!CommonConfig.bDisableBluetooth) {
+            IconConnect.SetActive(true);
+        }
     }
 
     void OnDestroy() {