Skip to content

Can't connect to modem #2

Open
Open

Description

@AlexMineware

Hi,

I can use my modem through Hyperterminal and another 3rd party library. When I select my com port I get the error : Failed to communicate with phone. It is a D-LINK usb modem...

Activity

  1. alexmiby commented on Mar 6, 2019

    @alexmiby

    Same here, but there is a way to solve. Some modems answers are different so I found the following changes made the code working for me:
    _connectedStream.Write(writeBuffer, 0, writeBuffer.Length); System.Threading.Thread.Sleep(100); // Add this line // read response
    // read rows while (true) { readLength = _connectedStream.Read(readBuffer, 0, 512); System.Threading.Thread.Sleep(100); // Add this line if (readLength == 0) {

    Amend this
    WriteCommandExpectResponse("ATE=0", "ATE=0\r\rOK\r\0\rOK\r");
    with this:
    WriteCommandExpectResponse("ATE0", "ATE0\r\rOK\r\0\rOK\r");

    Debug.WriteLine("Asking for storage enumeration"); string response = WriteCommandExpectResponse("AT+CPMS?", "\rOK\r"); string[] data = response.Split('\r'); if ((data[1].Length>=7 && data[1].Substring(0, 7).ToUpper() != "+CPMS: ") && (data[2].Length>=7 && data[2].Substring(0,7).ToUpper()!="+CPMS: ")) // line amended throw new UnexpectedResponseException("Phone message storages could not be enumerated");

    // walk storages string[] storages = null; if (data[1].Length >= 7) storages = data[1].Substring(7).Split(','); // line amended if (data[2].Length >= 7) storages = data[2].Substring(7).Split(','); // line added

    Also, message receiving still won't work with some mobile devices, they require different commands than the ones issued in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions