1. Создаем профиль соединения 0 - одинаково для клиента и сервера
at^sics=0,conType,GPRS0 //Select connection type GPRS0. AT^SICS=0,inactTO,"0" //Inactivitiy timeout = 0 (default). AT^SICS=0,authMode,"PAP" //Authentication protocol PAP (default). //AT^SICS=0,passwd,... // Password for GPRS services AT^SICS=0,apn,"internet.volga" AT^SICS=0,apn,"internet.ulgsm.ru" AT^SICS=0,apn,"internet.mts.ru"
2. Создаем профиль сервера
at^siss=4,srvType,socket //Select service type Socket. at^siss=4,conId,0 //Select connection profile 0. at^siss=4,address,"socktcp://listener:65534" /*The host specifies its local port 65534 to be used for the Socket listener service. The local IP address will be dynamically assigned when the service is opened with AT^SISO. */ at^siso=4 //Open the Socket service. //Именно эта ком. действует - занимает неск.сек., при успехе модем //мигает в режиме гпрс - двойная вспышка
//Теперь надо узнать назначенный серверу IP at^siso? /*Query the current status of services. All service profiles are unused, except for service profile 4 which is running in listener mode, where <srvState>=3 (listening) and <socketState>=3 (LISTENER). The response also indicates the IP address dynamically assigned to the listener. */
^SISO: 0, "" ^SISO: 1, "" ^SISO: 2, "" ^SISO: 3, "" ^SISO: 4, "Socket","3","3","0","0","10.10.0.187:65534","0.0.0.0:0"
3. Создаем профиль клиента
at^siss=1,srvType,socket //Select service type Socket. at^siss=1,conId,0 //Select connection profile 0. at^siss=1,address,"socktcp://92.252.135.164:700" // или at^siss=1,address,"sockudp://10.207.208.143:65534" //The service profile of the client contains the IP address and the TCP port of the remote host. at^siso=1
4. Сервер получил запрос от клиента
//Indication of incoming Socket connection request: ^SIS: 4, 1, 0 */The URC indicates that the listener configured on service profile 4 is receiving a Socket connection request (<urcCause>=1) from the remote client. The last URC parameter <urcInfoId> represents the ID of the dynamically assigned service profile, here 0. */
at^siso? /*Query the current status of services. ^SISO: 0, "Socket","2","4","0","0","10.10.0.187:0","10.10.0.185:1024" Indication on host 1 that the connection request from the remote client has been dynamically assigned to service profile 0 which is set to Server mode (<socketState>=4).*/ ^SISO: 1, "" ^SISO: 2, ""
at^siso=0 //Принимает запрос - открывает соединение /*Host 1 accepts the connection request, where 0 is the ID of the dynamically assigned service profile.
^SISW: 0, 1 /*The URC indicates that data transmission to the remote client is possible. If the remote client has already sent some data the additional URC ^SISR:0,1 is displayed.*/
at^siso? //Query the current status of services. ^SISO: 0, "Socket","4","4","0","0", "10.10.0.187:65534","10.10.0.185:1024" //The socket connection between host 1 and remote client is successfully established.
5. Чтение
^SISR: 0,1 /*Service profile 0 is configured for Socket service and UDP. The URC notifies host that data are available for reading.*/
at^sisr=0,6 //The host requests to read 6 bytes. ^SISR: 0,6,12 THIS_I
/*The first 6 bytes of datagram A are confirmed and transmitted. Another 12 bytes are still available. */
5. Запись - AT^SISW
6. Закрытие at^sisc=0 /*Host 1 rejects the connection request, where 0 is the ID of the dynamically assigned service profile. */
at^siso? //Query the current status of services. ^SISO: 0, "" /*The dynamically assigned service profile is free again. The Socket listener stays at <srvState>=3 (listening) and <socketState>=3 (LISTENER).*/
|