You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.2 KiB
82 lines
2.2 KiB
2 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using LitJson;
|
||
2 years ago
|
using System;
|
||
2 years ago
|
using JXSoft;
|
||
2 years ago
|
|
||
2 years ago
|
namespace DYData {
|
||
|
public struct BluetoothGatewayData:IResponse
|
||
2 years ago
|
{
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
public int v { get; set; }
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
public int mid { get; set; }
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
public int time { get; set; }
|
||
|
/// <summary>
|
||
|
/// 用时
|
||
|
/// </summary>
|
||
|
public string ip { get; set; }
|
||
|
/// <summary>
|
||
|
/// 地址
|
||
|
/// </summary>
|
||
|
public string mac { get; set; }
|
||
|
/// <summary>
|
||
|
/// 设备信息
|
||
|
/// </summary>
|
||
2 years ago
|
public List<List<object>> devices { get; set; }
|
||
|
|
||
|
private string exceptionMsg;
|
||
|
|
||
|
|
||
|
public string findDataByMac(string mac) {
|
||
|
foreach (List<object> deviceMsg in devices) {
|
||
|
if (mac.Equals(deviceMsg[1])) {
|
||
|
return deviceMsg[3].ToString();
|
||
|
}
|
||
|
}
|
||
|
return "no data";
|
||
|
}
|
||
2 years ago
|
|
||
|
public string toProtocolData()
|
||
|
{
|
||
2 years ago
|
string watchMac = "535708030130";
|
||
|
string counter_1Mac = "90380C3BEF1A";
|
||
|
string counter_2Mac = "90380C3C0416";
|
||
|
string result = "watch:" + findDataByMac(watchMac) + "\ncounter_1:" + findDataByMac(counter_1Mac) + "\ncounter_2:" + findDataByMac(counter_2Mac);
|
||
|
return result;
|
||
2 years ago
|
}
|
||
|
|
||
|
public bool trySetData(string protocolData)
|
||
|
{
|
||
2 years ago
|
try
|
||
|
{
|
||
2 years ago
|
BluetoothGatewayData blg = JsonMapper.ToObject<BluetoothGatewayData>(protocolData);
|
||
2 years ago
|
this.v = blg.v;
|
||
|
this.time = blg.time;
|
||
|
this.mid = blg.mid;
|
||
|
this.ip = blg.ip;
|
||
|
this.mac = blg.mac;
|
||
|
this.devices = blg.devices;
|
||
|
return true;
|
||
|
}
|
||
|
catch (Exception e) {
|
||
|
Debug.Log(e.ToString());
|
||
|
return false;
|
||
|
}
|
||
2 years ago
|
}
|
||
|
|
||
|
public string getException()
|
||
|
{
|
||
2 years ago
|
return exceptionMsg;
|
||
2 years ago
|
}
|
||
|
}
|
||
|
}
|