/*---------------------------------------------------------------------------*/ static void register_http_post_handlers(void) { httpd_simple_register_post_handler(&org_id_handler); httpd_simple_register_post_handler(&type_id_handler); httpd_simple_register_post_handler(&event_type_id_handler); httpd_simple_register_post_handler(&cmd_type_handler); httpd_simple_register_post_handler(&auth_token_handler); httpd_simple_register_post_handler(&interval_handler); httpd_simple_register_post_handler(&port_handler); httpd_simple_register_post_handler(&ip_addr_handler); httpd_simple_register_post_handler(&reconnect_handler); httpd_simple_register_post_handler(&ping_interval_handler); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(net_uart_process, ev, data) { PROCESS_BEGIN(); printf("CC26XX Net UART Process\n"); set_config_defaults(); udp_conn = udp_new(NULL, UIP_HTONS(0), NULL); udp_bind(udp_conn, UIP_HTONS(REMOTE_PORT)); if(udp_conn == NULL) { printf("No UDP connection available, exiting the process!\n"); PROCESS_EXIT(); } httpd_simple_register_post_handler(&remote_port_handler); httpd_simple_register_post_handler(&remote_ipv6_handler); httpd_simple_register_post_handler(&on_off_handler); while(1) { PROCESS_YIELD(); if(ev == serial_line_event_message) { printf("~Received line: %s\n", (char *)data); /* * If the message contains a new IP address, save it and go back to * waiting. */ if(set_new_ip_address((char *)data) == ADDRESS_CONVERSION_ERROR) { /* Not an IP address in the message. Send to current destination */ memset(buffer, 0, MAX_MSG_SIZE); memset(uart_reading_value, 0, MAX_MSG_SIZE); /* We need to add a line feed, thus never fill the entire buffer */ msg_len = MIN(strlen(data), MAX_MSG_SIZE - 1); memcpy(buffer, data, msg_len); memcpy(uart_reading_value, data, msg_len); /* Add a line feed */ buffer[msg_len] = 0x0A; msg_len++; uip_udp_packet_sendto( udp_conn, buffer, msg_len, &remote_addr, UIP_HTONS(cc26xx_web_demo_config.net_uart.remote_port)); } } else if(ev == tcpip_event) { net_input(); } else if(ev == cc26xx_web_demo_config_loaded_event) { /* * New config. Check if it's possible to update the remote address. * The port will have been updated already */ set_new_ip_address(cc26xx_web_demo_config.net_uart.remote_address); if(cc26xx_web_demo_config.net_uart.enable == 1) { keep_uart_on(); } } else if(ev == cc26xx_web_demo_load_config_defaults) { set_config_defaults(); } } PROCESS_END(); }