向tk103 gps跟踪器发送命令

时间:2014-11-30 13:58:07

标签: php gps

我正在使用php处理实时gps跟踪器Web应用程序。 跟踪器引用是tk103,我可以从跟踪器接收信息并将其存储到数据库中。

设备的GPRS模式已启用,我的问题是:

如何使用php将命令从我的服务器发送到设备。

提前致谢

1 个答案:

答案 0 :(得分:1)

它'取决于您使用哪种协议将数据从tk103设备发送到服务器如果您使用TCP / IP协议,一旦数据来自设备,您应该使用您的命令重播。

在设备中显示configure以询问或调用请求命令。

我们配置就好 1)imei:359710047059226,tracker,15/03/18 12:17,,F,121703.000,A,1255.2746,N,07736.8209,E,0.00,208.00,0.00,1,1;

id device发送此命令,我们只存储到数据库

2)[`#!/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 = '192.168.1.53'; $port = 10000; 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); ?>

我们正在测试的最后一位数据  如果0表示只存储重播:OK  如果1表示重放:CMD GPRS 001就像一些命令

 <div class="form-group">
        <?= $form->labelEx($model, 'user_city_id', array('class' => ' control-label')); ?>
        <div class="clearfix">
            <?= $form->dropDownList($model, 'user_city_id', CHtml::listData($model_cities, 'city_id', 'city_country_id','city_name'), array('class' => 'select2')); ?>
        </div>

`] 1