I am working with a B-L072Z-LRWAN1 board and a 8pya00-simcom-evb v1.02 board with SIM7000E. This SIM module operates through AT commands and I need to send these commands through an UART connected between mentioned boards.
I have already set up the UART in the B-L072Z-LRWAN1 and I am able to transmit bytes of information, but I am not sure how to send AT commands.
Which is the format I have to use to send the commands? Do I use char variables? Do I use uint8_t variables and add '0' at the end to make them chars? Do I need to add \n\r at the end of the command?
I am a little bit confused so I need your help. Thank you!
1 Answer 1
char
and uint8_t
should be equivalent on ARM, in other words, char
should be unsigned
, but there are toolchains out there with char
by default signed. It does not matter in this case anyway, because AT
commands would only use characters in the [0-127] range.
Adding a \r
at the end of the command is mandatory, \n
and \x00
would probably be ignored, but better not send them. Responses are terminated with \r\n
(not \n\r
)
-
\$\begingroup\$ You are completely right. I ended up using a char array for the command terminated in \r. I am able to send the commands and get the response. Thank you! \$\endgroup\$user197178– user1971782018年11月21日 21:33:45 +00:00Commented Nov 21, 2018 at 21:33
strlen()
is defined asThe strlen() function calculates the length of the string s, excluding the terminating null byte ('0円').
Sostren(command)
already excludes the 0 byte. I would say most likely cause of problem would be a mismatch in BAUD, parity or number of stop bits. \$\endgroup\$