⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
12 posts / 0 new
Last post
ant777222
Offline
Last seen:1 week 3 days ago
加入:2019-07-11 17:03
Make new AT command

How would I make a new AT command in Codeless to change to the Baud rate of the BLE uart.

Device:
PM_Dialog
Offline
Last seen:3 hours 37 min ago
工作人员
加入:2018-02-08 11:03
Hi ant777222,

Hi 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

ant777222
Offline
Last seen:1 week 3 days ago
加入:2019-07-11 17:03
I made a command, AT+BAUD=0.

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?

PM_Dialog
Offline
Last seen:3 hours 37 min ago
工作人员
加入:2018-02-08 11:03
Hi ant777222,

Hi 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

ant777222
Offline
Last seen:1 week 3 days ago
加入:2019-07-11 17:03
Right now I have this bit of

Right now I have this bit of code in user_at_commands.c to change the baud rate to 115200.

#ifdef USE_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

然而,这冻结的终端。当我改变the baud rate setting on the terminal to 115200 it is still frozen.

PM_Dialog
Offline
Last seen:3 hours 37 min ago
工作人员
加入:2018-02-08 11:03
Hi ant777222,

Hi 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 command id index
  • AT command tag string
  • AT command tag length
  • AT command callback that implements the functionality
  • Minimum number of arguments
  • Maximum number of arguments
  • Max reply size string of argument

Since you send the AT+BAUD=0 command, can you please run it in debug mode in order to clarify if the user_at_BAUD() callback function is triggered?

Thanks, PM_Dialog

ant777222
Offline
Last seen:1 week 3 days ago
加入:2019-07-11 17:03
I added the following code to

I added the following code to the jump table.

#ifdef USE_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.

ant777222
Offline
Last seen:1 week 3 days ago
加入:2019-07-11 17:03
如果我添加这个to my user_at

如果我添加这个to my user_at_BAUD() funtion which does not change the BAUD rate but keeps it at 57K6 the terminal also freezes.

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?

ant777222
Offline
Last seen:1 week 3 days ago
加入:2019-07-11 17:03
So I am changing the baud

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.

PM_Dialog
Offline
Last seen:3 hours 37 min ago
工作人员
加入:2018-02-08 11:03
Hi ant777222,

Hi 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

ant777222
Offline
Last seen:1 week 3 days ago
加入:2019-07-11 17:03
I was changing the baud rate

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;
}

PM_Dialog
Offline
Last seen:3 hours 37 min ago
工作人员
加入:2018-02-08 11:03
Hi ant777222,

Hi ant777222,

Glad that you figured your issue out and many thanks for your indication.

Thanks, PM_Dialog