error seems caused by inside the while too long - Contiki cannot use large delay