internal void Reboot() { if (Serial == null) { return; } try { QualcommSerial SerialDevice = new QualcommSerial(Serial); SerialDevice.EncodeCommands = false; // This will succeed on new models SerialDevice.SendData(new byte[] { 0x7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0 }); // This will succeed on old models SerialDevice.SendData(new byte[] { 0x7E, 0xA, 0x0, 0x0, 0xB6, 0xB5, 0x7E }); SerialDevice.Close(); SerialDevice.Dispose(); } catch { } }
public bool SendImage(string Path) { bool Result = true; LogFile.Log("Sending programmer: " + Path, LogType.FileOnly); int Step = 0; UInt32 Offset = 0; UInt32 Length = 0; byte[] ImageBuffer = null; try { Step = 1; byte[] Hello = null; Hello = Serial.GetResponse(new byte[] { 0x01, 0x00, 0x00, 0x00 }); // Incoming Hello packet: // 00000001 = Hello command id // xxxxxxxx = Length // xxxxxxxx = Protocol version // xxxxxxxx = Supported version // xxxxxxxx = Max packet length // xxxxxxxx = Expected mode // 6 dwords reserved space LogFile.Log("Protocol: 0x" + ByteOperations.ReadUInt32(Hello, 0x08).ToString("X8"), LogType.FileOnly); LogFile.Log("Supported: 0x" + ByteOperations.ReadUInt32(Hello, 0x0C).ToString("X8"), LogType.FileOnly); LogFile.Log("MaxLength: 0x" + ByteOperations.ReadUInt32(Hello, 0x10).ToString("X8"), LogType.FileOnly); LogFile.Log("Mode: 0x" + ByteOperations.ReadUInt32(Hello, 0x14).ToString("X8"), LogType.FileOnly); // Packet: // 00000002 = Hello response command id // 00000030 = Length // 00000002 = Protocol version // 00000001 = Supported version // 00000000 = Status OK // 00000000 = Mode // rest is reserved space Step = 2; byte[] HelloResponse = new byte[] { 0x02, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; Serial.SendData(HelloResponse); Step = 3; using (System.IO.FileStream FileStream = new System.IO.FileStream(Path, System.IO.FileMode.Open, System.IO.FileAccess.Read)) { while (true) { Step = 4; byte[] ReadDataRequest = Serial.GetResponse(null); UInt32 ResponseID = ByteOperations.ReadUInt32(ReadDataRequest, 0); if (ResponseID == 4) { break; } if (ResponseID != 3) { Step = 5; throw new BadConnectionException(); } Offset = ByteOperations.ReadUInt32(ReadDataRequest, 0x0C); Length = ByteOperations.ReadUInt32(ReadDataRequest, 0x10); if ((ImageBuffer == null) || (ImageBuffer.Length != Length)) { ImageBuffer = new byte[Length]; } if (FileStream.Position != Offset) { FileStream.Seek(Offset, System.IO.SeekOrigin.Begin); } Step = 6; FileStream.Read(ImageBuffer, 0, (int)Length); Step = 7; Serial.SendData(ImageBuffer); } } } catch (Exception Ex) { LogFile.LogException(Ex, LogType.FileAndConsole, Step.ToString() + " 0x" + Offset.ToString("X8") + " 0x" + Length.ToString("X8")); Result = false; } if (Result) { LogFile.Log("Programmer loaded into phone memory", LogType.FileOnly); } return(Result); }