How would I make a new AT command in Codeless to change to the Baud rate of the BLE uart.
Keywords:
Device:
How would I make a new AT command in Codeless to change to the Baud rate of the BLE uart.
嗨Ant777222,
The CodeLess reference application code is developed o quick evaluate or perform some basic BLE functionality without having to dive in the code. What you need to implement is achievable, but you will need to do some work yourself and debug some user application functions. Take a look at the function void user_execute_commands(char* cmd) in the user_codeless.c. This function takes a string of semicolon separated AT commands and executes them one by one. A USER_APP_CMD_RECEIVED is sent toward to the kernel. Then, check the user_catch_rest_hndl() which handles the USER_APP_CMD_RECEIVED message. Your custom AT command should be added into the at_command_characteristics_t jump table. Please follow the USE_AT_ADVSTART macro which is responsible for start advertising. In addition, you should take care how to pass the baud rate in the perip_init() function.
Thanks, PM_Dialog
I made a command, AT+BAUD=0. Right now all it does is return ok. I'm struggling to figure out the best way to pass the baud rate into perip_init() how would you suggest I do this?
嗨Ant777222,
Please take a look at periph_init() function and you will see that that UART2 is finalized with 57600 baud rate. As soon as you send the appropriate AT command you should keep the baud rate into a variable and pass it in uart2_init().
Thanks, PM_Dialog
Right now I have this bit of code in user_at_commands.c to change the baud rate to 115200.
#ifdef使用_at_baud.
void user_at_baud(struct at_cmd_params_t * arg,char * reply_string)
{
uint8_t index = ahtoi(&arg->cmd_buffer[arg->arg_index[0]]);
if (index == 3){
uart2_init(UART_BAUDRATE_115K2, UART_CHARFORMAT_8);
arg->success_flag = true;
}
}
#endif
然而,这冻结了终端。当我将终端的波特率设置更改为115200时,它仍然冻结。
嗨Ant777222,
Can you please share how did you modify the at_command_characteristics_t jump table with your custom AT command? The description of the syntax is depicted in the below:
由于您发送AT + BAUK = 0命令,请您在调试模式下运行它,以澄清user_at_baud()触发回调函数吗?
Thanks, PM_Dialog
I added the following code to the jump table.
#ifdef使用_at_baud.
{ AT_BAUD, "BAUD", 4, user_at_BAUD, 1, 1, RPLY_MAX_SIZE },
#endif
If I put the code that is in void user_at_random() into my void user_at_BAUD() and use the AT command AT+BAUD=3 I get a random number as I would expect to.
如果我将此添加到我的user_at_baud()funtion,它不会改变波特率,但在57k6保持终端也会冻结。
uint8_t index = ahtoi(&arg->cmd_buffer[arg->arg_index[0]]);
if (index == 3){
uart2_init(UART_BAUDRATE_57K6, UART_CHARFORMAT_8);
arg->success_flag = true;
I do not yet have the debugger connected, I am waiting on my IT department to connect the right driver. Right now the connection to J3 only acts as the power source. I have P0_4 connected to Rx and P0_5 to Tx and J4 pin 2 connected to ground of a COM port. Could this be the problem?
So I am changing the baud rate correctly, however, when I change the baud rate the keyboard cannot type in the terminal anymore. Through the lightblue app I can still send commands such at typing with the pipe command after I change the baud rate. If I type ATr for example the the terminal does not respond with ok I would like to be able to read the response on the terminal and the phone connected.. Also I would like to fix not being able to type with the keyboard to the terminal after changing the baud rate.
嗨Ant777222,
Apologies for the delay. Since that the baud rate is changed, I suppose that the baud rate from the serial terminal should be also changed.
Thanks, PM_Dialog
I was changing the baud rate of the terminal . Adding user_charachter_parser_start() solved the problem.
void user_at_baud(struct at_cmd_params_t * arg,char * reply_string)
{
uint8_t index = ahtoi(&arg->cmd_buffer[arg->arg_index[0]]);
if (index == 5){
UART2_INIT(UART_BAUDRATE_38K4,UART_CHARFORMAT_8);
user_charachter_parser_start();
arg->success_flag = true;
}
嗨Ant777222,
Glad that you figured your issue out and many thanks for your indication.
Thanks, PM_Dialog