public void PeripheralReceiveMessage(string UUID, byte[] bytes)
    {
        MyDebug.LogGreen("PeripheralReceiveMessage");
        BluetoothMessage msg = new BluetoothMessage(bytes);

        if (msg == null)
        {
            MyDebug.LogYellow("PeripheralReceiveMessage: Message is NULL!");
            return;
        }

        MyDebug.LogGreen("Index:" + msg.index + ", Result:" + msg.result + ", name:" + msg.name);

        if (msg.index == 0)
        {
            UnityEngine.Random.InitState(msg.result);
            CurPeripheralInstance = new PeripheralInstance("", msg.name);
            SetSendMessageFunc(false);
            BLESendMessage(msg);
            GuiController.Instance.CompetitionGUI = GuiFrameID.BluetoothFrame;
            GuiController.Instance.SwitchWrapper(GuiFrameID.BluetoothFightFrame);
        }
        else
        {
            if (BLEReceiveMessage != null)
            {
                BLEReceiveMessage(msg);
            }
        }
    }
Example #2
0
    protected override void InitPrefabItem(object data)
    {
        content = data as PeripheralInstance;
        if (content == null)
        {
            MyDebug.LogYellow("BluetoothInstance is null!!");
            return;
        }

        Init();
        receiveReadID         = false;
        receiveWriteID        = false;
        periphralName.text    = content.name;
        periphralAddress.text = content.address;
    }