p1

Committer:
bosko001
Date:
Thu Jun 18 15:23:39 2020 +0000
Revision:
7:be56cf51685d
p1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bosko001 7:be56cf51685d 1
bosko001 7:be56cf51685d 2 #include "ParkareClient.h"
bosko001 7:be56cf51685d 3 #include "PGSdisplay.h"
bosko001 7:be56cf51685d 4
bosko001 7:be56cf51685d 5
bosko001 7:be56cf51685d 6
bosko001 7:be56cf51685d 7 //unsigned char msg_request_message[] = "{5|1|1;2}";
bosko001 7:be56cf51685d 8 //unsigned char msg_catalogue_request_message[] = "{1|1}";
bosko001 7:be56cf51685d 9
bosko001 7:be56cf51685d 10
bosko001 7:be56cf51685d 11 char crm_req[]= {'{','1','|','1','}'}; //"{1|1}";
bosko001 7:be56cf51685d 12 char crm_resp[100];
bosko001 7:be56cf51685d 13 void crm_fun( char *rx)
bosko001 7:be56cf51685d 14 {
bosko001 7:be56cf51685d 15 printf("crm_resp: %s\n\r",rx);
bosko001 7:be56cf51685d 16 strcmp(crm_resp, rx);
bosko001 7:be56cf51685d 17 }
bosko001 7:be56cf51685d 18
bosko001 7:be56cf51685d 19 char srm_req[]="{5|1|0}";
bosko001 7:be56cf51685d 20 void srm_fun( char *rx )
bosko001 7:be56cf51685d 21 {
bosko001 7:be56cf51685d 22 printf("srm_resp: %s\n\r",rx);
bosko001 7:be56cf51685d 23 char *strno= extract_string(';',rx, 2);
bosko001 7:be56cf51685d 24 char boja = 0;
bosko001 7:be56cf51685d 25 if(atoi(strno) <= 0) {
bosko001 7:be56cf51685d 26 boja = 1;
bosko001 7:be56cf51685d 27 } else if(atoi(strno) >0 && atoi(strno)<5) {
bosko001 7:be56cf51685d 28 boja = 4;
bosko001 7:be56cf51685d 29 } else {
bosko001 7:be56cf51685d 30 boja = 2;
bosko001 7:be56cf51685d 31 }
bosko001 7:be56cf51685d 32 printf("broj: %d - boja: %d\n\r", atoi(strno),boja);
bosko001 7:be56cf51685d 33 if (atoi(strno) < 0)
bosko001 7:be56cf51685d 34 putOnDisp("0", boja);
bosko001 7:be56cf51685d 35 else
bosko001 7:be56cf51685d 36 putOnDisp((char*)strno, boja);
bosko001 7:be56cf51685d 37 }
bosko001 7:be56cf51685d 38
bosko001 7:be56cf51685d 39
bosko001 7:be56cf51685d 40
bosko001 7:be56cf51685d 41 void requestMessageThread(struct s_rm *s)
bosko001 7:be56cf51685d 42 {
bosko001 7:be56cf51685d 43
bosko001 7:be56cf51685d 44 TCPSocket tcpSocket;
bosko001 7:be56cf51685d 45 nsapi_error_t err=NULL;
bosko001 7:be56cf51685d 46 char rxbuf[1024];
bosko001 7:be56cf51685d 47 memset(rxbuf, 0, sizeof(rxbuf));
bosko001 7:be56cf51685d 48 if((err=tcpSocket.open( s->e )) ==0 ) {
bosko001 7:be56cf51685d 49 if((err = tcpSocket.connect(*(s->sa))) == 0) {
bosko001 7:be56cf51685d 50 char *ss = s->tx_msg;
bosko001 7:be56cf51685d 51 if( (err = tcpSocket.send(s->tx_msg,strlen(ss))<0 ) ) {
bosko001 7:be56cf51685d 52 printf("requestMessage - send err: %d\n\r", err);
bosko001 7:be56cf51685d 53 } else {
bosko001 7:be56cf51685d 54 printf("requestMessage - poslano: %d bajtova od: %s\n\r", err, s->tx_msg);
bosko001 7:be56cf51685d 55 if( (err = tcpSocket.recv(rxbuf,sizeof(rxbuf)) <0 )) {
bosko001 7:be56cf51685d 56 printf("requestMessage - recv err %d\n\r", err);
bosko001 7:be56cf51685d 57 } else {
bosko001 7:be56cf51685d 58
bosko001 7:be56cf51685d 59 printf("requestMessage - prim tel %d: %s\n\r", err, rxbuf) ;
bosko001 7:be56cf51685d 60 s->fun_rec( rxbuf );
bosko001 7:be56cf51685d 61 s->response = dispGetResponce( );
bosko001 7:be56cf51685d 62
bosko001 7:be56cf51685d 63 }
bosko001 7:be56cf51685d 64 }
bosko001 7:be56cf51685d 65 }
bosko001 7:be56cf51685d 66
bosko001 7:be56cf51685d 67 printf("requestMessage - zatvaranje konekcije\n\r");
bosko001 7:be56cf51685d 68 tcpSocket.close();
bosko001 7:be56cf51685d 69 }
bosko001 7:be56cf51685d 70
bosko001 7:be56cf51685d 71 }
bosko001 7:be56cf51685d 72
bosko001 7:be56cf51685d 73
bosko001 7:be56cf51685d 74
bosko001 7:be56cf51685d 75
bosko001 7:be56cf51685d 76
bosko001 7:be56cf51685d 77