| 86 | } |
| 87 | |
| 88 | static at_result_t at_uart_setup(const char *args) |
| 89 | { |
| 90 | struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; |
| 91 | int baudrate, databits, stopbits, parity, flow_control, argc; |
| 92 | const char *req_expr = "=%d,%d,%d,%d,%d"; |
| 93 | |
| 94 | argc = at_req_parse_args(args, req_expr, &baudrate, &databits, &stopbits, &parity, &flow_control); |
| 95 | if (argc != 5) |
| 96 | { |
| 97 | return AT_RESULT_PARSE_FAILE; |
| 98 | } |
| 99 | |
| 100 | at_server_printfln("UART baudrate : %d", baudrate); |
| 101 | at_server_printfln("UART databits : %d", databits); |
| 102 | at_server_printfln("UART stopbits : %d", stopbits); |
| 103 | at_server_printfln("UART parity : %d", parity); |
| 104 | at_server_printfln("UART control : %d", flow_control); |
| 105 | |
| 106 | config.baud_rate = baudrate; |
| 107 | config.data_bits = databits; |
| 108 | config.stop_bits = stopbits; |
| 109 | config.parity = parity; |
| 110 | |
| 111 | if(rt_device_control(at_get_server()->device, RT_DEVICE_CTRL_CONFIG, &config) != RT_EOK) |
| 112 | { |
| 113 | return AT_RESULT_FAILE; |
| 114 | } |
| 115 | |
| 116 | return AT_RESULT_OK; |
| 117 | } |
| 118 | |
| 119 | AT_CMD_EXPORT("AT+UART", "=<baudrate>,<databits>,<stopbits>,<parity>,<flow_control>", RT_NULL, at_uart_query, at_uart_setup, RT_NULL); |
| 120 |
nothing calls this directly
no test coverage detected