void rx(void) { uint8_t state; state = rfm12_rxstart(); unsigned char tmp[RFM12_DATA_LENGTH]; state = rfm12_rxfinish(tmp); if (state == 0) { return; } if (state == 255) { return; } if (state == 254) { rfm12_allstop(); return; } char out[16]; sprintf(out, "RX: [%02x] ", state); uart_puts(out); for (uint8_t i=0; i < state; i++) { sprintf(out,"%02x", tmp[i]); uart_puts(out); } uart_puts("\r\n"); }
void rfm12_process(void) { uip_len = rfm12_rxfinish(); if (!uip_len) return; #ifdef ROUTER_SUPPORT #ifdef RFM12_RAW_SUPPORT if (rfm12_raw_conn->rport) { /* rfm12 raw capturing active, forward in udp/ip encapsulated form, * thusly don't push to the stack. */ /* FIXME This way we cannot accept rfm12_raw requests from anything * but ethernet. This shalt be improved somewhen. */ uip_stack_set_active(STACK_ENC); memmove(uip_buf + UIP_IPUDPH_LEN + UIP_LLH_LEN, rfm12_data, uip_len); uip_slen = uip_len; uip_udp_conn = rfm12_raw_conn; uip_process(UIP_UDP_SEND_CONN); router_output(); uip_buf_unlock(); rfm12_rxstart(); return; } #endif /* RFM12_RAW_SUPPORT */ /* uip_input expects the number of bytes including the LLH. */ uip_len = uip_len + RFM12_BRIDGE_OFFSET + RFM12_LLH_LEN; #endif /* not ROUTER_SUPPORT */ rfm12_rxstart(); router_input(STACK_RFM12); if (uip_len == 0) { uip_buf_unlock(); return; /* The stack didn't generate any data * that has to be sent back. */ } /* Application has generated output, send it out. */ router_output(); }