Sfoglia il codice sorgente

添加新蓝牙流程CMD连接扫描

slambb 2 settimane fa
parent
commit
ae719acf7d

BIN
Assets/AddressableAssetsData/Android/addressables_content_state.bin


+ 18 - 0
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -227,6 +227,24 @@ public class AimDeviceInfos
             }
         }
     }
+    /// <summary>
+    /// 寻找对应的AimDeviceInfo
+    /// </summary>
+    /// <param name="player"></param>
+    /// <returns></returns>
+    public AimDeviceInfo GetAimDeviceInfo(BluetoothPlayer player)
+    {
+        foreach (AimDeviceInfo p in AimHandler.ins.aimDeviceInfos.arry)
+        {
+            if ((int)player == p.id)
+            {
+                return p;
+            }
+        }
+        // 如果没找到设备,可以返回 null 或者抛异常
+        Debug.LogWarning($"未找到 {player} 的 AimDeviceInfo");
+        return null;
+    }
 
     #region 根据设备1p或者2p 获取HOUYIPRO的状态
     public bool isHOUYIPRO(BluetoothPlayer bluetoothPlayer)

+ 333 - 18
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -8,6 +8,8 @@ using SmartBowSDK;
 using System.Collections;
 using UnityEngine.SceneManagement;
 using BleWinHelper = SmartBowSDK_BleWinHelper.BleWinHelper;
+using SmartBowSDK.CMD;
+using System.Linq;
 
 /* 蓝牙瞄准模块 */
 /* 管理1p和2p蓝牙连接,脚本外调用逻辑如果同时连接1p和2p设备,以前的逻辑还是以1p为主,如果只连2p,则使用2p数据*/
@@ -100,6 +102,18 @@ public class BluetoothAim : MonoBehaviour
 
     //首页初始化时候调用一次连接
     public bool bStartConnect = false;
+    private void Awake()
+    {
+#if UNITY_ANDROID
+        if (CommonConfig.bUseCMD)
+        {
+            SmartBowLogger.isDebug = true;
+            this.isUseCompanionDeviceManager = true;
+            InitCMDManager();
+        }
+
+#endif
+    }
     void Start()
     {
         ins = this;
@@ -120,7 +134,6 @@ public class BluetoothAim : MonoBehaviour
             BleWinHelper.RegisterTo(gameObject, firstBluetoothWindows, "1P");
         }
 #endif
-
     }
 
     void OnDestroy()
@@ -128,6 +141,9 @@ public class BluetoothAim : MonoBehaviour
         //删除ble。1p,2p 都删除
         DisconnectBleHelper();
         DisconnectSmartBowHelper2P();
+
+        if (CommonConfig.bUseCMD)
+            ClearCMDManager();
     }
 
     /// <summary>
@@ -201,6 +217,11 @@ public class BluetoothAim : MonoBehaviour
         BowCamera.isTouchMode = true;
         DestroyWhenDisconenct();
         if (AimHandler.ins) AimHandler.ins.SetMsOldDefault();
+
+        if (isUseCompanionDeviceManager)
+        {
+            cmdManager.Disconnect();
+        }
     }
 
     float notUserDoConnectTime = 0;
@@ -296,7 +317,14 @@ public class BluetoothAim : MonoBehaviour
         //ConnectBleByUDP();
         firstBluetoothWindows.Connect();
 #else
-        ConnectBleHelper();
+        if(isUseCompanionDeviceManager)
+        {
+            ConnectCMD();
+        }else
+        {
+            ConnectBleHelper();
+        }
+   
 #endif
     }
 
@@ -415,24 +443,25 @@ public class BluetoothAim : MonoBehaviour
                 }
                 foreach (BluetoothDevice device in nearbyDevices)
                 {
-                    Log("发现设备 " + device.DeviceName);                   
-                    if (AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.HOUYIPRO)
+                    int firstPlayerType = AimHandler.ins.GetAimDeviceInfo(BluetoothPlayer.FIRST_PLAYER).type;
+                    Log("发现设备:" + device.DeviceName + ",设备类型:"+ firstPlayerType);
+                    if (firstPlayerType == (int)AimDeviceType.HOUYIPRO)
                     {   //需要判断是否是红外弓箭
                         if (TryConnectDevice(targetDeviceNameHOUYIPro, device.DeviceName, "HOUYIPRO")) return;
                     }
-                    else if (AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.ARTEMISPRO)
+                    else if (firstPlayerType == (int)AimDeviceType.ARTEMISPRO)
                     {   //需要判断是否是ARTEMISPro弓箭
                         if (TryConnectDevice(targetDeviceNameARTEMISPro, device.DeviceName, "ARTEMISPRO")) return;
                     }
-                    else if (AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.Gun)
+                    else if (firstPlayerType == (int)AimDeviceType.Gun)
                     {
                         if (TryConnectDevice(targetDeviceNameGun, device.DeviceName, "Pistol")) return;
                     }
-                    else if (AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.PistolM17)
+                    else if (firstPlayerType == (int)AimDeviceType.PistolM17)
                     {
                         if (TryConnectDevice(targetDeviceNameGun_M17, device.DeviceName, "PistolM17")) return;
                     }
-                    else if (AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.RifleM416)
+                    else if (firstPlayerType == (int)AimDeviceType.RifleM416)
                     {
                         if (TryConnectDevice(targetDeviceNameGun_M416, device.DeviceName, "RifleM416")) return;
                     }
@@ -819,6 +848,11 @@ public class BluetoothAim : MonoBehaviour
 
     public void WriteData(string data)
     {
+        if (isUseCompanionDeviceManager)
+        {
+            cmdManager.WriteString(data);
+            return;
+        }
         //Debug.Log("WriteData:" + data);
 #if UNITY_STANDALONE_WIN || UNITY_EDITOR
         //BleUDP.ins.SendMsg(data);
@@ -829,9 +863,15 @@ public class BluetoothAim : MonoBehaviour
         ch.setService(bluetoothService.getName());
         bluetoothHelper.WriteCharacteristic(ch, data);
 #endif
+
     }
     public void WriteByteData(byte[] data)
     {
+        if (isUseCompanionDeviceManager)
+        {
+            cmdManager.WriteBytes(data);
+            return;
+        }
 #if UNITY_STANDALONE_WIN || UNITY_EDITOR
         firstBluetoothWindows.WriteByte(data);
 #else
@@ -858,12 +898,13 @@ public class BluetoothAim : MonoBehaviour
         {
             SideTipView.ShowTip("Mac获取成功:" + mac, Color.white);
             //需要增加一个判断,判断是否对应的mac设备。不是需要进行重新连接
-            if (!AimHandler.ins.aimDeviceInfo.bInitMac)
+            AimDeviceInfo firstPlayer = AimHandler.ins.GetAimDeviceInfo(BluetoothPlayer.FIRST_PLAYER);
+            if (!firstPlayer.bInitMac)
             {
                 Debug.Log("设置设备mac:" + mac);
                 AimHandler.ins.SetAimDeviceMac(mac);
             }
-            else if (AimHandler.ins.aimDeviceInfo.mac != mac)
+            else if (firstPlayer.mac != mac)
             {
                 Debug.Log("设备不一样,断开连接");
                 DoConnect();
@@ -935,7 +976,19 @@ public class BluetoothAim : MonoBehaviour
     {
 
         smartBowHelper2P = SmartBowHelper.NewInstance();
-        smartBowHelper2P.SetFilters(targetDeviceName2P);
+#if UNITY_ANDROID
+        if (CommonConfig.bUseCMD)
+        {
+            //使用CMD API连接,这个只支持Android
+            smartBowHelper2P.UseCompanionDeviceManager(true);
+        }
+#endif
+        if (isUseCompanionDeviceManager) {
+            smartBowHelper2P.SetFilters(ToRegex(targetDeviceName2P));
+        } else {
+            smartBowHelper2P.SetFilters(targetDeviceName2P);
+        }
+    
 
         smartBowHelper2P.OnBluetoothModuleInited += () =>
         {
@@ -943,12 +996,13 @@ public class BluetoothAim : MonoBehaviour
             //判断是否是同一个mac
             //需要增加一个判断,判断是否对应的mac设备。不是需要进行重新连接
             string mac = smartBowHelper2P.GetMacAddress();
-            if (!AimHandler.ins.aimDeviceInfo.bInitMac)
+            AimDeviceInfo secondPlayer = AimHandler.ins.GetAimDeviceInfo(BluetoothPlayer.SECOND_PLAYER);
+            if (!secondPlayer.bInitMac)
             {
                 Debug.Log("smartBowHelper2P 设置设备mac:" + mac);
                 AimHandler.ins.SetAimDeviceMac(mac);
             }
-            else if (AimHandler.ins.aimDeviceInfo.mac != mac)
+            else if (secondPlayer.mac != mac)
             {
                 Debug.Log("设备不一样,断开连接");
                 DoConnect2P();
@@ -971,6 +1025,14 @@ public class BluetoothAim : MonoBehaviour
 
             //}
         };
+        smartBowHelper2P.OnCMDState += (state, message) =>
+        {
+            userDoConnect2P = false;
+            doConnect2P = false;
+            canConnect2P = true;
+            DisconnectSmartBowHelper2P();
+            PopupMgr.ins.ShowTip(message);
+        };
         smartBowHelper2P.OnBluetoothError += (error, message) =>
         {
             Debug.Log("smartBowHelper2P error:" + error);
@@ -1284,7 +1346,7 @@ public class BluetoothAim : MonoBehaviour
     {
 
         // status != BluetoothStatusEnum.ConnectSuccess
-        Debug.LogWarning("onCancelAllConnecting 1:" + status);
+        //Debug.LogWarning("onCancelAllConnecting 1:" + status);
 #if UNITY_STANDALONE_WIN || UNITY_EDITOR
 
         //BleUDP.ins != null 
@@ -1298,12 +1360,13 @@ public class BluetoothAim : MonoBehaviour
             // BleUDP.ins.Disconnect();
             firstBluetoothWindows.Disconnect();
             SetStatus(_bluetoothStatus);
-            Debug.LogWarning("onCancelAllConnecting 3:" + status);
+            //Debug.LogWarning("onCancelAllConnecting 3:" + status);
         }
 #else
-        if (bluetoothHelper != null && status == BluetoothStatusEnum.Connecting)
+        //bluetoothHelper != null && 
+        if (status == BluetoothStatusEnum.Connecting)
         {
-            Debug.LogWarning("onCancelAllConnecting 2:" + status);
+            //Debug.LogWarning("onCancelAllConnecting 2:" + status);
             userDoConnect = false;
             doConnect = false;
             OnDisconnect(); 
@@ -1520,7 +1583,6 @@ public class BluetoothAim : MonoBehaviour
         }
     }
 
-
     #region 用户1 window ble 连接和部分共用代码
     void OnConnected_windows1()
     {
@@ -1683,4 +1745,257 @@ public class BluetoothAim : MonoBehaviour
         PlayerPrefs.Save();
     }
     #endregion
+
+
+
+
+    #region 使用CompanionDeviceManager API 管理连接
+
+    public bool isUseCompanionDeviceManager { get; set; } = false;//默认用原本蓝牙扫描连接
+
+    private CMDManager cmdManager;
+    private bool isCMDScanning = false;
+    private string CmdName = "";
+    private string CmdMac = "";
+
+    /// <summary>
+    /// 初始化 CompanionDeviceManager 连接
+    /// </summary>
+    public void InitCMDManager()
+    {
+        if (cmdManager != null) return;
+
+        cmdManager = new CMDManager();
+        cmdManager.SetUUIDs(targetDeviceService, targetDeviceCharacteristicWrite, targetDeviceCharacteristicNotify);
+        cmdManager.OnCMDDeviceFound += OnCMDScanFound;
+        cmdManager.OnCMDScanFailed += OnCMDScanFailed;
+
+        cmdManager.OnCMDBLEConnected += OnCMDBLEConnected;
+        cmdManager.OnCMDBLEDisconnected += OnCMDBLEDisconnected;
+        cmdManager.OnCMDBLEReady += OnCMDBLEReady;
+        cmdManager.OnCMDBLENotify += OnCMDBLENotify;
+
+        cmdManager.OnPermissionDenied += OnCMDPermissionDenied;
+        cmdManager.OnPermissionDontAsk += OnCMDPermissionDontAsk;
+
+
+        SmartBowLogger.Log(this, "CMDManager 已初始化。");
+    }
+    /// <summary>
+    /// 清空 CompanionDeviceManager 信息
+    /// </summary>
+    public void ClearCMDManager()
+    {
+        if (cmdManager != null)
+        {
+            cmdManager.Cleanup();   // 调用 CMDManager 内部彻底清理方法
+
+            cmdManager.OnCMDDeviceFound -= OnCMDScanFound;
+            cmdManager.OnCMDScanFailed -= OnCMDScanFailed;
+
+            cmdManager.OnCMDBLEConnected -= OnCMDBLEConnected;
+            cmdManager.OnCMDBLEDisconnected -= OnCMDBLEDisconnected;
+            cmdManager.OnCMDBLEReady -= OnCMDBLEReady;
+            cmdManager.OnCMDBLENotify -= OnCMDBLENotify;
+
+            cmdManager.OnPermissionDenied -= OnCMDPermissionDenied;
+            cmdManager.OnPermissionDontAsk -= OnCMDPermissionDontAsk;
+            cmdManager = null;
+
+            SmartBowLogger.Log(this, "CMDManager 已清除。");
+        }
+    }
+
+    /// <summary>
+    /// 使用CompanionDeviceManager连接,仅是 Android 平台
+    /// </summary>
+    public void ConnectCMD()
+    {
+ 
+        if (isCMDScanning) return;
+        PopupMgr.ins.ClearAllTip();
+        if (Application.platform == RuntimePlatform.Android)
+        {
+            if (!BluetoothHelperAndroid_SDK.IsBluetoothEnabled())
+            {
+                HandleConnectException(TextAutoLanguage2.GetTextByKey("ble-exception1"));
+                return;
+            }
+        }
+        try
+        {
+            //_bluetoothHelper.ScanNearbyDevices();
+            //".*"
+            AimDeviceInfo firstPlayer = AimHandler.ins.GetAimDeviceInfo(BluetoothPlayer.FIRST_PLAYER);
+            if (firstPlayer.bInitMac)
+            {
+                SmartBowLogger.Log(this, $"CMD ConnectMac:{firstPlayer.mac}");
+                cmdManager.ConnectMac(FormatMacWithColon(firstPlayer.mac));
+            }
+            else
+            {
+                string regex = ToRegex(targetDeviceNameAxis);
+                int firstPlayerType = firstPlayer.type;
+                Log("1P设备类型:" + firstPlayerType);
+                if (firstPlayerType == (int)AimDeviceType.HOUYIPRO)
+                {   //需要判断是否是红外弓箭
+                    ToRegex(targetDeviceNameHOUYIPro);
+                }
+                else if (firstPlayerType == (int)AimDeviceType.ARTEMISPRO)
+                {   //需要判断是否是ARTEMISPro弓箭
+                    ToRegex(targetDeviceNameARTEMISPro);
+                }
+                else if (firstPlayerType == (int)AimDeviceType.Gun)
+                {
+                    ToRegex(targetDeviceNameGun);
+                }
+                else if (firstPlayerType == (int)AimDeviceType.PistolM17)
+                {
+                    ToRegex(targetDeviceNameGun_M17);
+                }
+                else if (firstPlayerType == (int)AimDeviceType.RifleM416)
+                {
+                    ToRegex(targetDeviceNameGun_M416);
+                }
+                SmartBowLogger.Log(this, $"CMD StartScan:{regex}");
+                cmdManager.StartScan(regex);
+            }
+            isCMDScanning = true;
+            SetStatus(BluetoothStatusEnum.Connecting);
+        }
+        catch (Exception e)
+        {
+            //HandleConnectError(BluetoothError.Unknown, e.ToString());
+            SetStatus(BluetoothStatusEnum.ConnectFail);
+        }
+    }
+    /// <summary>
+    /// 把 "A | B | C" 格式的设备名称转成正则 (A|B|C)
+    /// 自动去掉空格
+    /// </summary>
+    string ToRegex(string names)
+    {
+        if (string.IsNullOrEmpty(names))
+            return "";
+
+        var parts = names.Split('|');
+        for (int i = 0; i < parts.Length; i++)
+            parts[i] = parts[i].Trim(); // 去掉空格
+
+        return "(" + string.Join("|", parts) + ")";
+    }
+
+    /**
+     * mac.Where(c => Uri.IsHexDigit(c))遍历 mac 字符串中的每一个字符 c。
+     * Uri.IsHexDigit(c) 会判断这个字符是否是 16 进制数字(0-9、A-F、a-f)。
+     * 所以这一步会 过滤掉所有非 16 进制的字符,比如 -、:、空格等。
+     * string.Concat(...)
+     * 将过滤后的字符重新拼接成一个新的字符串。
+     * .ToUpper()
+     * 将整个字符串转成大写。
+     */
+    string FormatMacWithColon(string mac)
+    {
+        var hex = string.Concat(mac.Where(c => Uri.IsHexDigit(c))).ToUpper();
+        return string.Join(":", Enumerable.Range(0, hex.Length / 2)
+                                         .Select(i => hex.Substring(i * 2, 2)));
+    }
+
+
+    private void OnCMDScanFound(string name, string mac)
+    {
+        //MAC = D3:5C:89:57:68:DE
+        SmartBowLogger.Log(this, $"[SmartBow] CMD 扫描到设备 MAC = " + mac);
+        // 监听蓝牙准备就绪
+        CmdMac = mac;
+        CmdName = name;
+        //扫描之后也是这里直接连接
+        StartCoroutine(DelayConnect(FormatMacWithColon(CmdMac)));
+    }
+    private IEnumerator DelayConnect(string mac)
+    {
+        yield return new WaitForSeconds(0.3f);
+        cmdManager.ConnectMac(FormatMacWithColon(mac));
+    }
+    private void OnCMDScanFailed(CMDScanState state,string reason)
+    {
+        SmartBowLogger.Log(this, $"[SmartBow] CMD OnCMDScanFailed,"+ reason);
+        OnDisconnect();
+        isCMDScanning = false;
+        userDoConnect = false;
+        canConnect = true;
+        SetStatus(BluetoothStatusEnum.ConnectFail);
+
+        //if (_scanCanRetryCount > 0)
+        //{
+        //    _scanCanRetryCount--;
+        //    isCMDScanning = false;
+        //}
+        //else
+        //{
+        //    userDoConnect = false;
+        //    canConnect = true;
+        //    SetStatus(BluetoothStatusEnum.ConnectFail);
+        //}
+        //smartBowHelper.InvokeOnBluetoothError(BluetoothError.CMDScanError, reason);
+
+    }
+
+    private void OnCMDBLEDisconnected()
+    {
+        SmartBowLogger.Log(this, $"[SmartBow] CMD OnCMDBLEDisconnected.");
+        OnDisconnect();
+        isCMDScanning = false;
+    }
+    /// <summary>
+    /// 连接上准备好
+    /// </summary>
+    private void OnCMDBLEConnected()
+    {
+        SmartBowLogger.Log(this, $"[SmartBow] CMD OnCMDBLEConnected.");
+    }
+    /// <summary>
+    /// 获取到特征值时候触发
+    /// </summary>
+    private void OnCMDBLEReady()
+    {
+        Log("连接成功\n" + CmdName);
+        isCMDScanning = false;
+        SetStatus(BluetoothStatusEnum.ConnectSuccess);
+        SetMainConnectDeviceType();
+        BowCamera.isTouchMode = false;
+        if (CommonConfig.EnableDecryption && NeedDecryption)
+        {
+            // 这里验证指令,开始请求授权
+            // 启动轮询协程
+            StartCoroutine(PollingCoroutine());
+        }
+        else
+        {
+            SmartBowLogger.Log(this, $"InitWhenConenct:"+ status);
+            if (status != BluetoothStatusEnum.ConnectSuccess) return;
+            InitWhenConenct();
+        }
+    }
+
+    private void OnCMDBLENotify(byte[] value)
+    {
+        //long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); 
+        //SmartBowLogger.Log(this,$"[CMDBleManager→Unity] NotifyArrived: {BitConverter.ToString(value)} | t={now} | size={value.Length}");
+        OnCharacteristicChanged(null, value, null);
+    }
+
+    public void OnCMDPermissionDenied(string perm)
+    {
+        SmartBowLogger.LogError(this, $"[App] 用户拒绝权限:{perm}");
+
+        HandleConnectException(TextAutoLanguage2.GetTextByKey("CMDDenied"));
+    }
+    public void OnCMDPermissionDontAsk(string perm)
+    {
+        SmartBowLogger.LogError(this, $"[App] 用户永久拒绝权限:{perm}");
+        HandleConnectException(TextAutoLanguage2.GetTextByKey("CMDDontAsk"));
+    }
+
+    #endregion
 }

+ 1 - 1
Assets/BowArrow/Scripts/Bluetooth/BluetoothStatus.cs

@@ -101,5 +101,5 @@ public enum BluetoothStatusEnum
 
 public enum BluetoothPlayer { 
     FIRST_PLAYER,
-    SECONDE_PLAYER,
+    SECOND_PLAYER,
 }

+ 6 - 0
Assets/BowArrow/Scripts/CommonConfig.cs

@@ -188,6 +188,12 @@ public class CommonConfig
 
     //设置海外版的启动语言
     public static string startLanguageKey = "English";
+
+
+    /// <summary>
+    /// 是否启动CMD来连接蓝牙
+    /// </summary>
+    public static bool bUseCMD { get; } = true;
 }
 
 //打包App 的端

+ 3 - 0
Assets/BowArrow/Scripts/Components/TextAutoLanguage2/Resources/TextAutoLanguage2/Japan.json

@@ -260,6 +260,9 @@
   "ble-exception3": "デバイスへの接続許可がされていません。",
   "ble-dev-notfound": "対象デバイスが見つかりません。",
 
+  "CMDDenied": "ユーザーが権限を拒否しました",
+  "CMDDontAsk": "ユーザーが権限を完全に拒否しました",
+
   "MagInterferenceTip_content": "磁力計の初期化は周囲の環境の影響を受けやすいため、初期化中は次の手順を実行してください。\n1.初期化中は、金属物や磁場干渉のない安定した環境を維持してください。\n2.スマート弓矢モジュールを携帯電話やテレビなどの電子機器から 0.5 メートル以上離してください。\n3.モジュールを取り付けたスマート弓矢、または個々のモジュールを、初期化が完了するまで XYZ 軸に沿って完全に回転させます。\n4.初期化が複数回失敗した場合でも、引き続き使用できますが、照準精度に影響が出るため、ゲーム内でカメラの再配置操作を追加で実行する必要があります。",
   "MagInterferenceTip_ok": "確定",
 

+ 3 - 0
Assets/BowArrow/Scripts/Components/TextAutoLanguage2/Resources/TextAutoLanguage2/cn.json

@@ -254,6 +254,9 @@
   "ble-exception3": "未授予<连接附近的设备>权限",
   "ble-dev-notfound": "未发现目标设备",
 
+  "CMDDenied": "用户拒绝权限",
+  "CMDDontAsk": "用户永久拒绝权限",
+
   "MagInterferenceTip_content": "由于地磁计初始化易受到周围环境的影响,因此在初始化过程中请按照以下步骤来做:\n1、请在初始化过程中,保持周围环境的稳定,远离金属物体和磁场干扰。\n2、请保持智能弓箭模块和手机、电视等电子设备0.5米以上的距离。\n3、请将安装了模块的智能弓箭或单独模块沿着XYZ三轴进行充分地旋转,直到提示完成为止。\n4、如多次无法完成初始化,也可继续使用,只是瞄准的精度会受到影响,游戏中需多做一次视角归位的操作。",
   "MagInterferenceTip_ok": "确定",
 

+ 4 - 0
Assets/BowArrow/Scripts/Components/TextAutoLanguage2/Resources/TextAutoLanguage2/en.json

@@ -252,6 +252,10 @@
   "ble-exception3": "<Connect to nearby devices> permission not granted",
   "ble-dev-notfound": "Target device not found",
 
+  "CMDDenied": "User denied permission",
+  "CMDDontAsk": "User permanently denied permission",
+
+
   "MagInterferenceTip_content": "Since the initialization of the magnetometer is vulnerable to the influence of the surrounding environment, please follow the following steps in the initialization process: \n1. Please keep the surrounding environment stable and away from metal objects and magnetic field interference during the initialization process. \n2. Please keep a distance of more than 0.5m between the smart bow module and electronic devices such as mobile phones and televisions. \n3. Please fully rotate the smart bow or individual module with the module installed along the XYZ axis until the prompt is completed. \n4. If the initialization cannot be completed for many times, it can still be used. However, the accuracy of aiming will be affected, and the game needs to do one more angle of view homing operation.",
   "MagInterferenceTip_ok": "OK",
 

+ 3 - 3
Assets/BowArrow/Scripts/View/Home/DeviceView_ItemShow.cs

@@ -205,7 +205,7 @@ public class DeviceView_ItemShow : MonoBehaviour
                 }
 
             }
-            else if (bluetoothPlayer == BluetoothPlayer.SECONDE_PLAYER)
+            else if (bluetoothPlayer == BluetoothPlayer.SECOND_PLAYER)
             {
 
                 SmartBowSDK.SmartBowHelper smartBowHelper = BluetoothAim.ins.getSmartBowHelper2P();
@@ -381,7 +381,7 @@ public class DeviceView_ItemShow : MonoBehaviour
             curConnectStatus.text = TextAutoLanguage2.GetTextByKey(name) + omitText;
 
         }
-        else if (bluetoothPlayer == BluetoothPlayer.SECONDE_PLAYER)
+        else if (bluetoothPlayer == BluetoothPlayer.SECOND_PLAYER)
         {
             SmartBowSDK.SmartBowHelper smartBowHelper = BluetoothAim.ins.getSmartBowHelper2P();
             if (smartBowHelper == null) return;
@@ -434,7 +434,7 @@ public class DeviceView_ItemShow : MonoBehaviour
         if (bluetoothPlayer == BluetoothPlayer.FIRST_PLAYER) {
             return BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
         }
-        else if (bluetoothPlayer == BluetoothPlayer.SECONDE_PLAYER)
+        else if (bluetoothPlayer == BluetoothPlayer.SECOND_PLAYER)
         {
             SmartBowSDK.SmartBowHelper smartBowHelper = BluetoothAim.ins.getSmartBowHelper2P();
             if (smartBowHelper == null) return false;

+ 5 - 5
Assets/Plugins/Android/AndroidManifest.xml

@@ -51,13 +51,13 @@
 	</application>
 
 	<!-- THE BELOW REQUIRES ASKING FOR LOCATION PERMISSION AT RUNTIME -->
-	<uses-permission android:name="android.permission.BLUETOOTH"/>
-	<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
-	<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
-	<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+	<!--<uses-permission android:name="android.permission.BLUETOOTH"/> -->
+	<!--<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> -->
+	<!--<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> -->
+	<!--<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> -->
 	<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
 	<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
-	<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
+	<!--<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/> -->
 	<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
 	<uses-permission android:name="android.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND"/>
 	<uses-permission android:name="android.permission.REQUEST_COMPANION_USE_DATA_IN_BACKGROUND"/>

BIN
Assets/Plugins/Android/CMDAndBleManager-release.aar


+ 32 - 0
Assets/Plugins/Android/CMDAndBleManager-release.aar.meta

@@ -0,0 +1,32 @@
+fileFormatVersion: 2
+guid: dc517b88e4b0bdd43a17d84a0d2b1299
+PluginImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  iconMap: {}
+  executionOrder: {}
+  defineConstraints: []
+  isPreloaded: 0
+  isOverridable: 0
+  isExplicitlyReferenced: 0
+  validateReferences: 1
+  platformData:
+  - first:
+      Android: Android
+    second:
+      enabled: 1
+      settings: {}
+  - first:
+      Any: 
+    second:
+      enabled: 0
+      settings: {}
+  - first:
+      Editor: Editor
+    second:
+      enabled: 0
+      settings:
+        DefaultValueInitialized: true
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 3 - 3
Assets/SmartBow/Scripts/Views/ConnectGuidanceView.cs

@@ -113,7 +113,7 @@ public class ConnectGuidanceView : MonoBehaviour
                 }
             }
         }
-        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
         {
             if (bowStatus2P == SmartBowSDK.BluetoothStatusEnum.Connected)
             {
@@ -210,7 +210,7 @@ public class ConnectGuidanceView : MonoBehaviour
                 StopLoading();
             }
         }
-        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
         {
             SmartBowSDK.SmartBowHelper smartBowHelper = BluetoothAim.ins.getSmartBowHelper2P();
             if (smartBowHelper == null) return;
@@ -290,7 +290,7 @@ public class ConnectGuidanceView : MonoBehaviour
         {
             BluetoothAim.ins.DoConnect();
         }
-        else if(BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+        else if(BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
         {
             BluetoothAim.ins.DoConnect2P();
         }

+ 4 - 4
Assets/SmartBow/Scripts/Views/GyrGuidanceView.cs

@@ -23,7 +23,7 @@ public class GyrGuidanceView : MonoBehaviour
             {
                 ClickGyrCalibrate();
             }
-            else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+            else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
             {
                 ClickGyroCalibrate2P();
             }
@@ -43,7 +43,7 @@ public class GyrGuidanceView : MonoBehaviour
                 _TextAutoLanguage2.SetTextKey("Gyro_Reinitialize");
             }
         }
-        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
         {
             if (!BluetoothAim.ins.getSmartBowHelper2P().IsGyrCompleted())
             {
@@ -88,7 +88,7 @@ public class GyrGuidanceView : MonoBehaviour
             }
             UpdateForGyr();
         }
-        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER) {
+        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER) {
 
             if (BluetoothAim.ins.getSmartBowHelper2P().IsGyrCompleted() && !bGyrCompleted && flag_GyrCalibarateOperateAndFinish != 0)
             {
@@ -114,7 +114,7 @@ public class GyrGuidanceView : MonoBehaviour
                 ViewManager2.ShowView(ViewManager2.Path_MagGuidanceView);
             }
         }
-        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
         {
             if (BluetoothAim.ins.getSmartBowHelper2P().IsGyrCompleted() && !gyrCalibrating)
             {

+ 3 - 3
Assets/SmartBow/Scripts/Views/MagGuidanceView.cs

@@ -24,7 +24,7 @@ public class MagGuidanceView : MonoBehaviour
             {
                 ClickResetMag();
             }
-            else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+            else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
             {
                 ClickResetMag2P();
             }
@@ -44,7 +44,7 @@ public class MagGuidanceView : MonoBehaviour
                 _TextAutoLanguage2.SetTextKey("Mag_Initialization");
             }
         }
-        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
         {
             if (BluetoothAim.ins.getSmartBowHelper2P().IsMagCompleted())
             {
@@ -82,7 +82,7 @@ public class MagGuidanceView : MonoBehaviour
         {
             UpdateForMag();
         }
-        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECONDE_PLAYER)
+        else if (BluetoothAim.ins.getBLEPlayer() == BluetoothPlayer.SECOND_PLAYER)
         {
 
             UpdateForMag2P();

BIN
Assets/SmartBow/SmartBowSDK/SmartBowSDK.dll


+ 5 - 5
ProjectSettings/ProjectSettings.asset

@@ -13,7 +13,7 @@ PlayerSettings:
   useOnDemandResources: 0
   accelerometerFrequency: 60
   companyName: JssF
-  productName: WONDERFITTER
+  productName: "WONDERFITTER \u8FD0\u52A8"
   defaultCursor: {fileID: 0}
   cursorHotspot: {x: 0, y: 0}
   m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
@@ -137,7 +137,7 @@ PlayerSettings:
     16:10: 1
     16:9: 1
     Others: 1
-  bundleVersion: 2.3.5
+  bundleVersion: 2.3.6
   preloadedAssets:
   - {fileID: 11400000, guid: 8ecb9c5da30ac7d4db9243c684f470ea, type: 2}
   metroInputSource: 0
@@ -159,7 +159,7 @@ PlayerSettings:
   androidSupportedAspectRatio: 1
   androidMaxAspectRatio: 2.1
   applicationIdentifier:
-    Android: com.xmjssvr.BowArrowEn
+    Android: com.xmjssvr.BowArrow.mi
     Standalone: com.JssF.BowArrow
     iPhone: com.xmjssvr.BowArrow
   buildNumber:
@@ -169,7 +169,7 @@ PlayerSettings:
     tvOS: 0
   overrideDefaultApplicationIdentifier: 1
   AndroidBundleVersionCode: 13
-  AndroidMinSdkVersion: 23
+  AndroidMinSdkVersion: 26
   AndroidTargetSdkVersion: 33
   AndroidPreferredInstallLocation: 1
   aotOptions: 
@@ -280,7 +280,7 @@ PlayerSettings:
   - m_BuildTarget: 
     m_Icons:
     - serializedVersion: 2
-      m_Icon: {fileID: 2800000, guid: 5a86b450fbbf31f4d9269beac3ccd441, type: 3}
+      m_Icon: {fileID: 2800000, guid: e1485575cd9962247a6d7cc46fd6d6a9, type: 3}
       m_Width: 128
       m_Height: 128
       m_Kind: 0