98err_t
errHaRecieve(
void *arg,
struct tcp_pcb *tpcb,
struct pbuf *p, err_t err){
101 static uint8_t cReadNextFrame = 0;
104 if(err == ERR_OK && p!=NULL){
107 printf(
"Number of pbufs %d\n", pbuf_clen(p));
108 printf(
"Contents of pbuf %.*s\n",p->len,(
char *)p->payload);
109 printf(
"Length of pbuf %d\n", p->len);
113 if(strstr(p->payload,
"\r\n\r\n") != NULL){
117 if(cReadNextFrame == 1){
120 strcpy(state, (
char*) p->payload);
121 printf(
"Payload: %s\n", state);
127 tcp_recved(tpcb,p->len);
132 if(err == ERR_OK && p == NULL){
134 printf(
"Connectie gesloten\n");
135 printf(
"/************************ End ****************************/\n");
142 tcp_sent(tpcb, NULL);
167 printf(
"/************************ Begin ****************************/\n");
168 printf(
"Verbinden is gelukt\n");
192 printf(
"args: %s\n",pArguments->
action);
194 char url[200] =
"GET /ha?entity=";
195 strcat(url,pArguments->
entity);
196 if(strcmp(pArguments->
action,
"") != 0){
197 strcat(url,
"&action=");
198 strcat(url,pArguments->
action);
200 strcat(url,
" HTTP/1.0\r\nHost: 192.168.0.10:5000\r\n\r\n ");
202 printf(
"url: %s", url);
206 error = tcp_write(tpcb, url, strlen(url), TCP_WRITE_FLAG_COPY);
210 printf(
"ERROR: Code: %d (errHaSendPacket :: tcp_write)\n", error);
216 error = tcp_output(tpcb);
220 printf(
"ERROR: Code: %d (errHaSendPacket :: tcp_output)\n", error);
242 printf(
"TCP_ha :: vHaError callback function\n");
261 printf(
"ERROR: Code: %d in function %pS\n",err,__builtin_return_address(0));
265 printf(
"Out of memory error");
280 printf(
"Routing problem.");
286 printf(
"Operation in progress.");
291 printf(
"Illegal value.");
296 printf(
"Not connected.");
317 printf(
"Restart Pending");
350 printf(
"Waiting on interface\n");
351 while(!netif_is_up(&
gnetif)){
362 printf(
"Waiting on link\n");
363 while(!netif_is_link_up(&
gnetif)){
389err_t
errHaSend(
char entity[],
char action[], uint16_t usButton){
390 struct tcp_pcb *pConnectie;
398 if(PCB_argument == NULL){
407 strcpy(PCB_argument->
entity,entity);
408 strcpy(PCB_argument->
action,action );
412 pConnectie = tcp_new();
415 tcp_arg(pConnectie, PCB_argument);
419 IP_ADDR4(&serverIP,192,168,0,10);
428 printf(
"ERROR: Code %d (errHaSend :: tcp_connect)\n",error);
err_t errHaSendPacket(struct tcp_pcb *tpcb)
errHaSendPacket Verstuurd een TCP pakket naar de server.
static void prvHaFreePcbArgument(PCB_HA_argument *)
Geef memory vrij PCB_HA_argument.
void vHaError(void *arg, err_t err)
error callback functie van de LwIP_stack
err_t errHaConnected(void *arg, struct tcp_pcb *tpcb, err_t err)
errHaConnected functie (callback van de LwIP_stack)
err_t errHaRecieve(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
errHaRecieve functie TCP.
err_t errHaSend(char entity[], char action[], uint16_t usButton)
Stuur boodschap naar server.
void vHaWaitOnLink(err_t err)
Wacht op link.
void vHaErrorHandling(err_t err)
Error handling van de TCP errors.
uint8_t globalReceive
Globale variabele voor communicatie tussen twee aparte functies.
static void prvHaErrorHandelingRebootSystem(void)
Reset MCU.
static PCB_HA_argument * prvHaMakePcbArgument(void)
Alloceert memory voor PCB_HA_argument.
static void prvHaErrorHandelingRoutingError(void)
Error handling van de Routing error.
void vDisplayError(char message[])
Display error op het scherm.
void vDisplaySetUpButtonStates(void)
Vraagt de status op van iedere knop.
void vDisplayMessage(char message[])
Display message op het scherm.
void vDisplayBgButtonState(uint8_t usButtonId, char cState[])
Verandert de achtergrond van de knop op basis van de status.
void vDisplayMainScreen(void)
Display het hoofd scherm met de UI.
Bevat informatie over de entity.
char entity[30]
entity naam.
uint16_t usButton
usButton