|
Code Example |
Top Previous Next |
global.tbh: |
'DEFINES------------------------------------------------------------- #define SUPPORTS_GPRS 1 #define GPRS_DEBUG_PRINT 1 #define GPRS_PAYLOAD_SIZE 1
'INCLUDES------------------------------------------------------------ include "sock\trunk\sock.tbh" include "gprs\trunk\gprs.tbh"
'DECLARATIONS-------------------------------------------------------- declare tcp_sock_o as byte
|
main.tbs: |
include "global.tbh" '--------------------------------------------------------------------
const AT_DT_COMMAND="*99#" const REMOTE_IP="124.155.161.141" '<----- CHANGE THIS AS NEEDED const REMOTE_PORT=1001 '<----- CHANGE THIS AS NEEDED '-------------------------------------------------------------------- dim tcp_sock_o as byte
'==================================================================== sub on_sys_init() dim res as en_gprs_status_codes
'----- this is for the outgoing test connection tcp_sock_o=sock_get("TCPA") sock.num=tcp_sock_o sock.txbuffrq(1) sock.rxbuffrq(1) sys.buffalloc sock.protocol=PL_SOCK_PROTOCOL_TCP sock.targetip=REMOTE_IP sock.targetport=REMOTE_PORT sock.targetinterface=PL_SOCK_INTERFACE_PPP '----- end
res=gprs_start(AT_DT_COMMAND) end sub
'-------------------------------------------------------------------- sub on_ser_data_arrival() gprs_proc_ser_data() end sub
'-------------------------------------------------------------------- sub on_sock_data_arrival() dim s as string(32)
gprs_proc_sock_data()
'----- this is for the outgoing test connection if sock.num=tcp_sock_o then s=sock.getdata(255) pat.play("-***",PL_PAT_CANINT) end if '----- end end sub
'-------------------------------------------------------------------- sub on_sys_timer() gprs_proc_timer()
'----- this is for the outgoing test connection sock.num=tcp_sock_o if sock.statesimple=PL_SSTS_EST then sock.setdata("ABC") sock.send end if '----- end end sub
'-------------------------------------------------------------------- sub on_sock_event(newstate as pl_sock_state, newstatesimple as pl_sock_state_simple) '----- this is for the outgoing test connection if sock.num=tcp_sock_o then pat.play("-***",PL_PAT_CANINT) end if '----- end end sub
'-------------------------------------------------------------------- sub on_pat() '----- this is for the outgoing test connection sock.num=tcp_sock_o if sock.statesimple=PL_SSTS_EST then pat.play("G~",PL_PAT_CANINT) end if '----- end end sub
|
device.tbs: |
include "global.tbh"
'==================================================================== sub callback_gprs_ok() sock.num=tcp_sock_o sock.connect end sub
'-------------------------------------------------------------------- sub callback_gprs_failure() sock.num=tcp_sock_o sock.discard end sub
'-------------------------------------------------------------------- sub callback_gprs_pre_buffrq(required_buff_pages as byte) end sub
|