int main(void) { /* Get PID of the a network interface */ kernel_pid_t ifs[GNRC_NETIF_NUMOF]; size_t numof = gnrc_netif_get(ifs); if (10 <= numof) { printf("No valid network interface found\n"); return -1; } /* Set pre-configured IP address */ char if_pid[] = {ifs[0] + '0', '\0'}; char *cmd[] = {"ifconfig", if_pid, "add", "unicast", LOCAL_ADDR}; _netif_config(5, cmd); /* Test configuration */ printf("\nStarting server: LOCAL_ADDR=%s, LOCAL_PORT=%d, ", LOCAL_ADDR, LOCAL_PORT); printf("CONNS=%d, NBYTE=%d, CYCLES=%d\n\n", CONNS, NBYTE, CYCLES); /* Start Threads to handle connections */ for (int i = 0; i < CONNS; i += 1) { thread_create((char *) stacks[i], sizeof(stacks[i]), THREAD_PRIORITY_MAIN, 0, srv_thread, (void *) i, NULL); } return 0; }
int main(void) { puts("RIOT microcoap example application"); /* microcoap_server uses conn which uses gnrc which needs a msg queue */ msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); puts("Waiting for address autoconfiguration..."); xtimer_sleep(3); /* print network addresses */ puts("Configured network interfaces:"); _netif_config(0, NULL); /* * Author: Norbert Danisik * * Following block of code was added as an part of bachelor thesis. */ thread_create(btn_handler_stack, sizeof(btn_handler_stack), THREAD_PRIORITY_MAIN, THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST, btn_handler_function, NULL, btn_handler); /* start coap server loop */ microcoap_server_loop(); /* should be never reached */ return 0; }
int main(void) { puts("RIOT libcoap example application"); puts("Waiting for address autoconfiguration..."); xtimer_sleep(3); puts("Configured network interfaces:"); _netif_config(0, NULL); puts("CoAP server will be initialized"); coap_server_loop(); return 0; }
int main(void) { /* Print all configured addresses of the server */ printf("\nStarting server: LOCAL_PORT=%d, CONNS=%d, NBYTE=%d\n\n", LOCAL_PORT, CONNS, NBYTE); printf("Printing Servers Network Configuration:\n"); _netif_config(0, NULL); /* Start Threads to handle each connection */ for (int i = 0; i < CONNS; i += 1) { thread_create((char *) stacks[i], sizeof(stacks[i]), THREAD_PRIORITY_MAIN, 0, srv_thread, (void *) i, NULL); } return 0; }