Software Development Network>> Smart Devicet>> Gprs/EDGE connection problem
I have a problem when i use a gprs connection. Sometimes it works fine, but sometimes there is a problem. I use VS2005, i develop in C# and my smartphone is a SPV C600. I use the connection manager (of OpennetCF) to connect my smarpthone by gprs, and when i'm connected, I log in to a ftp server. After this, I send pictures by upload to this server. But sometimes, i have this error : "couldn't open passive data connection, no DataConnection IP was given." Is someone have the same problem Maybe it don't use the correct way to establish a GPRS connection. here's my code: public bool connectGPRS() { label1.Text = connMgr.Status.ToString(); DestinationInfoCollection DIC = connMgr.EnumDestinations(); long startTime; bool is_connected = false; try { foreach (DestinationInfo di in DIC) { if (di.description == "Internet") { int i = 0; while (connMgr.Status.ToString() != "Connected" & i<10) { connMgr.Connect(di.guid, true, ConnectionMode.Asynch ronous) startTime = DateTime.Now.Ticks; while ((!is_connected) & (DateTime.Now.Ticks - start Time < 20 * TimeSpan.TicksPerSecond)) { if (connMgr.Status.ToString() == "Connected") is _connected = true; } i++; } label1.Text = connMgr.Status.ToString(); } } } catch (SystemException err) { MessageBox.Show(" err 700 " + err.Message); return false; } return true; } public bool FTPLogin() { label1.Text = "try to login"; try { FtpRequestCreator creator = new FtpRequestCreator(); WebRequest.RegisterPrefix("ftp:", creator); //Building our URI object Uri testUri; // Building our URI object testUri = new Uri("ftp://62.160.187.138"); //testUri = new Uri("ftp://10.3.3.42"); //Creating a new FtbRequest object request = (FtpWebRequest)WebRequest.Create(testUri); request.Credentials = new NetworkCredential("login", "****"); //request.Credentials = new NetworkCredential("any", "any"); //Getting the Request stream ftpRequestStream = request.GetRequestStream(); StreamReader reader = new StreamReader(ftpRequestStream); string responseFTP = reader.ReadToEnd(); label1.Text = responseFTP; //Connected logined = true; label1.Text = "logined"; } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; } public bool SendFile(string PhotoPath) { progress.Text = ""; progressBar1.Value = 0; label1.Text = "try to send"; string LocalFilePathText = PhotoPath; string PhotoName = Path.GetFileName(PhotoPath); string RemoteFilePathText = "\\GSM\\" + PhotoName; /*string LocalFilePathText = "\\My Documents\\My Pictures\\test.txt" ; string RemoteFilePathText = "\\test.txt";*/ StreamReader Reader; String commandReply; try { // Open the input file. If the file does not exist, it's an // error. FileStream fs = new FileStream(LocalFilePathText, FileMode.Open) ; // Create the reader for the local file data. BinaryReader r = new BinaryReader(fs); label1.Text = "file opened"; // Opening the data connection, this must be done before // we issue the command. Stream ftpResponseStream = request.GetResponse().GetResponseStre am(); label1.Text = "bordel1"; BinaryWriter response = new BinaryWriter(ftpResponseStream); // Prepare to send commands to the server. StreamWriter writer = new StreamWriter(ftpRequestStream); label1.Text = "bordel2"; // Set transfer type to IMAGE (binary). writer.Write("TYPE I\r\n"); writer.Flush(); ... ... .... So the method connect works fine, the edge connection is up, the ftplogin works too, but when i try to send a file, I often heve this error: "couldn't open passive data connection, no DataConnection IP was given." Anyway, the send of file works sometimes. For example, if i try to send 2 or 3 pictures, it doesn't work for the first, but it works for the second... it's very random. Is somenone know why
Gprs/EDGE connection problem
Chris Condrey