43typedef enum : uint32_t {
72 {
"ATE0",
"\r\nOK\r\n"},
73 {
"AT+CMEE=1",
"\r\nOK\r\n"},
74 {
"AT+CPIN?",
"\r\n+CPIN: READY\r\n\r\nOK\r\n"},
75 {
"AT+CSQ",
"\r\n+CSQ: 17,99\r\n\r\nOK\r\n"},
76 {
"AT+CREG=1",
"\r\nOK\r\n\r\n+CREG: 1\r\n"},
77 {
"AT+CREG?",
"\r\n+CREG: 1,1\r\n\r\nOK\r\n"},
78 {
"AT+CGATT?",
"\r\n+CGATT: 1\r\n\r\nOK\r\n"},
116 while ((n < out_cap) && (resp[n] !=
'\0')) {
117 out[n] = (uint8_t)resp[n];
140 for (uint32_t i = 0U; i < count; i++) {
169 if ((out ==
nullptr) || (out_cap == 0U)) {
201 (void)
priv_emu_io_errf(
" AT modem : %u command(s) answered, %u +CME ERROR\n",
void board_modem_reset(void)
Clear the modem's parser state (keeps the attached flag).
static RA8_INTERNAL uint32_t internal_modem_emit(const char *resp, uint8_t *out, uint32_t out_cap)
Copy a NUL-terminated response into out, bounded by out_cap.
uint8_t board_modem_channel(void)
SCI channel the modem is wired to (RXD7 / TXD7 = SCI7).
static RA8_INTERNAL uint32_t internal_modem_answer_line(uint8_t *out, uint32_t out_cap)
Answer the completed command line in s_modem.cmd.
uint32_t board_modem_feed_tx(uint8_t tx, uint8_t *out, uint32_t out_cap)
Feed one firmware-transmitted byte into the modem and drain a reply.
bool board_modem_attached(void)
Report whether the AT modem model is currently attached.
static const char s_k_modem_cme_error[]
Response for a command not present in s_k_modem_script.
modem_geom_t
Sizing constants for the modem line model (no magic numbers).
@ k_modem_cr
Carriage return (line terminator).
@ k_modem_resp_cap
Longest scripted response.
@ k_modem_lf
Line feed (dropped from the line).
@ k_modem_cmd_cap
Longest AT command line accepted.
@ k_modem_channel
RXD7/TXD7 = SCI7 (MikroBUS UART).
static modem_model_t s_modem
The single modelled modem.
static const modem_reply_t s_k_modem_script[]
The AT script the modelled modem answers.
void board_modem_report(void)
Print a one-line end-of-run summary if the modem was exercised.
bool board_modem_attach(void)
Attach (arm) the modelled AT cellular modem.
Cellular AT-modem device model for ra8_emulator (attached to SCI7 UART).
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
int strcmp(const char *s1, const char *s2)
Compare two null-terminated strings.
The modelled modem's whole state.
char cmd[k_modem_cmd_cap]
Command-line accumulator.
bool attached
–modem armed the modem.
uint32_t cmd_len
Bytes buffered in cmd.
uint32_t answered
Commands answered OK/URC.
uint32_t errors
Commands answered +CME ERROR.
One scripted (command -> response) pair.
const char * resp
Bytes the modem returns (CRLF-framed).
const char * cmd
AT command WITHOUT the trailing CR.