async void ProcessOnOpenCommandSessionComplete(IMbnDeviceService deviceService, int status, uint requestId)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
            {
                try
                {
                    string deviceServiceID = deviceService.DeviceServiceID;
                    deviceServicesOutputStr += "\nOnOpenCommandSessionComplete event received for DS: " + deviceServiceID + " request ID: " + requestId.ToString() + " status: 0x" + status.ToString("X");
                    if (deviceService.IsCommandSessionOpen == 1)
                    {
                        uint queryRequestID = 0;
                        // Generate query data
                        // Create the MBIM_PHONEBOOK_READ_REQ structure to get all entries in the phonebook
                        // We use the DataWriter object for this purpose
                        DataWriter dataWriter = new DataWriter();
                        dataWriter.ByteOrder = ByteOrder.LittleEndian; // MBIM byte ordering is Little Endian

                        dataWriter.WriteInt32(0);                      // FilterFlag = MBIMPhonebookFlagAll
                        dataWriter.WriteInt32(0);                      // FilterMessageIndex = 0

                        // Get the raw bytes out so that we can send it down to the API
                        byte[] data = dataWriter.DetachBuffer().ToArray();

                        uint commandID = 2;  // MBIM_CID_PHONEBOOK_READ
                        // Query command
                        deviceService.QueryCommand(commandID, data, out queryRequestID);
                        deviceServicesOutputStr += "\n\nWaiting for QueryCommand to complete for requestId: " + queryRequestID.ToString() + "\n";
                    }
                    rootPage.NotifyUser(deviceServicesOutputStr, NotifyType.StatusMessage);
                }
                catch (Exception e)
                {
                    deviceServicesOutputStr = "";
                    rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage);
                    if (deviceService.IsCommandSessionOpen == 1)
                    {
                        // Close command session
                        uint closeRequestID = 0;
                        deviceService.CloseCommandSession(out closeRequestID);
                        rootPage.NotifyUser("Waiting for CloseCommandSession to complete for requestId: " + closeRequestID.ToString(), NotifyType.StatusMessage);
                    }
                }
            }));
        }
示例#2
0
        async void ProcessOnOpenCommandSessionComplete(IMbnDeviceService deviceService, int status, uint requestId)
        {
            // Dispatch to UI thread
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
            {
                try
                {
                    string deviceServiceID = deviceService.DeviceServiceID;
                    deviceServicesOutputStr += "\nOnOpenCommandSessionComplete event received for DS: " + deviceServiceID + " request ID: " + requestId.ToString() + " status: 0x" + status.ToString("X");
                    if (deviceService.IsCommandSessionOpen == 1)
                    {
                        uint queryRequestID = 0;
                        // Generate query data
                        // Create the MBIM_PHONEBOOK_READ_REQ structure to get all entries in the phonebook
                        // We use the DataWriter object for this purpose
                        DataWriter dataWriter = new DataWriter();
                        dataWriter.ByteOrder = ByteOrder.LittleEndian;  // MBIM byte ordering is Little Endian

                        dataWriter.WriteInt32(0);   // FilterFlag = MBIMPhonebookFlagAll
                        dataWriter.WriteInt32(0);   // FilterMessageIndex = 0

                        // Get the raw bytes out so that we can send it down to the API
                        byte[] data = dataWriter.DetachBuffer().ToArray();

                        uint commandID = 2;  // MBIM_CID_PHONEBOOK_READ
                        // Query command
                        deviceService.QueryCommand(commandID, data, out queryRequestID);
                        deviceServicesOutputStr += "\n\nWaiting for QueryCommand to complete for requestId: " + queryRequestID.ToString() + "\n";
                    }
                    rootPage.NotifyUser(deviceServicesOutputStr, NotifyType.StatusMessage);
                }
                catch (Exception e)
                {
                    deviceServicesOutputStr = "";
                    rootPage.NotifyUser(ParseExceptionCode(e), NotifyType.ErrorMessage);
                    if (deviceService.IsCommandSessionOpen == 1)
                    {
                        // Close command session
                        uint closeRequestID = 0;
                        deviceService.CloseCommandSession(out closeRequestID);
                        rootPage.NotifyUser("Waiting for CloseCommandSession to complete for requestId: " + closeRequestID.ToString(), NotifyType.StatusMessage);
                    }
                }
            }));
        }