Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years ago.
Sending AT commands to bluetooth module using ATCmdParser
Hello,
I am using a NUCLEO L432KC to send AT commands to a bluetooth classic module to change the default baud rate. I want to use the ATCmdParser to send AT commands to the bluetooth module, but I get the following error: Error: Identifier "ATCmdParser" is undefined. Please help!
#include "mbed.h"
Serial pc(PA_2, PA_15);
Serial bt(PA_9, PA_10);
ATCmdParser at(&bt, "\r\n")
at.send("AT") && at.recv("OK");
at.send("AT+AB ChangeDefaultBaud [921600]", 3) && at.recv("OK");*/
int main()
{
pc.baud(921600);
bt.baud(921600);
while(1) {
wait(2);
pc.printf("hello\n");
bt.printf("hello\n");
}
}
1 Answer
7 years ago.
Hi Jihong,
We have edited your post so that it is more legible. In the future please use <<code>> and <</code>> tags as described in the "Editing tips".
It appears that you are missing a #include of "platform\ATCmdParser.h". We have a AT command parser example here:
Regards,
Ralph, Team Mbed
mbed.h has include for ATCmdParser so that's not the problem. Issue is that you running the code outside of the main and ATCmdParser line is missing ';' Also loose the '*/' at the end of the second at.send(...)...
This seems to compile fine:
#include "mbed.h" Serial pc(PA_2, PA_15); Serial bt(PA_9, PA_10); ATCmdParser at(&bt, "\r\n"); int main() { at.send("AT") && at.recv("OK"); at.send("AT+AB ChangeDefaultBaud [921600]", 3) && at.recv("OK"); pc.baud(921600); bt.baud(921600); while(1) { wait(2); pc.printf("hello\n"); bt.printf("hello\n"); } }In second at.send command you don't need ', 3' as you are don't have %d where to put that.
posted by Teppo Järvelin 14 Dec 2018