PPP with a ZTE MF180 modem

Hi, I want to get my fez cobra in the internet, I have written following code:


public class Modem
    {
        private USBH_Device modem;

        public Modem()
        {
            USBHostController.DeviceConnectedEvent += new USBH_DeviceConnectionEventHandler(USBHostController_DeviceConnectedEvent);
            USBHostController.DeviceDisconnectedEvent += new USBH_DeviceConnectionEventHandler(USBHostController_DeviceDisconnectedEvent);
        }

        private void USBHostController_DeviceDisconnectedEvent(USBH_Device device)
        {
            if (PPP.IsEnabled)
            {
                PPP.Disable();
            }
        }

        private void USBHostController_DeviceConnectedEvent(USBH_Device device)
        {
            if (device.PRODUCT_ID == 22 && device.VENDOR_ID == 6610 && device.INTERFACE_INDEX == 2)
            {
                modem = device;

                Thread tInit = new Thread(new ThreadStart(this.InitilizeModem));
                tInit.Priority = ThreadPriority.BelowNormal;
                tInit.Start();
            }
        }

        private static bool Write(USBH_SerialUSB device, string command, string response)
        {
            return Write(device, Encoding.UTF8.GetBytes(command + "\r\n"), response);
        }
        private static bool Write(USBH_SerialUSB device, byte[] command, string response)
        {
            string read_buffer = string.Empty;
            byte[] buffer = new byte[1024];
            byte[] temp = new byte[1];
            int index = 0;
            byte count = 0;

            device.Write(command, 0, command.Length);
            device.Flush();

            while (true)
            {
                device.Read(temp, 0, 1);

                if (temp[0] == '\r' || temp[0] == '\n')
                {
                    string temptext = new string(Encoding.UTF8.GetChars(buffer));
                    if (response == temptext)
                    {
                        return true;
                    }
                    else
                    {
                        if (count == 3)
                        {
                            return false;
                        }
                        else
                        {
                            count++;
                            index = 0;
                            buffer = new byte[1024];
                        }
                    }
                }
                else
                {
                    buffer[index] = temp[0];
                    index++;
                }
            }
        }
        private void InitilizeModem()
        {
            USBH_Device zte = new USBH_Device(this.modem.ID, this.modem.INTERFACE_INDEX, USBH_DeviceType.Serial_FTDI, this.modem.VENDOR_ID, this.modem.PRODUCT_ID, this.modem.PORT_NUMBER);
            USBH_SerialUSB serialUSB = new USBH_SerialUSB(zte, 921600, Parity.None, 8, StopBits.One);

            serialUSB.Open();

            bool return0 = Write(serialUSB, "AT", "OK");
            bool return1 = Write(serialUSB, "ATV1", "OK");
            bool return2 = Write(serialUSB, "ATE0", "OK");
            bool return3 = Write(serialUSB, "AT&F&D2&C1S0=0", "OK");
            bool return4 = Write(serialUSB, "ATS7=60S30=0", "OK");
            bool return5 = Write(serialUSB, "AT+CGDCONT=1,\"IP\",\"bob.at\"", "OK");
            bool return6 = Write(serialUSB, "ATDT*99#", "CONNECT 3600000");

            if (return1 && return2 && return3 && return4 && return5 && return6)
            {
                if (!PPP.IsEnabled)
                {
                    PPP.Enable(serialUSB);
                }

                if (!PPP.IsLinkConnected)
                {
                    PPP.ConnectionStatus status = PPP.Connect("data@ bob.at", "ppp");
                    if (status == PPP.ConnectionStatus.Connected)
                    {
                        Debug.Print(Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress);
                    }

                    if (status == PPP.ConnectionStatus.Authentication_Faild)
                    {
                        Debug.Print("Auth failed");
                    }

                    if (status == PPP.ConnectionStatus.Connection_Faild)
                    {
                        Debug.Print("Conn failed");
                    }
                }
            }
        }
    }

Iam using a ZTE MF180 usb-modem, its one of the “flipflop” things, but I have disabled that and the modem is visible since I plug it in.

My problem is that I allways get a connection failed from the PPP class.

Can any buddy give me a advice whats wrong?

Some of the AT-Commands I have reverse engineered from windows.

thanks

Search the forum for “PPP”. Search is under “Help” menu at the top. I remeber there were couple of good threads. So people who worked on that already might help you.

Yeah I have read all the post from the history but nothing worked! I also copied the code of them and it doesn’t worked, every time when I call PPP.Connect() I got a connection failure back.

Are you sure that the ISP accept PAP authentication? our PPP supports only PAP, CHAP is not supported yet.

To help checking if it accept PAP, there is a way to enable only PAP authentication in Windows connection settings.

Yes I have tested it, and it worked, without any problem.

May can you explain to me, what the call PPP.Connect() actually do?

So I have now hooked up my cell phone to the cobra board to act as the modem, and it works without any problem.

Well I think the problem ist the ZTE MF180 3g usb stick, may someone has a idea …

Best regards

Maybe it is not getting enough power? Can you use an external 6V power supply instead of USB

So I have tried a external 6V power supply with 1000mA, but it didn’t worked.

The onliest diverence between my cellphone and the datastick is the DeviceType

Cellphone: Serial_CDC
Datastick: Serial_FTDI

If you could send AT commands and you got the response than I think PPP should work.
Are you able to access internet through the same interface but from PC instead of FEZ Cobra?

Probably, this modem has multiple interfaces, some for AT commands and other for data.

There is another thing you can test:
Make a small application that let FEZ Cobra perform as a bridge between the modem and the PC.
USB ZTE modem <—> FEZ Cobra <—> Serial Port <—> PC’s Serial Port.