public static void CheckConnection()
        {
            if (device == null)
            {
                connection = null;
                return;
            }

            var idevice = LibiMobileDevice.Instance.iDevice;
            var error   = idevice.idevice_connect(device, PORT, out iDeviceConnectionHandle _connection);

            if (error != iDeviceError.Success)
            {
                device      = null;
                connection  = null;
                status.Text = "Lost connection";
            }
        }
        private static void ReceiveResponse()
        {
            var idevice = LibiMobileDevice.Instance.iDevice;

            Task.Run(() =>
            {
                while (true)
                {
                    uint receivedBytes = 0;
                    byte[] response    = new byte[64];
                    idevice.idevice_connection_receive(connection, response, (uint)response.Length, ref receivedBytes);

                    if (receivedBytes <= 0)
                    {
                        Console.WriteLine("No data recieved!");
                        device     = null;
                        connection = null;
                        break;
                    }

                    // Handle received bytes

                    /*string res = "";
                     * for (int i = 0; i < response.Length; i++)
                     *  res += " | " + response[i].ToString();
                     * Console.WriteLine("Command: "+res);*/

                    if (response.Length > 1 && response[0] == 1)
                    {
                        if (response[1] != 0)
                        {
                            Console.WriteLine("Button " + response[1] + " was pressed!");
                        }
                        break;
                    }

                    break;
                }
            });
        }
        public static void Connect(string newUdid)
        {
            var idevice = LibiMobileDevice.Instance.iDevice;

            idevice.idevice_new(out iDeviceHandle deviceHandle, newUdid).ThrowOnError();
            var error = idevice.idevice_connect(deviceHandle, PORT, out iDeviceConnectionHandle connectionHandle);

            if (error != iDeviceError.Success)
            {
                Console.WriteLine("Error");
                return;
            }

            device     = deviceHandle;
            connection = connectionHandle;

            status.Text = "Connected via USB";

            //Clear app queue before recieving data
            byte[] cmd = { 2 };
            SendBytes(cmd);
        }
        public static FileRelayError file_relay_request_sources_timeout(FileRelayClientHandle client, out string sources, out iDeviceConnectionHandle connection, uint timeout)
        {
            System.Runtime.InteropServices.ICustomMarshaler sourcesMarshaler = NativeStringMarshaler.GetInstance(null);
            System.IntPtr  sourcesNative = System.IntPtr.Zero;
            FileRelayError returnValue   = FileRelayNativeMethods.file_relay_request_sources_timeout(client, out sourcesNative, out connection, timeout);

            sources = ((string)sourcesMarshaler.MarshalNativeToManaged(sourcesNative));
            sourcesMarshaler.CleanUpNativeData(sourcesNative);
            return(returnValue);
        }
Exemple #5
0
        /// <summary>
        /// Request data for the given sources. Calls file_relay_request_sources_timeout() with
        /// a timeout of 60000 milliseconds (60 seconds).
        /// </summary>
        /// <param name="client">
        /// The connected file_relay client.
        /// </param>
        /// <param name="sources">
        /// A NULL-terminated list of sources to retrieve.
        /// Valid sources are:
        /// - AppleSupport
        /// - Network
        /// - VPN
        /// - WiFi
        /// - UserDatabases
        /// - CrashReporter
        /// - tmp
        /// - SystemConfiguration
        /// </param>
        /// <param name="connection">
        /// The connection that has to be used for receiving the
        /// data using idevice_connection_receive(). The connection will be closed
        /// automatically by the device, but use file_relay_client_free() to clean
        /// up properly.
        /// </param>
        /// <returns>
        /// FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
        /// more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
        /// error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
        /// or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
        /// sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
        /// for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
        /// </returns>
        /// <remarks>
        /// WARNING: Don't call this function without reading the data afterwards.
        /// A directory mobile_file_relay.XXXX used for creating the archive will
        /// remain in the /tmp directory otherwise.
        /// </remarks>
        public virtual FileRelayError file_relay_request_sources_timeout(FileRelayClientHandle client, out string sources, out iDeviceConnectionHandle connection, uint timeout)
        {
            FileRelayError returnValue;

            returnValue    = FileRelayNativeMethods.file_relay_request_sources_timeout(client, out sources, out connection, timeout);
            connection.Api = this.Parent;
            return(returnValue);
        }
 public static extern FileRelayError file_relay_request_sources_timeout(FileRelayClientHandle client, out System.IntPtr sources, out iDeviceConnectionHandle connection, uint timeout);