diff --git a/projects/WEAtHeR/main.c b/projects/WEAtHeR/main.c index 5f47235153..c89c8fa16a 100644 --- a/projects/WEAtHeR/main.c +++ b/projects/WEAtHeR/main.c @@ -64,6 +64,7 @@ static void weather_send(char* unused); static void weather_sink(char* unused); static void set_interval(char* interval); static void set_probability(char* prob); +static void print_cc1100_info(char* unused); /* shell commands */ shell_t shell; @@ -72,6 +73,7 @@ const shell_command_t sc[] = { {"sink", "Enables node as data sink.", weather_sink}, {"int", "Set the sending interval in seconds", set_interval}, {"prob", "Set the gossiping probability", set_probability}, + {"cc1100", "Show state, statistics and config of cc1100", print_cc1100_info}, {NULL, NULL, NULL}}; static void shell_runner(void) { @@ -128,6 +130,14 @@ static void set_probability(char* prob) { } } +static void print_cc1100_info(char* unused) { + puts("=================================================="); + cc1100_print_statistic(); + puts("--------------------------------------------------"); + cc1100_print_config(); + puts("=================================================="); +} + /* packet handling */ static void handle_packet(void* msg, int msg_size, packet_info_t* packet_info) { weather_packet_header_t *header = (weather_packet_header_t*) msg; @@ -219,6 +229,7 @@ static void protocol_handler_thread(void) { packet = packet_buffer[pos]; handle_packet(packet.payload, packet.msg_size, &(packet.packet_info)); + DEBUG("Packet handler done\n"); } } @@ -273,8 +284,11 @@ int main(void) { if (data_src) { wdp.header.src = cc1100_get_address(); + DEBUG("Src filled\n"); wdp.timestamp = rtc_time(NULL); + DEBUG("Timestamp filled\n"); wdp.energy = ltc4150_get_total_mAh(); + DEBUG("Energy filled\n"); if (!success) { printf("error;error;error\n"); @@ -284,6 +298,7 @@ int main(void) { wdp.relhum = sht11_val.relhum; wdp.relhum_temp = sht11_val.relhum_temp; wdp.hops[0] = cc1100_get_address(); + DEBUG("Ready for sending\n"); /* send packet with one entry in hop list */ sending_state = cc1100_send_csmaca(0, WEATHER_PROTOCOL_NR, 0, (char*)&wdp, (EMPTY_WDP_SIZE + 1)); if (sending_state > 0) { diff --git a/projects/WEAtHeR/protocol_msg_gateway.c b/projects/WEAtHeR/protocol_msg_gateway.c index 6c32d3469a..baccab5e9a 100644 --- a/projects/WEAtHeR/protocol_msg_gateway.c +++ b/projects/WEAtHeR/protocol_msg_gateway.c @@ -20,6 +20,11 @@ packet_t packet_buffer[PACKET_BUFFER_SIZE]; static void protocol_msg_gateway(void* payload, int msg_size, packet_info_t* packet_info) { msg_t m; + if (!cc1100_get_address()) { + puts("No address configured, not processing incoming packet"); + return; + } + if (protocol_handler_pid <= 0) { puts("protocol_handler(): received packet without protocol handler. msg dropped."); return;