Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 "subsystems/datalink/downlink.h"
#include "ap_subsystems/datalink/downlink.h"
#include "subsystems/gps.h"
#include "autopilot.h"
#include "estimator.h"
#include "generated/settings.h"
+ Include dependency graph for gsm.c:

Go to the source code of this file.

Macros

#define DOWNLINK_DEVICE   DOWNLINK_AP_DEVICE
 
#define GSM_LINK   Uart3100
 
#define GSM_MAX_PAYLOAD   160
 
#define __GSMLink(dev, _x)   dev##_x
 
#define _GSMLink(dev, _x)   __GSMLink(dev, _x)
 
#define GSMLink(_x)   _GSMLink(GSM_LINK, _x)
 
#define GSMBuffer()   GSMLink(ChAvailable())
 
#define ReadGSMBuffer()   { while (GSMLink(ChAvailable())&&!gsm_line_received) gsm_parse(GSMLink(Getch())); }
 
#define GSMTransmit(_c)   GSMLink(Transmit(_c))
 
#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 char gsm_buf[GSM_MAX_PAYLOAD__attribute__ ((aligned))
 
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. More...
 
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. More...
 
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 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

#define __GSMLink (   dev,
  _x 
)    dev##_x

Definition at line 84 of file gsm.c.

#define _GSMLink (   dev,
  _x 
)    __GSMLink(dev, _x)

Definition at line 85 of file gsm.c.

#define CMTI   "+CMTI:"

Definition at line 97 of file gsm.c.

Referenced by gsm_got_line().

#define CTRLZ   0x1A

Definition at line 93 of file gsm.c.

Referenced by gsm_got_prompt().

#define DATA_MAXLEN   128

Definition at line 95 of file gsm.c.

#define DOWNLINK_DEVICE   DOWNLINK_AP_DEVICE

Definition at line 67 of file gsm.c.

#define GSM_LINK   Uart3100

Definition at line 79 of file gsm.c.

#define GSM_MAX_PAYLOAD   160

Definition at line 82 of file gsm.c.

Referenced by gsm_parse().

#define GSM_ORIGIN_MAXLEN   32

Definition at line 94 of file gsm.c.

#define GSMBuffer ( )    GSMLink(ChAvailable())

Definition at line 88 of file gsm.c.

Referenced by gsm_event().

#define GSMLink (   _x)    _GSMLink(GSM_LINK, _x)

Definition at line 86 of file gsm.c.

#define GSMTransmit (   _c)    GSMLink(Transmit(_c))

Definition at line 91 of file gsm.c.

Referenced by Send().

#define MAXLEN_CMTI_ANSWER   32

Definition at line 98 of file gsm.c.

Referenced by gsm_got_line().

#define MAXLEN_SMS_CONTENT   DATA_MAXLEN

Definition at line 99 of file gsm.c.

Referenced by gsm_receive_content().

#define ReadGSMBuffer ( )    { while (GSMLink(ChAvailable())&&!gsm_line_received) gsm_parse(GSMLink(Getch())); }

Definition at line 89 of file gsm.c.

Referenced by gsm_event().

#define STATUS_CSQ   1

Definition at line 115 of file gsm.c.

Referenced by gsm_got_line(), and gsm_send_report().

#define STATUS_DELETE_SMS   11

Definition at line 125 of file gsm.c.

Referenced by gsm_got_line().

#define STATUS_IDLE   9

Definition at line 123 of file gsm.c.

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

#define STATUS_NONE   0

Definition at line 114 of file gsm.c.

Referenced by gsm_init(), and gsm_init_report().

#define STATUS_POWERON   12

Definition at line 126 of file gsm.c.

Referenced by gsm_init().

#define STATUS_RECEPTION_SMS2   7

Definition at line 121 of file gsm.c.

#define STATUS_REQUESTING_MESSAGE   2

Definition at line 116 of file gsm.c.

Referenced by gsm_got_line().

#define STATUS_SEND_AT   3

Definition at line 117 of file gsm.c.

Referenced by gsm_got_line(), and gsm_init_report().

#define STATUS_SEND_CMGF   4

Definition at line 118 of file gsm.c.

Referenced by gsm_got_line().

#define STATUS_SEND_CNMI   5

Definition at line 119 of file gsm.c.

Referenced by gsm_got_line().

#define STATUS_SEND_CPMS   6

Definition at line 120 of file gsm.c.

Referenced by gsm_got_line().

#define STATUS_WAITING_DATA   8

Definition at line 122 of file gsm.c.

Referenced by gsm_got_line().

#define STATUS_WAITING_PROMPT   10

Definition at line 124 of file gsm.c.

Referenced by gsm_got_line(), and gsm_got_prompt().

Function Documentation

static char gsm_buf [GSM_MAX_PAYLOAD] __attribute__ ( (aligned)  )
static
void gsm_event ( void  )

Definition at line 187 of file gsm.c.

References DefaultChannel, DefaultDevice, gsm_got_line(), gsm_got_prompt(), gsm_line_received, GSMBuffer, prompt_received, and ReadGSMBuffer.

+ Here is the call graph for this function:

static void gsm_got_line ( void  )
static
static void gsm_got_prompt ( void  )
static

Definition at line 361 of file gsm.c.

References CTRLZ, 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:

void gsm_init ( void  )

Definition at line 154 of file gsm.c.

References LED_ON, STATUS_NONE, and STATUS_POWERON.

void gsm_init_report ( void  )

Definition at line 176 of file gsm.c.

References FALSE, gsm_line_received, Send_AT(), STATUS_NONE, and STATUS_SEND_AT.

+ Here is the call graph for this function:

static void gsm_parse ( uint8_t  c)
static

Definition at line 480 of file gsm.c.

References c, gsm_buf_idx, gsm_line_received, GSM_MAX_PAYLOAD, and prompt_received.

static 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 295 of file gsm.c.

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

Referenced by gsm_got_line().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gsm_send_report ( void  )

Definition at line 393 of file gsm.c.

References Send_CSQ(), STATUS_CSQ, and STATUS_IDLE.

+ Here is the call graph for this function:

void gsm_send_report_continue ( void  )
static

Definition at line 405 of file gsm.c.

References i2c_transaction::buf, UtmCoor_i::east, estimator_flight_time, gps, GpsState::gspeed, GpsState::hmsl, GpsState::ned_vel, UtmCoor_i::north, Send(), GpsState::utm_pos, vsupply, and NedCoor_i::z.

Referenced by gsm_got_line().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 517 of file gsm.c.

Referenced by gsm_got_line(), and gsm_receive_content().

+ Here is the caller graph for this function:

static void parse_msg_header ( void  )
static

Message header in gsm_bug.

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

Definition at line 375 of file gsm.c.

Referenced by gsm_got_line().

+ Here is the caller graph for this function:

static void request_for_msg ( void  )
static

Definition at line 279 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:

static void Send ( const char  string[])
static

Definition at line 504 of file gsm.c.

References DefaultChannel, DefaultDevice, and GSMTransmit.

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:

static void Send_AT ( void  )
static

Definition at line 442 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:

static void Send_CMGF ( void  )
static

Definition at line 450 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:

static void Send_CNMI ( 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:

static void Send_CPMS ( void  )
static

Definition at line 472 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:

static void Send_CSQ ( void  )
static

Definition at line 457 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:

void Suppr_SMS ( int  index_)
static

Definition at line 349 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

char data_to_send[DATA_MAXLEN]
static

Definition at line 112 of file gsm.c.

char expected_ack[10]
static
uint8_t gcs_index
static

Definition at line 149 of file gsm.c.

uint8_t gcs_index_max
static

Definition at line 150 of file gsm.c.

uint8_t gsm_buf_idx
static

Definition at line 110 of file gsm.c.

Referenced by gsm_parse().

uint8_t gsm_buf_len
static

Definition at line 110 of file gsm.c.

bool gsm_line_received
static

Definition at line 101 of file gsm.c.

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

uint8_t gsm_status = STATUS_NONE
static

Definition at line 128 of file gsm.c.

uint8_t index_msg
static

Definition at line 130 of file gsm.c.

char origin[GSM_ORIGIN_MAXLEN]
static

Definition at line 111 of file gsm.c.

bool prompt_received
static

Definition at line 102 of file gsm.c.

Referenced by gsm_event(), and gsm_parse().

bool waiting_for_reply
static