Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
gsm.c File Reference
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "gsm.h"
#include "mcu_periph/uart.h"
#include "std.h"
#include "modules/datalink/downlink.h"
#include "modules/gps/gps.h"
#include "autopilot.h"
#include "modules/energy/electrical.h"
#include "generated/settings.h"
#include "led.h"
Include dependency graph for gsm.c:

Go to the source code of this file.

Macros

#define GSM_LINK   UART3100
#define GSM_MAX_PAYLOAD   160
#define GSMLinkDev   (&(GSM_LINK).device)
#define GSMLinkChAvailable()
#define GSMLinkTransmit(_c)
#define GSMLinkGetch()
#define ReadGSMBuffer()
#define CTRLZ   0x1A
#define GSM_ORIGIN_MAXLEN   32
#define DATA_MAXLEN   128
#define CMTI   "+CMTI:"
#define MAXLEN_CMTI_ANSWER   32
#define MAXLEN_SMS_CONTENT   DATA_MAXLEN
#define STATUS_NONE   0
#define STATUS_CSQ   1
#define STATUS_REQUESTING_MESSAGE   2
#define STATUS_SEND_AT   3
#define STATUS_SEND_CMGF   4
#define STATUS_SEND_CNMI   5
#define STATUS_SEND_CPMS   6
#define STATUS_RECEPTION_SMS2   7
#define STATUS_WAITING_DATA   8
#define STATUS_IDLE   9
#define STATUS_WAITING_PROMPT   10
#define STATUS_DELETE_SMS   11
#define STATUS_POWERON   12

Functions

static void Send_AT (void)
static void Send_CMGF (void)
static void Send_CNMI (void)
static void Send_CPMS (void)
static void Suppr_SMS (int)
static void gsm_send_report_continue (void)
static void gsm_parse (uint8_t c)
static void gsm_got_line (void)
static void gsm_got_prompt (void)
static void gsm_receive_content (void)
 Receiving a SMS, third step, content in gsm_buf Message can be Bdd where dd is a block index on two digits.
static void request_for_msg (void)
static void Send_CSQ (void)
static void Send (const char string[])
static void parse_msg_header (void)
 Message header in gsm_bug.
static char * indexn (char *, char, uint8_t)
void gsm_init (void)
void gsm_init_report (void)
void gsm_event (void)
void gsm_send_report ()

Variables

static bool gsm_line_received
static bool prompt_received
static bool waiting_for_reply
static char expected_ack [10]
static char gsm_buf [GSM_MAX_PAYLOAD]
static uint8_t gsm_buf_idx
static uint8_t gsm_buf_len
static char origin [GSM_ORIGIN_MAXLEN]
static char data_to_send [DATA_MAXLEN]
static uint8_t gsm_status = STATUS_NONE
static uint8_t index_msg
static uint8_t gcs_index
static uint8_t gcs_index_max

Macro Definition Documentation

◆ CMTI

#define CMTI   "+CMTI:"

Definition at line 87 of file gsm.c.

Referenced by gsm_got_line().

◆ CTRLZ

#define CTRLZ   0x1A

Definition at line 83 of file gsm.c.

Referenced by gsm_got_prompt().

◆ DATA_MAXLEN

#define DATA_MAXLEN   128

Definition at line 85 of file gsm.c.

◆ GSM_LINK

#define GSM_LINK   UART3100

Definition at line 70 of file gsm.c.

◆ GSM_MAX_PAYLOAD

#define GSM_MAX_PAYLOAD   160

Definition at line 73 of file gsm.c.

Referenced by gsm_parse().

◆ GSM_ORIGIN_MAXLEN

#define GSM_ORIGIN_MAXLEN   32

Definition at line 84 of file gsm.c.

◆ GSMLinkChAvailable

#define GSMLinkChAvailable ( )
Value:
GSMLinkDev->check_available(GSMLinkDev->periph)
#define GSMLinkDev
Definition gsm.c:75

Definition at line 77 of file gsm.c.

Referenced by gsm_event().

◆ GSMLinkDev

#define GSMLinkDev   (&(GSM_LINK).device)

Definition at line 75 of file gsm.c.

◆ GSMLinkGetch

#define GSMLinkGetch ( )
Value:
GSMLinkDev->get_byte(GSMLinkDev->periph)

Definition at line 79 of file gsm.c.

◆ GSMLinkTransmit

#define GSMLinkTransmit ( _c)
Value:
GSMLinkDev->put_byte(GSMLinkDev->periph, 0, _c)

Definition at line 78 of file gsm.c.

◆ MAXLEN_CMTI_ANSWER

#define MAXLEN_CMTI_ANSWER   32

Definition at line 88 of file gsm.c.

Referenced by gsm_got_line().

◆ MAXLEN_SMS_CONTENT

#define MAXLEN_SMS_CONTENT   DATA_MAXLEN

Definition at line 89 of file gsm.c.

Referenced by gsm_receive_content().

◆ ReadGSMBuffer

#define ReadGSMBuffer ( )
Value:
static void gsm_parse(uint8_t c)
Definition gsm.c:473
#define GSMLinkChAvailable()
Definition gsm.c:77
#define GSMLinkGetch()
Definition gsm.c:79
static bool gsm_line_received
Definition gsm.c:91

Definition at line 80 of file gsm.c.

Referenced by gsm_event().

◆ STATUS_CSQ

#define STATUS_CSQ   1

Definition at line 105 of file gsm.c.

Referenced by gsm_got_line(), and gsm_send_report().

◆ STATUS_DELETE_SMS

#define STATUS_DELETE_SMS   11

Definition at line 115 of file gsm.c.

Referenced by gsm_got_line().

◆ STATUS_IDLE

#define STATUS_IDLE   9

Definition at line 113 of file gsm.c.

Referenced by gsm_got_line(), gsm_got_prompt(), and gsm_send_report().

◆ STATUS_NONE

#define STATUS_NONE   0

Definition at line 104 of file gsm.c.

Referenced by gsm_init(), and gsm_init_report().

◆ STATUS_POWERON

#define STATUS_POWERON   12

Definition at line 116 of file gsm.c.

Referenced by gsm_init().

◆ STATUS_RECEPTION_SMS2

#define STATUS_RECEPTION_SMS2   7

Definition at line 111 of file gsm.c.

◆ STATUS_REQUESTING_MESSAGE

#define STATUS_REQUESTING_MESSAGE   2

Definition at line 106 of file gsm.c.

Referenced by gsm_got_line().

◆ STATUS_SEND_AT

#define STATUS_SEND_AT   3

Definition at line 107 of file gsm.c.

Referenced by gsm_got_line(), and gsm_init_report().

◆ STATUS_SEND_CMGF

#define STATUS_SEND_CMGF   4

Definition at line 108 of file gsm.c.

Referenced by gsm_got_line().

◆ STATUS_SEND_CNMI

#define STATUS_SEND_CNMI   5

Definition at line 109 of file gsm.c.

Referenced by gsm_got_line().

◆ STATUS_SEND_CPMS

#define STATUS_SEND_CPMS   6

Definition at line 110 of file gsm.c.

Referenced by gsm_got_line().

◆ STATUS_WAITING_DATA

#define STATUS_WAITING_DATA   8

Definition at line 112 of file gsm.c.

Referenced by gsm_got_line().

◆ STATUS_WAITING_PROMPT

#define STATUS_WAITING_PROMPT   10

Definition at line 114 of file gsm.c.

Referenced by gsm_got_line(), and gsm_got_prompt().

Function Documentation

◆ gsm_event()

void gsm_event ( void )

Definition at line 179 of file gsm.c.

References DefaultChannel, DefaultDevice, gsm_buf, gsm_buf_len, gsm_got_line(), gsm_got_prompt(), gsm_line_received, GSMLinkChAvailable, prompt_received, and ReadGSMBuffer.

Here is the call graph for this function:

◆ gsm_got_line()

void gsm_got_line ( void )
static

◆ gsm_got_prompt()

void gsm_got_prompt ( void )
static

Definition at line 353 of file gsm.c.

References CTRLZ, data_to_send, gsm_status, Send(), STATUS_IDLE, and STATUS_WAITING_PROMPT.

Referenced by gsm_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gsm_init()

void gsm_init ( void )

Definition at line 144 of file gsm.c.

References gcs_index, gcs_index_max, gsm_status, LED_ON, STATUS_NONE, and STATUS_POWERON.

◆ gsm_init_report()

void gsm_init_report ( void )

Definition at line 167 of file gsm.c.

References gsm_buf_idx, gsm_line_received, gsm_status, Send_AT(), STATUS_NONE, and STATUS_SEND_AT.

Here is the call graph for this function:

◆ gsm_parse()

void gsm_parse ( uint8_t c)
static

Definition at line 473 of file gsm.c.

References gsm_buf, gsm_buf_idx, gsm_buf_len, gsm_line_received, GSM_MAX_PAYLOAD, and prompt_received.

◆ gsm_receive_content()

void gsm_receive_content ( void )
static

Receiving a SMS, third step, content in gsm_buf Message can be Bdd where dd is a block index on two digits.

WARNING: dd > 0 Sdd value where dd>0 is a var index on two digits and value is a float

Definition at line 288 of file gsm.c.

References gsm_buf, indexn(), MAXLEN_SMS_CONTENT, nav_goto_block(), and origin.

Referenced by gsm_got_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gsm_send_report()

void gsm_send_report ( void )

Definition at line 385 of file gsm.c.

References gsm_status, Send_CSQ(), STATUS_CSQ, and STATUS_IDLE.

Here is the call graph for this function:

◆ gsm_send_report_continue()

void gsm_send_report_continue ( void )
static

Definition at line 397 of file gsm.c.

References autopilot, data_to_send, electrical, gcs_index, gcs_index_max, gps, gsm_buf, rssi, and Send().

Referenced by gsm_got_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexn()

char * indexn ( char * s,
char c,
uint8_t n )
static

Definition at line 512 of file gsm.c.

References s.

Referenced by gsm_got_line(), and gsm_receive_content().

Here is the caller graph for this function:

◆ parse_msg_header()

void parse_msg_header ( void )
static

Message header in gsm_bug.

Extraction(buffer2, '"', 1, 1, '"', 1, 0, msg_status);

Definition at line 367 of file gsm.c.

Referenced by gsm_got_line().

Here is the caller graph for this function:

◆ request_for_msg()

void request_for_msg ( void )
static

Definition at line 272 of file gsm.c.

References expected_ack, index_msg, Send(), and waiting_for_reply.

Referenced by gsm_got_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Send()

void Send ( const char string[])
static

Definition at line 498 of file gsm.c.

References DefaultChannel, and DefaultDevice.

Referenced by gsm_got_prompt(), gsm_send_report_continue(), request_for_msg(), Send_AT(), Send_CMGF(), Send_CNMI(), Send_CPMS(), Send_CSQ(), and Suppr_SMS().

Here is the caller graph for this function:

◆ Send_AT()

void Send_AT ( void )
static

Definition at line 435 of file gsm.c.

References expected_ack, Send(), and waiting_for_reply.

Referenced by gsm_init_report().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Send_CMGF()

void Send_CMGF ( void )
static

Definition at line 443 of file gsm.c.

References expected_ack, Send(), and waiting_for_reply.

Referenced by gsm_got_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Send_CNMI()

void Send_CNMI ( void )
static

Definition at line 458 of file gsm.c.

References expected_ack, Send(), and waiting_for_reply.

Referenced by gsm_got_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Send_CPMS()

void Send_CPMS ( void )
static

Definition at line 465 of file gsm.c.

References expected_ack, Send(), and waiting_for_reply.

Referenced by gsm_got_line().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Send_CSQ()

void Send_CSQ ( void )
static

Definition at line 450 of file gsm.c.

References expected_ack, Send(), and waiting_for_reply.

Referenced by gsm_send_report().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Suppr_SMS()

void Suppr_SMS ( int index_)
static

Definition at line 341 of file gsm.c.

References expected_ack, Send(), and waiting_for_reply.

Referenced by gsm_got_line().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ data_to_send

char data_to_send[DATA_MAXLEN]
static

Definition at line 102 of file gsm.c.

Referenced by gsm_got_prompt(), and gsm_send_report_continue().

◆ expected_ack

char expected_ack[10]
static

◆ gcs_index

uint8_t gcs_index
static

Definition at line 139 of file gsm.c.

Referenced by gsm_init(), and gsm_send_report_continue().

◆ gcs_index_max

uint8_t gcs_index_max
static

Definition at line 140 of file gsm.c.

Referenced by gsm_init(), and gsm_send_report_continue().

◆ gsm_buf

char gsm_buf[GSM_MAX_PAYLOAD]
static

◆ gsm_buf_idx

uint8_t gsm_buf_idx
static

Definition at line 100 of file gsm.c.

Referenced by gsm_init_report(), and gsm_parse().

◆ gsm_buf_len

uint8_t gsm_buf_len
static

Definition at line 100 of file gsm.c.

Referenced by gsm_event(), and gsm_parse().

◆ gsm_line_received

bool gsm_line_received
static

Definition at line 91 of file gsm.c.

Referenced by gsm_event(), gsm_init_report(), and gsm_parse().

◆ gsm_status

uint8_t gsm_status = STATUS_NONE
static

Definition at line 118 of file gsm.c.

Referenced by gsm_got_line(), gsm_got_prompt(), gsm_init(), gsm_init_report(), and gsm_send_report().

◆ index_msg

uint8_t index_msg
static

Definition at line 120 of file gsm.c.

Referenced by gsm_got_line(), and request_for_msg().

◆ origin

char origin[GSM_ORIGIN_MAXLEN]
static

Definition at line 101 of file gsm.c.

Referenced by gsm_receive_content(), and mavlink_common_message_handler().

◆ prompt_received

bool prompt_received
static

Definition at line 92 of file gsm.c.

Referenced by gsm_event(), and gsm_parse().

◆ waiting_for_reply

bool waiting_for_reply
static