Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Sending data from web Server to GSM module via GPRS

Status
Not open for further replies.

kazimi

Newbie level 5
Joined
Feb 10, 2010
Messages
9
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,372
www + gprs

Hello!

I have to construct a system, which uses data transmission over gprs (tcp/ip) to control and monitor a building. The idea is like following: user can log in (www) and then he sees his control and monitoring panel. Data are sent over gprs to the device. This device consists of uC and GSM module (has implemented tcp/ip, i used such a module, but I was sending smses only). I know, that such a module has to have sim card with public ip (the best is, when it is static ip). And I know (I tried this before), that there is no problem to do transmission module->server. It can be done via standard AT commands. But I do not know, how to transmit data in the other direction: www -> module. Ok, I understand, that such a module has simcard with ip, but is it possible, that www will initiate the connection? So if server will send something to the module, who is going to pay for that? I cannot understand that.
I will be thankful for any advice (I need this for my master thesis).

Regards,
kazimi
 

Re: www + gprs

kazimi said:
But I do not know, how to transmit data in the other direction: www -> module. Ok, I understand, that such a module has simcard with ip, but is it possible, that www will initiate the connection?
First, you need to open a "server" connection on your module. Then your server needs to make a request to the module just as any client would. How you do this depends on the software your server is running (PHP, ASP, etc.). With ASP you can use the "xmlhttp" object.

kazimi said:
So if server will send something to the module, who is going to pay for that?
Regardless of who instantiates the connection, the cell phone account will be charged for any data transferred.
 

www + gprs

You have to read the at command set for GPRS communication
 

    kazimi

    Points: 2
    Helpful Answer Positive Rating
Re: www + gprs

Thanks for reply.

I am going to use:
**broken link removed**

AT commands for that module:
**broken link removed**


Regardless of who instantiates the connection, the cell phone account will be charged for any data transferred.

Thanks, I expected such answer!

But I have to admit, that there is something, that I am not sure. So I think, that I should establish gprs connection, than establish tcp server connection.
If I want to send data, I use +ZIPSEND (send TCP data to target address).
If serwer (user) wants to send data to the module, then he sends it (using PHP or ASP) and it is somewhere buffered (??) and then on the module side I can use +ZIPRECV: (Prompt to Receive Data from Current Data Link) ?? Is that correct?


Best Regards,
kazimi
 

Re: www + gprs

kazimi said:
If serwer (user) wants to send data to the module, then he sends it (using PHP or ASP) and it is somewhere buffered (??)
Just to clarify this; you'll have TCP/IP connection open between the server and your module, so the data is sent directly between the 2 of them - it's not 'buffered' anywhere.

kazimi said:
If I want to send data, I use +ZIPSEND (send TCP data to target address).
If serwer (user) wants to send data to the module, then he sends it (using PHP or ASP) and it is somewhere buffered (??) and then on the module side I can use +ZIPRECV: (Prompt to Receive Data from Current Data Link) ?? Is that correct?
I'm not familiar with the module you are using, or it's command set, but looking at the documentation I would say this is correct.
 

Re: www + gprs

Hi.
I do not want to open new topic, so I am refreshing this one. Now I am waiting for parts, so I thought, that in the meantime I can take care of server part. But unfotunately I failed, and I do not know why.

I wrote simple script in PHP (in fact, rewrote from manual). I am able to run that locally using WampSerwer. But when I want to run that not locally, I am getting an error:

#!/usr/local/bin/php -q
Warning: socket_accept() [function.socket-accept]: unable to accept incoming connection [4]: Interrupted system call in /home/users/kazek/public_html/index2.php on line 28
socket_accept() failed: reason: Success

I suppose, that there is something wrong with my server (I use my account on server localized in my old studenthaus). And this problem really stopped me. I tried to use 2 another free servers, but there was always something wrong (like disabled sockets).

Do you have any advice for me? If it is phps problem, then I can change language for another (which one?). In general - how it can be done? Where can I get appropriate server (but free?). I will be thatnkfull for any advice, because I have never got into programming related to networks etc.

Below my code:

Code:
#!/usr/local/bin/php -q
<?php
error_reporting(E_ALL);

/* Allow the script to hang around waiting for connections. */
set_time_limit(0);

/* Turn on implicit output flushing so we see what we're getting
 * as it comes in. */
ob_implicit_flush();

$address = '0';
$port = 60989;

if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
    echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
}

if (socket_bind($sock, $address, $port) === false) {
    echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}

if (socket_listen($sock, 5) === false) {
    echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}

do {
    if (($msgsock = socket_accept($sock)) === false) {
        echo "socket_accept() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
        break;
    }
    /* Send instructions. */
    $msg = "\nWelcome to the PHP Test Server. \n" .
        "To quit, type 'quit'. To shut down the server type 'shutdown'.\n";
    socket_write($msgsock, $msg, strlen($msg));

    do {
        if (false === ($buf = socket_read($msgsock, 2048, PHP_NORMAL_READ))) {
            echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($msgsock)) . "\n";
            break 2;
        }
        if (!$buf = trim($buf)) {
            continue;
        }
        if ($buf == 'quit') {
            break;
        }
        if ($buf == 'shutdown') {
            socket_close($msgsock);
            break 2;
        }
        $talkback = "PHP: You said '$buf'.\n";
        socket_write($msgsock, $talkback, strlen($talkback));
        echo "$buf\n";
    } while (true);
    socket_close($msgsock);
} while (true);

socket_close($sock);
?>


For example, my page:

**broken link removed**

info.php:

**broken link removed**

If I want to telnet, which ip address should i use? It seems, that errors are switched off. How tu turn them on?

Regards,
kazimi
 

Re: www + gprs

Thanks, I saw that tutorial before. I also possess Programming PHP written by O'Reilly. I looked through that book, but I dont think, that there is answer for my question. I do not ask about PHPs advice, but how to deal with server (why my script is interrupted?).
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top