/****************************************************************************
- * apps/dev/rf_hopping/main.c
- *
+ * rf_hopping/main.c
*
*
* Copyright 2013-2014 Nathael Pajani <nathael.pajani@ed3l.fr>
}
#define RF_BUFF_LEN 64
+
+/* Note that this example application does not really handle data.
+ * Only display a message indicating that we received data.
+ */
void handle_rf_rx_data(void)
{
uint8_t data[RF_BUFF_LEN];
/******************************************************************************/
-/* Handle packets */
+/* Handle packets received on UART */
void handle_data(uint8_t* data, int len)
{
uint8_t cc_tx_data[RF_BUFF_LEN];
/* Note : Packets will not respect the sequence numbers, do not check. */
status_led(green_on);
- if (data[0] == 'a') {
+ if (data[0] == 'a') { /* Set our address */
struct board_data tmp_bdata __attribute__ ((__aligned__(4))) = {};
bdata->addr = strtoul((char*)&data[2], NULL, 10);
memcpy(&tmp_bdata, bdata, sizeof(struct board_data));
return;
}
- if (data[0] == 'C') {
+ if (data[0] == 'C') { /* RF Config */
struct board_data tmp_bdata __attribute__ ((__aligned__(4))) = {};
bdata->rx_channel = (uint8_t)strtoul((char*)&data[2], NULL, 10);
bdata->tx_channel = (uint8_t)strtoul((char*)&data[5], NULL, 10);
return;
}
- if (data[0] == 's') {
+ if (data[0] == 's') { /* Send data */
uint8_t send_len = 0;
- if (data[1] == 'v') { /* Send to one vehicule, raw */
+ if (data[1] == 'v') { /* Send to one peer, raw */
cc_tx_data[0] = (len - 2);
memcpy((cc_tx_data + 1), (data + 2), (len - 2));
send_len = len - 1;
new_packet = idx;
idx = 0;
}
+ if (idx >= UART_BUFF_SIZE) {
+ idx = 0;
+ }
}
/******************************************************************************/