Пример #1
0
        public void MessageReceiver(object sender, SPPMessage e)
        {
            BaseMessageParser parser = SPPMessageParserFactory.BuildParser(e);

            AnyMessageReceived?.Invoke(this, parser);
            switch (e.Id)
            {
            case SPPMessage.MessageIds.MSG_ID_RESET:
                ResetResponse?.Invoke(this, ((ResetResponseParser)parser).ResultCode);
                break;

            case SPPMessage.MessageIds.MSG_ID_FOTA_DEVICE_INFO_SW_VERSION:
                SwVersionResponse?.Invoke(this, ((SoftwareVersionOTAParser)parser).SoftwareVersion);
                break;

            case SPPMessage.MessageIds.MSG_ID_BATTERY_TYPE:
                BatteryTypeResponse?.Invoke(this, (BatteryTypeParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_AMBIENT_MODE_UPDATED:
                AmbientEnabledUpdateResponse?.Invoke(this, ((AmbientModeUpdateParser)parser).Enabled);
                break;

            case SPPMessage.MessageIds.MSG_ID_DEBUG_BUILD_INFO:
                BuildStringResponse?.Invoke(this, ((DebugBuildInfoParser)parser).BuildString);
                break;

            case SPPMessage.MessageIds.MSG_ID_DEBUG_GET_ALL_DATA:
                GetAllDataResponse?.Invoke(this, (DebugGetAllDataParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_DEBUG_SERIAL_NUMBER:
                SerialNumberResponse?.Invoke(this, (DebugSerialNumberParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_EXTENDED_STATUS_UPDATED:
                ExtendedStatusUpdate?.Invoke(this, (ExtendedStatusUpdateParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_FIND_MY_EARBUDS_STOP:
                FindMyGearStopped?.Invoke(this, null);
                break;

            case SPPMessage.MessageIds.MSG_ID_RESP:
                GenericResponse?.Invoke(this, (GenericResponseParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_SELF_TEST:
                SelfTestResponse?.Invoke(this, (SelfTestParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_SET_TOUCHPAD_OTHER_OPTION:
                OtherOption?.Invoke(this, ((SetOtherOptionParser)parser).OptionType);
                break;

            case SPPMessage.MessageIds.MSG_ID_STATUS_UPDATED:
                StatusUpdate?.Invoke(this, (StatusUpdateParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_USAGE_REPORT:
                UsageReport?.Invoke(this, (UsageReportParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_MUTE_EARBUD_STATUS_UPDATED:
                FindMyGearMuteUpdate?.Invoke(this, (MuteUpdateParser)parser);
                break;

            case SPPMessage.MessageIds.MSG_ID_ANC_STATUS_UPDATED:
                NoiseCancellingUpdated?.Invoke(this, ((NoiseCancellingUpdatedParser)parser).Enabled);
                break;
            }
        }
Пример #2
0
        public void DispatchEvent(BaseMessageParser?parser, SPPMessage.MessageIds?ids = null)
        {
            AnyMessageReceived?.Invoke(this, parser);
            switch (ids ?? parser?.HandledType ?? 0)
            {
            case SPPMessage.MessageIds.RESET:
                ResetResponse?.Invoke(this, (parser as ResetResponseParser)?.ResultCode ?? -1);
                break;

            case SPPMessage.MessageIds.FOTA_DEVICE_INFO_SW_VERSION:
                SwVersionResponse?.Invoke(this, (parser as SoftwareVersionOTAParser)?.SoftwareVersion ?? "null");
                break;

            case SPPMessage.MessageIds.BATTERY_TYPE:
                BatteryTypeResponse?.Invoke(this, (parser as BatteryTypeParser) !);
                break;

            case SPPMessage.MessageIds.AMBIENT_MODE_UPDATED:
                AmbientEnabledUpdateResponse?.Invoke(this, (parser as AmbientModeUpdateParser)?.Enabled ?? false);
                break;

            case SPPMessage.MessageIds.DEBUG_BUILD_INFO:
                BuildStringResponse?.Invoke(this, (parser as DebugBuildInfoParser)?.BuildString ?? "null");
                break;

            case SPPMessage.MessageIds.DEBUG_GET_ALL_DATA:
                GetAllDataResponse?.Invoke(this, (parser as DebugGetAllDataParser) !);
                break;

            case SPPMessage.MessageIds.DEBUG_SERIAL_NUMBER:
                SerialNumberResponse?.Invoke(this, (parser as DebugSerialNumberParser) !);
                break;

            case SPPMessage.MessageIds.EXTENDED_STATUS_UPDATED:
                BaseUpdate?.Invoke(this, (parser as IBasicStatusUpdate) !);
                ExtendedStatusUpdate?.Invoke(this, (parser as ExtendedStatusUpdateParser) !);
                break;

            case SPPMessage.MessageIds.FIND_MY_EARBUDS_STOP:
                FindMyGearStopped?.Invoke(this, EventArgs.Empty);
                break;

            case SPPMessage.MessageIds.RESP:
                GenericResponse?.Invoke(this, (parser as GenericResponseParser) !);
                break;

            case SPPMessage.MessageIds.SELF_TEST:
                SelfTestResponse?.Invoke(this, (parser as SelfTestParser) !);
                break;

            case SPPMessage.MessageIds.SET_TOUCHPAD_OTHER_OPTION:
                OtherOption?.Invoke(this, (parser as SetOtherOptionParser) !.OptionType);
                break;

            case SPPMessage.MessageIds.STATUS_UPDATED:
                StatusUpdate?.Invoke(this, (parser as StatusUpdateParser) !);
                BaseUpdate?.Invoke(this, (parser as IBasicStatusUpdate) !);
                break;

            case SPPMessage.MessageIds.USAGE_REPORT:
                UsageReport?.Invoke(this, (parser as UsageReportParser) !);
                break;

            case SPPMessage.MessageIds.MUTE_EARBUD_STATUS_UPDATED:
                FindMyGearMuteUpdate?.Invoke(this, (parser as MuteUpdateParser) !);
                break;

            case SPPMessage.MessageIds.NOISE_REDUCTION_MODE_UPDATE:
                AncEnabledUpdateResponse?.Invoke(this,
                                                 (parser as NoiseReductionModeUpdateParser)?.Enabled ?? false);
                break;

            case SPPMessage.MessageIds.NOISE_CONTROLS_UPDATE:
                NoiseControlUpdateResponse?.Invoke(this,
                                                   (parser as NoiseControlUpdateParser)?.Mode ?? NoiseControlMode.Off);
                break;
            }
        }