GPS tracker code documentation
 All Classes Files Functions Variables Macros Pages
Functions | Variables
sim808.c File Reference

Implementations of functions that communicate directly with the SIM808 module and control it. More...

#include <string.h>
#include <stdio.h>
#include "sim808.h"
Include dependency graph for sim808.c:

Functions

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)
 
void HAL_UART_RxCpltCallback (UART_HandleTypeDef *huart)
 is called when the receive buffer of any UART has received 1 byte. it copies the received byte into the receive buffer which is a global variable: sim_rx_buffer. it also increases by one the counter of received bytes: rx_index. Which points to the next free index in the receive buffer. usart1 is always used to communicate with SIM module therefore AT_uart is defined as usart1. 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 is_subarray_present (const uint8_t *array, size_t array_len, const uint8_t *subarray, size_t subarray_len)
 
uint8_t send_serial_data (uint8_t *data, uint8_t length, char *cmd_reply, uint32_t rx_timeout)
 sends raw serial data to the SIM808 module through the AT_uart peripheral. Then it deletes the receive buffer. More...
 

Variables

UART_HandleTypeDef huart1
 
UART_HandleTypeDef huart2
 

Detailed Description

Implementations of functions that communicate directly with the SIM808 module and control it.

Author
Mohamed Boubaker
Bug:
issue #9

Function Documentation

void HAL_UART_RxCpltCallback ( UART_HandleTypeDef *  huart)

is called when the receive buffer of any UART has received 1 byte. it copies the received byte into the receive buffer which is a global variable: sim_rx_buffer. it also increases by one the counter of received bytes: rx_index. Which points to the next free index in the receive buffer. usart1 is always used to communicate with SIM module therefore AT_uart is defined as usart1.

uint8_t is_subarray_present ( const uint8_t *  array,
size_t  array_len,
const uint8_t *  subarray,
size_t  subarray_len 
)

Here is the caller graph for this function:

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
cmdis the AT command to be sent
expected_replyis used to determine if the outcome of the function is SUCCESS or FAIL.
save_replyif set to 1, then the reply from the module gets copied into cmd_reply.
cmd_replyis an array where to modules reply is copied.
rx_timeoutthe 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.

Here is the call graph for this function:

Here is the caller graph for this function:

void send_debug ( const char *  debug_msg)

sends a debug message through the debug UART

Parameters
debug_messageis the debug message.

Here is the caller graph for this function:

void send_raw_debug ( uint8_t *  debug_dump,
uint8_t  length 
)

Here is the caller graph for this function:

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
cmdcontains the command
rx_waitwaiting time before exit. To make sure the reply is received.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
simis the definition of the sim808 hardware
Returns
SUCCESS if module is ready for use, FAIL otherwise

Here is the call graph for this function:

uint8_t sim_power_off ( SIM808_typedef sim)

power_off the module.

Parameters
simis the definition of the sim808 hardware
Returns
SUCCESS if module is ready for use, FAIL otherwise

Here is the call graph for this function:

Here is the caller graph for this function:

void system_reset ( SIM808_typedef sim)

power_off the module and reset the MCU

Parameters
simis the definition of the sim808 hardware

Here is the call graph for this function:

Variable Documentation

UART_HandleTypeDef huart1
UART_HandleTypeDef huart2