Exemplo n.º 1
0
        private void btnTest_Clicked(object sender, EventArgs e)
        {
            GBGProtocol protocol = new GBGProtocol();
            List <byte> reqData  = protocol.AppToDevice_AirCheckTime(TwoByte.SetFromInt(0));

            DisplayAlert("Test", BitConverter.ToString(reqData.ToArray()).Replace("-", String.Empty), "OK !");
        }
Exemplo n.º 2
0
        //블루투스로 데이터 계속 옴
        private void Character_ValueUpdated(object sender, Plugin.BLE.Abstractions.EventArgs.CharacteristicUpdatedEventArgs e)
        {
            var         bytes    = e.Characteristic.Value;
            GBGProtocol protocol = new GBGProtocol();
            string      retData  = "";

            if (bytes.Length > 1)
            {
                recvData = protocol.DeviceToApp_ParseRecvData(bytes.ToList(), int.Parse(protocolVer.Text));
                JObject j = JObject.Parse(recvData);
                if (!j.HasValues)
                {
                    return;
                }

                Device.BeginInvokeOnMainThread(() =>
                {
                    lblRecvValue.Text = recvData;
                    if (j.HasValues)
                    {
                        if (j["type"] != null)
                        {
                            if (j["type"].ToString() == "KGAIR" && j["result"].ToString() == "SUCCESS")
                            {
                                if (j["subType"].ToString() == "PM25/PM10/VOC/CO2/TEMP/HUMI")
                                {
                                    /*
                                     * kgAirPage.SetJsonData(recvData);
                                     * if (!Navigation.NavigationStack.Contains(kgAirPage))
                                     * {
                                     *  Navigation.PushAsync(kgAirPage);
                                     * }
                                     */
                                    dgMain2.setAirValue(j.ToString());
                                }
                                else if (j["subType"].ToString() == "KG/LB/FAT/VFAT")
                                {
                                    dgMain.setFat(j["FAT"].ToString());
                                }
                                else if (j["subType"].ToString() == "WATER/MUSCLE")
                                {
                                    dgMain.setWater(j["WATER"].ToString());
                                    dgMain.setMuscle(j["MUSCLE"].ToString());
                                }
                                else if (j["subType"].ToString() == "BONE/KCAL/BMI")
                                {
                                    dgMain.setKcal(j["KCAL"].ToString());
                                    dgMain.setBone(j["BONE"].ToString());
                                }
                            }
                            else if (j["type"].ToString() == "ONLYKG" && j["result"].ToString() == "SUCCESS")
                            {
                                dgMain.setWeight(j["KG"].ToString());
                            }
                        }
                    }
                });
            }
        }