Prototypes of functions that communicate with the SIM808 module and control it and definition of related parameters.
More...
#include <stdint.h>
#include "main.h"
Go to the source code of this file.
|
struct | SIM808_typedef |
| is used to abstract the SIM808 hardware interface. It will decouple the functions from the hardware (uart+pins) used to interface with the module. The UART peripheral used to send AT commands to the module and the UART used to send Debug messages and the pins used to power on, reset and check status of the module are combined together in this struct. This struct will be passed to all the functions that perform actions on the module. More...
|
|
|
uint8_t | sim_init (SIM808_typedef *sim) |
| it initialises the SIM808_typedef struct members and powers on the module. initializes the UARTs and the GPIOs used to power on, reset and check the status of the module. Which UART peripheral is used for what is specified in the parameter SIM808_typedef members: AT_uart and debug_uart. More...
|
|
uint8_t | sim_power_off (SIM808_typedef *sim) |
| power_off the module. More...
|
|
void | system_reset (SIM808_typedef *sim) |
| power_off the module and reset the MCU More...
|
|
uint8_t | send_AT_cmd (const char *cmd, const char *expected_reply, uint8_t save_reply, char *cmd_reply, uint32_t rx_timeout) |
| sends a cmd to the module, if the parameter save_reply == 1 then it copies the reply into the parameter cmd_reply. More...
|
|
uint8_t | send_serial_data (uint8_t *data, uint8_t length, char *cmd_reply, uint32_t rx_wait) |
| sends raw serial data to the SIM808 module through the AT_uart peripheral. Then it deletes the receive buffer. More...
|
|
void | send_debug (const char *debug_msg) |
| sends a debug message through the debug UART More...
|
|
void | send_raw_debug (uint8_t *debug_dump, uint8_t length) |
|
uint8_t | is_subarray_present (const uint8_t *array, size_t array_len, const uint8_t *subarray, size_t subarray_len) |
|
Prototypes of functions that communicate with the SIM808 module and control it and definition of related parameters.
- Author
- Mohamed Boubaker
- Bug:
- issue #9
#define BAUD_RATE 38400 /* BAUD_RATE=38400 => it take 26 ms to send 100 bytes */ |
#define GPS_COORDINATES_LENGTH 23 |
#define GREEN_LED GPIO_PIN_13 |
#define RX_BUFFER_LENGTH 256 |
#define RX_WAIT 200 /* After sending AT command, wait RX_WAIT ms to ensure that the reply is receeived in the buffer */ |
#define TCP_CONNECT_TIMEOUT 5 /* value in second */ |
uint8_t is_subarray_present |
( |
const uint8_t * |
array, |
|
|
size_t |
array_len, |
|
|
const uint8_t * |
subarray, |
|
|
size_t |
subarray_len |
|
) |
| |
uint8_t send_AT_cmd |
( |
const char * |
cmd, |
|
|
const char * |
expected_reply, |
|
|
uint8_t |
save_reply, |
|
|
char * |
cmd_reply, |
|
|
uint32_t |
rx_timeout |
|
) |
| |
sends a cmd to the module, if the parameter save_reply == 1 then it copies the reply into the parameter cmd_reply.
- Parameters
-
cmd | is the AT command to be sent |
expected_reply | is used to determine if the outcome of the function is SUCCESS or FAIL. |
save_reply | if set to 1, then the reply from the module gets copied into cmd_reply. |
cmd_reply | is an array where to modules reply is copied. |
rx_timeout | the maximum amount of time the function will wait for the module to receive a reply. |
- Returns
- SUCCESS if the module replies withing timeout and the reply includes the expected_reply, FAIL otherwise.
void send_debug |
( |
const char * |
debug_msg | ) |
|
sends a debug message through the debug UART
- Parameters
-
debug_message | is the debug message. |
void send_raw_debug |
( |
uint8_t * |
debug_dump, |
|
|
uint8_t |
length |
|
) |
| |
uint8_t send_serial_data |
( |
uint8_t * |
data, |
|
|
uint8_t |
length, |
|
|
char * |
cmd_reply, |
|
|
uint32_t |
rx_wait |
|
) |
| |
sends raw serial data to the SIM808 module through the AT_uart peripheral. Then it deletes the receive buffer.
- Parameters
-
cmd | contains the command |
rx_wait | waiting time before exit. To make sure the reply is received. |
it initialises the SIM808_typedef struct members and powers on the module. initializes the UARTs and the GPIOs used to power on, reset and check the status of the module. Which UART peripheral is used for what is specified in the parameter SIM808_typedef members: AT_uart and debug_uart.
- Parameters
-
sim | is the definition of the sim808 hardware |
- Returns
- SUCCESS if module is ready for use, FAIL otherwise
power_off the module.
- Parameters
-
sim | is the definition of the sim808 hardware |
- Returns
- SUCCESS if module is ready for use, FAIL otherwise
power_off the module and reset the MCU
- Parameters
-
sim | is the definition of the sim808 hardware |