kopia lustrzana https://github.com/SP8EBC/ParaTNC
igate packet received from rf network. send status message after gsm module is registered to network and gprs is working
rodzic
3f51027c60
commit
4102d7495b
|
@ -17,7 +17,6 @@ C_SRCS += \
|
|||
../src/configuration_handler.c \
|
||||
../src/delay.c \
|
||||
../src/dummy.c \
|
||||
../src/float_to_string.c \
|
||||
../src/io.c \
|
||||
../src/it_handlers.c \
|
||||
../src/kiss_callback.c \
|
||||
|
@ -51,7 +50,6 @@ OBJS += \
|
|||
./src/configuration_handler.o \
|
||||
./src/delay.o \
|
||||
./src/dummy.o \
|
||||
./src/float_to_string.o \
|
||||
./src/io.o \
|
||||
./src/it_handlers.o \
|
||||
./src/kiss_callback.o \
|
||||
|
@ -85,7 +83,6 @@ C_DEPS += \
|
|||
./src/configuration_handler.d \
|
||||
./src/delay.d \
|
||||
./src/dummy.d \
|
||||
./src/float_to_string.d \
|
||||
./src/io.d \
|
||||
./src/it_handlers.d \
|
||||
./src/kiss_callback.d \
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "gsm/sim800_state_t.h"
|
||||
|
||||
#define SW_VER "EA22"
|
||||
#define SW_DATE "15062023"
|
||||
#define SW_DATE "17062023"
|
||||
#define SW_KISS_PROTO "A"
|
||||
|
||||
#define SYSTICK_TICKS_PER_SECONDS 100
|
||||
|
@ -134,10 +134,17 @@ inline void main_set_monitor(int8_t bit) {
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Block I/O function which waits for all transmission to end
|
||||
*/
|
||||
inline void main_wait_for_tx_complete(void) {
|
||||
while(main_afsk.sending == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset pooling timers values after waking up from deep sleep, to be sure
|
||||
* than
|
||||
*/
|
||||
inline void main_reset_pooling_timers(void) {
|
||||
main_wx_sensors_pool_timer = 35000;
|
||||
|
||||
|
|
|
@ -1178,6 +1178,12 @@ int main(int argc, char* argv[]){
|
|||
rx10m++;
|
||||
#ifdef STM32L471xx
|
||||
rte_main_rx_total++;
|
||||
|
||||
// if aprsis is logged
|
||||
if (aprsis_connected == 1) {
|
||||
aprsis_igate_to_aprsis(&ax25_rxed_frame, &main_callsign_with_ssid);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "api/api.h"
|
||||
#include "pwr_save.h"
|
||||
#include "nvm.h"
|
||||
|
||||
#include "gsm/sim800c_gprs.h"
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
|
@ -62,6 +64,9 @@ uint8_t packet_tx_trigger_tcp = 0;
|
|||
#define RECONNECT_APRSIS (1 << 7)
|
||||
|
||||
nvm_measurement_t packet_tx_nvm;
|
||||
|
||||
//!< Flag set to one after the gsm status message is sent over radio.
|
||||
uint8_t packet_tx_gsm_status_sent = 0;
|
||||
#endif
|
||||
|
||||
void packet_tx_send_wx_frame(void) {
|
||||
|
@ -305,6 +310,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
packet_tx_meteo_counter = 0;
|
||||
}
|
||||
|
||||
// if modus RTU client is enabled with debugging
|
||||
if ((main_config_data_mode->wx_modbus & WX_MODBUS_DEBUG) == WX_MODBUS_DEBUG) {
|
||||
// send the status packet with raw values of all requested modbus-RTU registers
|
||||
if (packet_tx_meteo_counter == (packet_tx_meteo_interval - 1) &&
|
||||
|
@ -340,6 +346,7 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
// wait if serial port is currently used
|
||||
srl_wait_for_tx_completion(main_kiss_srl_ctx_ptr);
|
||||
|
||||
// create wx data packet into specified buffer
|
||||
SendWXFrameToBuffer(rte_wx_average_windspeed, rte_wx_max_windspeed, rte_wx_average_winddirection, rte_wx_temperature_average_external_valid, rte_wx_pressure_valid, rte_wx_humidity_valid, main_kiss_srl_ctx_ptr->srl_tx_buf_pointer, main_kiss_srl_ctx_ptr->srl_tx_buf_ln, &ln);
|
||||
|
||||
srl_start_tx(main_kiss_srl_ctx_ptr, ln);
|
||||
|
@ -352,9 +359,6 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
|
||||
packet_tx_multi_per_call_handler();
|
||||
|
||||
// GET TEMPERATURE FOR TELEMETRY - HAS SIDE EFFECTS
|
||||
//wx_get_temperature_measurement(main_config_data_wx_sources, main_config_data_mode, main_config_data_umb, main_config_data_rtu, &rte_wx_temperature_internal_valid);
|
||||
|
||||
// ASSEMBLY QUALITY FACTORS
|
||||
|
||||
// if there weren't any erros related to the communication with DS12B20 from previous function call
|
||||
|
@ -540,6 +544,29 @@ void packet_tx_handler(const config_data_basic_t * const config_basic, const con
|
|||
packet_tx_telemetry_descr_counter = 0;
|
||||
}
|
||||
|
||||
#ifdef STM32L471xx
|
||||
// if gsm modem is enabled
|
||||
if (main_config_data_mode->gsm != 0) {
|
||||
// if gprs is connected
|
||||
if (gsm_sim800_gprs_ready == 1) {
|
||||
// if no gsm status packet has been sent so far
|
||||
if (packet_tx_gsm_status_sent == 0) {
|
||||
|
||||
// send a status
|
||||
telemetry_send_status_gsm();
|
||||
|
||||
// network parameters are not queries while APRS-IS connection is pending
|
||||
// so no sense to send status more than once after the initialization
|
||||
packet_tx_gsm_status_sent = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
packet_tx_gsm_status_sent = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
void packet_tx_get_current_counters(packet_tx_counter_values_t * out) {
|
||||
|
|
|
@ -97,6 +97,7 @@ void telemetry_send_status_raw_values_modbus(void);
|
|||
void telemetry_send_status_powersave_cutoff(uint16_t battery_voltage, int8_t vbatt_low, int8_t cutoff);
|
||||
void telemetry_send_status_powersave_registers(uint32_t register_last_sleep, uint32_t register_last_wakeup, uint32_t register_counters, uint32_t monitor, uint32_t last_sleep_time);
|
||||
|
||||
void telemetry_send_status_gsm(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,4 +34,6 @@ void gsm_sim800_reset(gsm_sim800_state_t * state);
|
|||
uint8_t gsm_sim800_get_waiting_for_command_response(void);
|
||||
uint16_t gsm_sim800_get_response_start_idx(void);
|
||||
|
||||
void gsm_sim800_create_status(char * buffer, int ln);
|
||||
|
||||
#endif /* INCLUDE_GSM_SIM800C_H_ */
|
||||
|
|
|
@ -29,4 +29,6 @@ void sim800_gprs_create_apn_config_str(char * buffer, uint16_t buffer_ln);
|
|||
void sim800_gprs_response_callback(srl_context_t * srl_context, gsm_sim800_state_t * state, uint16_t gsm_response_start_idx);
|
||||
void sim800_gprs_reset(void);
|
||||
|
||||
void sim800_gprs_create_status(char * buffer, int ln);
|
||||
|
||||
#endif /* INCLUDE_GSM_SIM800C_GPRS_H_ */
|
||||
|
|
|
@ -35,6 +35,13 @@ inline static void text_replace_non_printable_with_space(char * str, uint16_t si
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Goes from the end of the buffer and replace all spaces with null terminator.
|
||||
* Stops on " (double quotation mark) which is also replaced with null, or
|
||||
* at the begining of an string
|
||||
* @param str
|
||||
* @param size
|
||||
*/
|
||||
inline static void text_replace_space_with_null(char * str, uint16_t size) {
|
||||
|
||||
// it goes from the end of a buffer towards its begining
|
||||
|
|
|
@ -27,6 +27,8 @@ const char * telemetry_vbatt_low = "VBATT_LOW";
|
|||
const char * telemetry_vbatt_cutoff = "VBATT_CUTOFF";
|
||||
const char * telemetry_vbatt_unknown = "VBATT_UNKNOWN";
|
||||
|
||||
#include "gsm/sim800c_gprs.h"
|
||||
#include "gsm/sim800c.h"
|
||||
#endif
|
||||
|
||||
void telemetry_send_chns_description_pv(const config_data_basic_t * const config_basic) {
|
||||
|
@ -617,3 +619,26 @@ void telemetry_send_status_powersave_registers(uint32_t register_last_sleep, uin
|
|||
main_wait_for_tx_complete();
|
||||
}
|
||||
|
||||
void telemetry_send_status_gsm(void){
|
||||
main_wait_for_tx_complete();
|
||||
|
||||
// clear buffer
|
||||
memset(main_own_aprs_msg, 0x00, sizeof(main_own_aprs_msg));
|
||||
|
||||
// append general status information about network connection
|
||||
gsm_sim800_create_status(main_own_aprs_msg, OWN_APRS_MSG_LN);
|
||||
|
||||
// measure a lenght of existing status string
|
||||
const size_t size_so_far = strlen(main_own_aprs_msg);
|
||||
|
||||
// append an ip address
|
||||
sim800_gprs_create_status(main_own_aprs_msg + size_so_far, OWN_APRS_MSG_LN - size_so_far);
|
||||
|
||||
// full lenght of status string
|
||||
main_own_aprs_msg_len = strlen(main_own_aprs_msg);
|
||||
|
||||
// send message on radio
|
||||
ax25_sendVia(&main_ax25, main_own_path, main_own_path_ln, main_own_aprs_msg, main_own_aprs_msg_len);
|
||||
afsk_txStart(&main_afsk);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "io.h"
|
||||
|
||||
#include "text.h"
|
||||
#include "float_to_string.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -768,10 +769,13 @@ void gsm_sim800_rx_done_event_handler(srl_context_t * srl_context, gsm_sim800_st
|
|||
else {
|
||||
gsm_sim800_network_status = NETWORK_REGISTERED;
|
||||
|
||||
strncpy(gsm_sim800_registered_network, (const char *)(srl_context->srl_rx_buf_pointer + gsm_response_start_idx + 12), 16);
|
||||
// copy network name from serial buffer into separate module, keep a room for null terminator
|
||||
strncpy(gsm_sim800_registered_network, (const char *)(srl_context->srl_rx_buf_pointer + gsm_response_start_idx + 12), REGISTERED_NETWORK_LN - 1);
|
||||
|
||||
// replace all non printable characters with space
|
||||
text_replace_non_printable_with_space(gsm_sim800_registered_network, REGISTERED_NETWORK_LN);
|
||||
|
||||
// trim network name with excessive spaces
|
||||
text_replace_space_with_null(gsm_sim800_registered_network, REGISTERED_NETWORK_LN);
|
||||
}
|
||||
|
||||
|
@ -783,6 +787,7 @@ void gsm_sim800_rx_done_event_handler(srl_context_t * srl_context, gsm_sim800_st
|
|||
if (comparision_result == 0) {
|
||||
comparision_result = atoi((const char *)(srl_context->srl_rx_buf_pointer + gsm_response_start_idx + 6));
|
||||
|
||||
// recalculate signal level from numeric value into decibels
|
||||
if (comparision_result > 1 && comparision_result < 32) {
|
||||
gsm_sim800_signal_level_dbm = (int8_t)(-110 + 2 * (comparision_result - 2));
|
||||
}
|
||||
|
@ -877,3 +882,25 @@ void gsm_sim800_reset(gsm_sim800_state_t * state) {
|
|||
|
||||
gsm_sim800_tcpip_reset();
|
||||
}
|
||||
|
||||
void gsm_sim800_create_status(char * buffer, int ln) {
|
||||
// buffer to assemble GSM control channel frequency xxx.xxMHz
|
||||
char freq[9];
|
||||
|
||||
// clear the buffer
|
||||
memset(freq, 0x0, 0x9);
|
||||
|
||||
float_to_string(gsm_sim800_bcch_frequency, freq, 9, 2, 3);
|
||||
|
||||
if (buffer != 0) {
|
||||
snprintf(
|
||||
buffer,
|
||||
ln,
|
||||
">[GSM status][network: %s][signal: %ddBm][freq: %s][cellid: %s][lac: %s]",
|
||||
gsm_sim800_registered_network,
|
||||
gsm_sim800_signal_level_dbm,
|
||||
freq,
|
||||
gsm_sim800_cellid,
|
||||
gsm_sim800_lac);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "drivers/serial.h"
|
||||
|
||||
#include "float_to_string.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -193,3 +195,15 @@ void sim800_gprs_reset(void){
|
|||
|
||||
memset (gsm_sim800_ip_address, 0x00, 18);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a text status message
|
||||
* @param buffer
|
||||
* @param ln
|
||||
*/
|
||||
void sim800_gprs_create_status(char * buffer, int ln) {
|
||||
// check if output buffer has been provided
|
||||
if (buffer != 0) {
|
||||
snprintf(buffer, ln, "[IP: %s]", gsm_sim800_ip_address);
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue