Paparazzi UAS
v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
|
#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 "subsystems/gps.h"
#include "autopilot.h"
#include "generated/settings.h"
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() GSMLinkDev->check_available(GSMLinkDev->periph) |
#define | GSMLinkTransmit(_c) GSMLinkDev->put_byte(GSMLinkDev->periph, 0, _c) |
#define | GSMLinkGetch() GSMLinkDev->get_byte(GSMLinkDev->periph) |
#define | ReadGSMBuffer() { while (GSMLinkChAvailable&&!gsm_line_received) gsm_parse(GSMLinkGetch()); } |
#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. 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 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 |
#define CMTI "+CMTI:" |
Definition at line 85 of file gsm.c.
Referenced by gsm_got_line().
#define CTRLZ 0x1A |
Definition at line 81 of file gsm.c.
Referenced by gsm_got_prompt().
#define GSM_MAX_PAYLOAD 160 |
Definition at line 71 of file gsm.c.
Referenced by gsm_parse().
#define GSMLinkChAvailable | ( | ) | GSMLinkDev->check_available(GSMLinkDev->periph) |
Definition at line 75 of file gsm.c.
Referenced by gsm_event().
#define GSMLinkGetch | ( | ) | GSMLinkDev->get_byte(GSMLinkDev->periph) |
#define GSMLinkTransmit | ( | _c | ) | GSMLinkDev->put_byte(GSMLinkDev->periph, 0, _c) |
#define MAXLEN_CMTI_ANSWER 32 |
Definition at line 86 of file gsm.c.
Referenced by gsm_got_line().
#define MAXLEN_SMS_CONTENT DATA_MAXLEN |
Definition at line 87 of file gsm.c.
Referenced by gsm_receive_content().
#define ReadGSMBuffer | ( | ) | { while (GSMLinkChAvailable&&!gsm_line_received) gsm_parse(GSMLinkGetch()); } |
Definition at line 78 of file gsm.c.
Referenced by gsm_event().
#define STATUS_CSQ 1 |
Definition at line 103 of file gsm.c.
Referenced by gsm_got_line(), and gsm_send_report().
#define STATUS_DELETE_SMS 11 |
Definition at line 113 of file gsm.c.
Referenced by gsm_got_line().
#define STATUS_IDLE 9 |
Definition at line 111 of file gsm.c.
Referenced by gsm_got_line(), gsm_got_prompt(), and gsm_send_report().
#define STATUS_NONE 0 |
Definition at line 102 of file gsm.c.
Referenced by gsm_init(), and gsm_init_report().
#define STATUS_POWERON 12 |
Definition at line 114 of file gsm.c.
Referenced by gsm_init().
#define STATUS_REQUESTING_MESSAGE 2 |
Definition at line 104 of file gsm.c.
Referenced by gsm_got_line().
#define STATUS_SEND_AT 3 |
Definition at line 105 of file gsm.c.
Referenced by gsm_got_line(), and gsm_init_report().
#define STATUS_SEND_CMGF 4 |
Definition at line 106 of file gsm.c.
Referenced by gsm_got_line().
#define STATUS_SEND_CNMI 5 |
Definition at line 107 of file gsm.c.
Referenced by gsm_got_line().
#define STATUS_SEND_CPMS 6 |
Definition at line 108 of file gsm.c.
Referenced by gsm_got_line().
#define STATUS_WAITING_DATA 8 |
Definition at line 110 of file gsm.c.
Referenced by gsm_got_line().
#define STATUS_WAITING_PROMPT 10 |
Definition at line 112 of file gsm.c.
Referenced by gsm_got_line(), and gsm_got_prompt().
void gsm_event | ( | void | ) |
Definition at line 177 of file gsm.c.
References DefaultChannel, DefaultDevice, gsm_buf, gsm_got_line(), gsm_got_prompt(), gsm_line_received, GSMLinkChAvailable, prompt_received, and ReadGSMBuffer.
|
static |
Start reporting
We did not get the expected answer
Definition at line 196 of file gsm.c.
References CMTI, expected_ack, gsm_buf, gsm_receive_content(), gsm_send_report_continue(), indexn(), MAXLEN_CMTI_ANSWER, parse_msg_header(), request_for_msg(), Send_CMGF(), Send_CNMI(), Send_CPMS(), STATUS_CSQ, STATUS_DELETE_SMS, STATUS_IDLE, STATUS_REQUESTING_MESSAGE, STATUS_SEND_AT, STATUS_SEND_CMGF, STATUS_SEND_CNMI, STATUS_SEND_CPMS, STATUS_WAITING_DATA, STATUS_WAITING_PROMPT, Suppr_SMS(), and waiting_for_reply.
Referenced by gsm_event().
|
static |
Definition at line 351 of file gsm.c.
References CTRLZ, Send(), STATUS_IDLE, and STATUS_WAITING_PROMPT.
Referenced by gsm_event().
void gsm_init | ( | void | ) |
Definition at line 142 of file gsm.c.
References LED_ON, STATUS_NONE, and STATUS_POWERON.
void gsm_init_report | ( | void | ) |
Definition at line 165 of file gsm.c.
References gsm_line_received, Send_AT(), STATUS_NONE, and STATUS_SEND_AT.
|
static |
Definition at line 471 of file gsm.c.
References gsm_buf, gsm_buf_idx, gsm_line_received, GSM_MAX_PAYLOAD, and prompt_received.
|
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 286 of file gsm.c.
References gsm_buf, indexn(), MAXLEN_SMS_CONTENT, and nav_goto_block().
Referenced by gsm_got_line().
void gsm_send_report | ( | void | ) |
Definition at line 383 of file gsm.c.
References Send_CSQ(), STATUS_CSQ, and STATUS_IDLE.
|
static |
Definition at line 395 of file gsm.c.
References autopilot, UtmCoor_i::east, pprz_autopilot::flight_time, gps, gsm_buf, GpsState::gspeed, GpsState::hmsl, GpsState::ned_vel, UtmCoor_i::north, Send(), GpsState::utm_pos, vsupply, and NedCoor_i::z.
Referenced by gsm_got_line().
|
static |
Definition at line 510 of file gsm.c.
Referenced by gsm_got_line(), and gsm_receive_content().
|
static |
Message header in gsm_bug.
Extraction(buffer2, '"', 1, 1, '"', 1, 0, msg_status);
Definition at line 365 of file gsm.c.
Referenced by gsm_got_line().
|
static |
Definition at line 270 of file gsm.c.
References expected_ack, Send(), and waiting_for_reply.
Referenced by gsm_got_line().
|
static |
Definition at line 496 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().
|
static |
Definition at line 433 of file gsm.c.
References expected_ack, Send(), and waiting_for_reply.
Referenced by gsm_init_report().
|
static |
Definition at line 441 of file gsm.c.
References expected_ack, Send(), and waiting_for_reply.
Referenced by gsm_got_line().
|
static |
Definition at line 456 of file gsm.c.
References expected_ack, Send(), and waiting_for_reply.
Referenced by gsm_got_line().
|
static |
Definition at line 463 of file gsm.c.
References expected_ack, Send(), and waiting_for_reply.
Referenced by gsm_got_line().
|
static |
Definition at line 448 of file gsm.c.
References expected_ack, Send(), and waiting_for_reply.
Referenced by gsm_send_report().
|
static |
Definition at line 339 of file gsm.c.
References expected_ack, Send(), and waiting_for_reply.
Referenced by gsm_got_line().
|
static |
|
static |
Definition at line 96 of file gsm.c.
Referenced by gsm_got_line(), request_for_msg(), Send_AT(), Send_CMGF(), Send_CNMI(), Send_CPMS(), Send_CSQ(), and Suppr_SMS().
|
static |
Definition at line 97 of file gsm.c.
Referenced by gsm_event(), gsm_got_line(), gsm_parse(), gsm_receive_content(), and gsm_send_report_continue().
|
static |
Definition at line 98 of file gsm.c.
Referenced by gsm_parse().
|
static |
Definition at line 89 of file gsm.c.
Referenced by gsm_event(), gsm_init_report(), and gsm_parse().
|
static |
|
static |
|
static |
Definition at line 90 of file gsm.c.
Referenced by gsm_event(), and gsm_parse().
|
static |
Definition at line 91 of file gsm.c.
Referenced by gsm_got_line(), request_for_msg(), Send_AT(), Send_CMGF(), Send_CNMI(), Send_CPMS(), Send_CSQ(), and Suppr_SMS().