|
|
@@ -193,7 +193,10 @@ public class BluetoothAim : MonoBehaviour
|
|
|
};
|
|
|
bluetoothHelper.OnCharacteristicChanged += (helper, value, characteristic) =>
|
|
|
{
|
|
|
- if (!hasData) hasDataTime = JC.CS.Utility.GetTimestamp();
|
|
|
+ if (!hasData) {
|
|
|
+ hasDataTime = JC.CS.Utility.GetTimestamp();
|
|
|
+ UploadMacAddress(value);
|
|
|
+ }
|
|
|
hasData = true;
|
|
|
byte[] bytes = value;
|
|
|
// Log(String.Join(",", bytes));
|
|
|
@@ -264,7 +267,10 @@ public class BluetoothAim : MonoBehaviour
|
|
|
};
|
|
|
BleUDP.ins.OnCharacteristicChanged = (byte[] value) =>
|
|
|
{
|
|
|
- if (!hasData) hasDataTime = JC.CS.Utility.GetTimestamp();
|
|
|
+ if (!hasData) {
|
|
|
+ hasDataTime = JC.CS.Utility.GetTimestamp();
|
|
|
+ UploadMacAddress(value);
|
|
|
+ }
|
|
|
hasData = true;
|
|
|
byte[] bytes = value;
|
|
|
// Log(String.Join(",", bytes));
|
|
|
@@ -350,6 +356,7 @@ public class BluetoothAim : MonoBehaviour
|
|
|
{
|
|
|
canAutoDormancy = true;
|
|
|
List<string> cmds = new List<string>();
|
|
|
+ cmds.Add("M"); //获取Mac地址
|
|
|
cmds.Add("b"); //确保开启stm32
|
|
|
cmds.Add("b"); //获取初始电量
|
|
|
cmds.Add("1"); //开启发送逻辑
|
|
|
@@ -501,4 +508,16 @@ public class BluetoothAim : MonoBehaviour
|
|
|
textUI.text = text;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ void UploadMacAddress(byte[] bytes) {
|
|
|
+ if (hasData) return;
|
|
|
+ string str = System.Text.Encoding.ASCII.GetString (bytes);
|
|
|
+ if (str == null) return;
|
|
|
+ if (str.Contains(":")) {
|
|
|
+ if (!str.Equals(LoginMgr.myUserInfo.mac)) {
|
|
|
+ LoginMgr.myUserInfo.mac = str;
|
|
|
+ }
|
|
|
+ UserPlayer.ins.call("userComp.saveMac", str);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|