// Прошивка для серверного радиомодуля #include #include #include #include #include #include "uart/uart.h" #include "uart/uart_addon.h" #include "res/strings.h" #include "nrf24l01/nrf24l01.h" #define UART_BAUD_RATE 9600 typedef struct t_data{ uint8_t from; uint8_t to; char cmd[5]; uint8_t value[25]; }t_data; unsigned char get_uart_char(void){ unsigned int res; do{ res = uart_getc(); } while(res & UART_NO_DATA); return (unsigned char) res; } static uint8_t get_uart_line(char *pbuf, uint8_t len_ln){ uint8_t i = 0; unsigned char c; len_ln=len_ln-1; while((c=get_uart_char()) != 0x0D && i0){ data.from = 0; data.to = 0xFF; if (strcmp(data.cmd, CmdLD)==0){ i = nrf24l01_write((uint8_t*) &data); if(i == 1){ uart_puts_p(TransOK); }else{ uart_puts_p(TransLost); } uart_puts_p(CmdPrompt); } if (strcmp(data.cmd, CmdHelp)==0){ uart_puts_p(HelpTitle); uart_puts_p(HelpItem1); uart_puts_p(HelpItem2); uart_puts_p(CmdPrompt); } } } if(nrf24l01_readready(0)){ nrf24l01_read((uint8_t*) &data); uart_puts(data.cmd); uart_putc('-'); uart_puthex_byte(data.from); uart_putc('>'); uart_puthex_byte(data.to); uart_putc(':'); for ( i=0; i < sizeof(data.value); i++ ){ uart_puthex_byte(data.value[i]); uart_putc(' '); } uart_puts(CRLF); } } }