bosko lekovic
/
EthTCPclient_05_03
p1
ParkareClient.cpp
- Committer:
- bosko001
- Date:
- 2020-06-18
- Revision:
- 7:be56cf51685d
File content as of revision 7:be56cf51685d:
#include "ParkareClient.h" #include "PGSdisplay.h" //unsigned char msg_request_message[] = "{5|1|1;2}"; //unsigned char msg_catalogue_request_message[] = "{1|1}"; char crm_req[]= {'{','1','|','1','}'}; //"{1|1}"; char crm_resp[100]; void crm_fun( char *rx) { printf("crm_resp: %s\n\r",rx); strcmp(crm_resp, rx); } char srm_req[]="{5|1|0}"; void srm_fun( char *rx ) { printf("srm_resp: %s\n\r",rx); char *strno= extract_string(';',rx, 2); char boja = 0; if(atoi(strno) <= 0) { boja = 1; } else if(atoi(strno) >0 && atoi(strno)<5) { boja = 4; } else { boja = 2; } printf("broj: %d - boja: %d\n\r", atoi(strno),boja); if (atoi(strno) < 0) putOnDisp("0", boja); else putOnDisp((char*)strno, boja); } void requestMessageThread(struct s_rm *s) { TCPSocket tcpSocket; nsapi_error_t err=NULL; char rxbuf[1024]; memset(rxbuf, 0, sizeof(rxbuf)); if((err=tcpSocket.open( s->e )) ==0 ) { if((err = tcpSocket.connect(*(s->sa))) == 0) { char *ss = s->tx_msg; if( (err = tcpSocket.send(s->tx_msg,strlen(ss))<0 ) ) { printf("requestMessage - send err: %d\n\r", err); } else { printf("requestMessage - poslano: %d bajtova od: %s\n\r", err, s->tx_msg); if( (err = tcpSocket.recv(rxbuf,sizeof(rxbuf)) <0 )) { printf("requestMessage - recv err %d\n\r", err); } else { printf("requestMessage - prim tel %d: %s\n\r", err, rxbuf) ; s->fun_rec( rxbuf ); s->response = dispGetResponce( ); } } } printf("requestMessage - zatvaranje konekcije\n\r"); tcpSocket.close(); } }