/******************************************************************************* * @fn uint8_t send_sync_message() * @brief TODO * ****************************************************************************/ uint8_t send_sync_message() { // Send sync message radio_tx( tx_buffer, sizeof(packet_header_t) ); led2_toggle(); return 1; }
void *th_recv( void *arg ){ my_info_t *buf; rf_pkt recv_buf; uint8_t i; while(1){ if( radio_recv(RADIO_PORT, (rf_pkt*)&recv_buf ) > 0 ){ buf = (my_info_t*)&recv_buf; uint8_t idx = buf->id; pthread_mutex_lock( &mutex_lock ); nb_table[idx].x = buf->x; nb_table[idx].y = buf->y; nb_table[idx].d = ptod( nb_table[LOCAL_ADDR].x, nb_table[LOCAL_ADDR].y, nb_table[idx].x, nb_table[idx].y ); if( nb_table[idx].life < 5 ) nb_table[idx].life++; pthread_mutex_unlock( &mutex_lock ); led2_toggle(); } else continue; uint8_t cnt = 0; for( i = 0; i < MAX_NB_CNT; i++ ){ if( nb_table[i].life > 0 ) cnt++; } if( cnt >= 3 ){ my_info.level = MTSL_LEVEL3; } } }