コード例 #1
0
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--


        #endregion

        #region --Misc Methods (Private)--


        #endregion

        #region --Misc Methods (Protected)--


        #endregion
        //--------------------------------------------------------Events:---------------------------------------------------------------------\\
        #region --Events--
        private void CACHE_CharacteristicChanged(OnewheelCharacteristicsCache sender, CharacteristicChangedEventArgs args)
        {
            if (args.UUID.Equals(OnewheelCharacteristicsCache.CHARACTERISTIC_CUSTOM_NAME))
            {
                BoardName = OnewheelCharacteristicsCache.GetString(args.NEW_VALUE);
            }
            else if (args.UUID.Equals(OnewheelCharacteristicsCache.CHARACTERISTIC_BATTERY_LEVEL))
            {
                BatteryLevel = (int)OnewheelCharacteristicsCache.GetUint(args.NEW_VALUE);
            }
        }
コード例 #2
0
 private async void CACHE_CharacteristicChanged(OnewheelCharacteristicsCache sender, OnewheelBluetooth.Classes.Events.CharacteristicChangedEventArgs args)
 {
     // Battery:
     if (args.UUID.Equals(OnewheelCharacteristicsCache.CHARACTERISTIC_BATTERY_CELL_VOLTAGES))
     {
         await ShowCellVoltagesAsync();
     }
     // Firmware:
     else if (args.UUID.Equals(OnewheelCharacteristicsCache.CHARACTERISTIC_FIRMWARE_REVISION))
     {
         await ShowFirmwareRevisionAsync();
     }
     // Hardware:
     else if (args.UUID.Equals(OnewheelCharacteristicsCache.CHARACTERISTIC_HARDWARE_REVISION))
     {
         await ShowHardwareRevisionAsync();
     }
 }
コード例 #3
0
        //--------------------------------------------------------Events:---------------------------------------------------------------------\\
        #region --Events--
        private async void CACHE_CharacteristicChanged(OnewheelCharacteristicsCache sender, Events.CharacteristicChangedEventArgs args)
        {
            if (args.UUID.Equals(OnewheelCharacteristicsCache.CHARACTERISTIC_UART_SERIAL_READ) && !(args.NEW_VALUE is null) && args.NEW_VALUE.Length > 0)
            {
                // Reverse back the byte order because we need the raw date send by the board:
                Utils.ReverseByteOrderIfNeeded(args.NEW_VALUE);

                AddSerialReadDataToCache(args.NEW_VALUE);
                if (unlock.CheckIfFirstChallengeBytesMatch(SERIAL_READ_CACHE) && SERIAL_READ_CACHE.Count == 20)
                {
                    await unlock.CalcAndSendResponseAsync(SERIAL_READ_CACHE, ONEWHEEL);

                    await ONEWHEEL.UnsubscribeFromCharacteristicAsync(OnewheelCharacteristicsCache.CHARACTERISTIC_UART_SERIAL_READ);

                    await ONEWHEEL.SubscribeToCharacteristicsAsync(OnewheelCharacteristicsCache.SUBSCRIBE_TO_CHARACTERISTICS);

                    // Send the Gemini firmware revision every UNLOCK_PERIOD to keep the board unlocked:
                    StartUnlockTimer();
                    OnewheelConnectionHelper.INSTANCE.CACHE.CharacteristicChanged -= CACHE_CharacteristicChanged;
                }
            }
        }