Pages: [1]   Go Down
Author Topic: Some problem to connect to my remote server  (Read 406 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 0
Posts: 446
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear all and programmer,

Iinstalled a unbuntu workstation with a web server. I also past in /var/opt a python script.
On my wirefall, I open the port 81
That script listner the port 81 and store a a mysql data the entry.

In order to make sure it work, I create another script, on my mac.
That script send data to server. The format of data are
Quote
"toto","titi","tata","tete"

The remote server collect the data and store it in to the DB.
Also, when the connection is done, the python script , of the unbuntu, dusplay a message " connection done"

Then it work


I also have a Arduino Uno and a Spreadtrum GSM card. I also have a SMI card and the PIN is unactive. From my mobile I can call it.

On my arduino, I have that code
Code:
     pinMode(13, OUTPUT);
     Serial.println("GPS Parser Initialized");
     digitalWrite(POWERPIN, LOW);
     delay(500);
     Serial.println("Setting up PDP Context");
     cell.println("AT+CGDCONT=1,\"IP\",\"wap.cingular\""); // IS THAT LINE CORRECT?
     delay(500);
     Serial.println("Activating PDP Context");
     cell.println("AT+CGACT=1,1");
     delay(500);
     Serial.println("Configuring TCP connection to TCP Server");
     cell.println("AT+SDATACONF=1,\"TCP\",\"xxx.xxx.xxx.xxx\",81");
     delay(500);
     Serial.println("Starting TCP Connection\n");
     cell.println("AT+SDATASTART=1,1");

When Arduino is running, I never see the "connection done" from my ubuntu. The python scrupt is running but it do not detect any entry from the Arduino. At same time, and to make sure that my python sctipt listen well the port 81, from my mac a lunch my test code and the message is well sent and recieved.

In fact, I thing , I have a problem on my above pasted code, but as I am a beginner, I would like to know if you can have a check and let me know what I shloud correct.

I have a doubt with that line
 
Code:
cell.println("AT+CGDCONT=1,\"IP\",\"wap.cingular\"");

What is exactely "wap.cingular"? I tried to replace it with sunrise.ch, but without success
Shoud  addapt i with my phone provider?
My phone provider is sunrise.ch

Do you have any advise and suggestion to successfuly connect to the remote ubuntu workstation?

Do you need more code?

In case you need, here is my setup()
Code:
void setup(){
// LED Pin are outputs. Switch the mode
  pinMode(redLedPin, OUTPUT);
  pinMode(blueLedPin, OUTPUT);
 
  /* Blink the Power LED */
  blinkLed(redLedPin,3,500);
 
  //Initialize serial ports for communication.
  Serial.begin(4800);
  cell.begin(9600);
 
  //Let's get started!
  Serial.println("Starting SM5100B Communication...");
  delay(5000);
  /* Currently GPRS is not registered and AT is not ready */

  GPRS_registered = 0;
  GPRS_AT_ready = 0;
}

And here my loop()
Code:
void loop() {
  /* If called for the first time, loop until GPRS and AT is ready */
   if(firstTimeInLoop) {
     firstTimeInLoop = 0;
      while (GPRS_registered == 0 || GPRS_AT_ready == 0) {
        readATString();
        ProcessATString();
     }
 
     if(POWERPIN) {
       pinMode(POWERPIN, OUTPUT);
     }
   
     pinMode(13, OUTPUT);
     Serial.println("GPS Parser Initialized");
     digitalWrite(POWERPIN, LOW);
     delay(500);
     Serial.println("Setting up PDP Context");
     cell.println("AT+CGDCONT=1,\"IP\",\"wap.cingular\"");
     delay(500);
     Serial.println("Activating PDP Context");
     cell.println("AT+CGACT=1,1");
     delay(500);
     Serial.println("Configuring TCP connection to TCP Server");
     cell.println("AT+SDATACONF=1,\"TCP\",\"xx.xxx.xx.xxx\",81");
     delay(00);
     Serial.println("Starting TCP Connection\n");
     cell.println("AT+SDATASTART=1,1");
     onLed(redLedPin);
   
   }else{
       
       //onLed(blueLedPin);
       //myString.print("AT+SSTRSEND=1,\"");
       
       //myString.print("lat");
       //myString.print(",");

       //myString.print("long");
       //myString.print(",");
       //myString.print(inc);
       //myString.print(",");
       //myString.print("w");
       //myString.print("\"");
       
       //inc++;
       
       // Serial.println(myString);
       // cell.println(myString);
       // myString.begin();
       // offLed(blueLedPin);
     
      delay(SEND_DELAY);
    }
}

For now I commented the data to be send, because I testing the connection

Many thank for your help
« Last Edit: January 08, 2013, 08:05:44 am by pierrot10 » Logged

Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

Offline Offline
Sr. Member
****
Karma: 0
Posts: 446
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am still surpise, it work and sometime it does not work.
Sometime it works when I press the reset button of my Arduino.

I thougnt that the reset button will delete the Sketch code?

I also wanted to make sure that all command have been ran successefuly.

For that I add that function
Code:
char incoming_status;
static void status(){
     while(cell.available()){
        incoming_status=cell.read();
        Serial.print(incoming_status);
      }
}

Then I added status() after each AT commande
Code:
void loop() {
  /* If called for the first time, loop until GPRS and AT is ready */
   if(firstTimeInLoop) {
     firstTimeInLoop = 0;
      while (GPRS_registered == 0 || GPRS_AT_ready == 0) {
        readATString();
        ProcessATString();
     }
 
     if(POWERPIN) {
       pinMode(POWERPIN, OUTPUT);
     }
     
     Serial.println("");
     Serial.println(F("*GPS Parser Initialized*"));
     //digitalWrite(POWERPIN, LOW);
     Serial.println(F("Setting up PDP Context"));
     cell.println("AT+CGDCONT=1,\"IP\",\"internet\"");
     status();
     delay(500);
     
     Serial.println(F("Activating PDP Context"));
     cell.println("AT+CGACT=1,1");
     status();
     delay(500);
     
     Serial.println(F("Configuring TCP connection to TCP Server"));
     cell.println("AT+SDATACONF=1,\"TCP\",\"92.104.69.134\",81");
     status();
     delay(500);
     
     Serial.println(F("Starting TCP Connection\n"));
     cell.println("AT+SDATASTART=1,1");
     status();
     delay(500);
     
     Serial.println(F("Getting status"));
     cell.print("AT+SDATASTATUS=1");
     status();
   
     
     blinkLed(blueLedPin,4,200);
   
   }else{
       
     
       myString.print("AT+SSTRSEND=1,\"");
       
       //myString.print(flat,DEC);
       myString.print("lat");
       myString.print(",");
       //myString.print(flon,DEC);
       myString.print("long");
       myString.print(",");
       myString.print(inc);
       myString.print(",");
       myString.print("w");
       myString.print("\"");
       
       
       
       cell.println(myString);
       Serial.println(myString);
       
       myString.begin();
       inc++;
       blinkLed(blueLedPin,10,200);
     
      delay(SEND_DELAY);
    }

for most oif them, it return "OK". But for
Code:
cell.println("AT+SDATACONF=1,\"TCP\",\"xx.xxx.xx.xxx\",81");
it return nothing
and for
Code:
cell.println("AT+CGDCONT=1,\"IP\",\"internet\"");
It return like a \n\r.

Could you ask you a very good fundtion to corretely check each AT command?
Logged

Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The reset button it like switching your Arduino off and on again, if this makes your code work it may be that your setup code finishes before your GPRS module is ready and so may not get the commands properly, I know seems unlikely, as you get a response for some functions, but it may be worth switching you delay(5000) for something like:
Code:
while(!cell.available())
     cell.println("AT");

while(cell.available())
     cell.read();
This way you only have to wait until you get a response.

PS in your second post you left your IP address in the code
Logged

Pages: [1]   Go Up
Jump to: