kopia lustrzana https://github.com/SP8EBC/ParaTNC
did with string content
rodzic
280a12e9f1
commit
56d0f440b8
|
@ -21,14 +21,42 @@
|
|||
|
||||
#include "./kiss_communication/kiss_xmacro_helpers.h"
|
||||
#include "rte_wx.h"
|
||||
#include "main_master_time.h"
|
||||
#include "main.h"
|
||||
#include "rte_main.h"
|
||||
#include "gsm/sim800c.h"
|
||||
|
||||
//!< Dummy variable used only as end of definition marker in tables
|
||||
extern char did_dummy_data;
|
||||
|
||||
//!< Definition of all DIDs with theirs source data for PARAMETEO platform
|
||||
#if defined(PARAMETEO)
|
||||
#define DIDS_STRING(ENTRY) \
|
||||
ENTRY(0x1500U, gsm_sim800_registered_network) \
|
||||
ENTRY(0x1501U, gsm_sim800_simcard_status_string) \
|
||||
ENTRY(0x1502U, gsm_sim800_cellid) \
|
||||
ENTRY(0x1503U, gsm_sim800_lac) \
|
||||
|
||||
#define DIDS_FLOAT(ENTRY) \
|
||||
ENTRY(0x2000U, &rte_wx_temperature_average_external_valid, 0x0, 0x0) \
|
||||
ENTRY(0x2001U, &rte_wx_temperature_internal_valid, 0x0, 0x0) \
|
||||
ENTRY(0x2002U, &rte_wx_pressure_history[0], &rte_wx_pressure_history[1], &rte_wx_pressure_history[2]) \
|
||||
ENTRY(0x1505U, &gsm_sim800_signal_level_dbm, 0x0, 0x0) \
|
||||
|
||||
#define DIDS_NUMERIC(ENTRY) \
|
||||
ENTRY(0x1234U, &rte_wx_temperature_average_dallas, &rte_wx_temperature_average_pt, &rte_wx_temperature_average_internal) \
|
||||
ENTRY(0x1000U, &master_time, 0x0, 0x0) \
|
||||
ENTRY(0x1001U, &rx10m, 0x0, 0x0) \
|
||||
ENTRY(0x1002U, &tx10m, 0x0, 0x0) \
|
||||
ENTRY(0x1003U, &digi10m, 0x0, 0x0) \
|
||||
ENTRY(0x1004U, &digidrop10m, 0x0, 0x0) \
|
||||
ENTRY(0x1100U, &rte_main_battery_voltage, &rte_main_average_battery_voltage, 0x0) \
|
||||
ENTRY(0x2003U, &rte_wx_temperature_average_dallas, &rte_wx_temperature_average_pt, &rte_wx_temperature_average_internal) \
|
||||
ENTRY(0x2004U, &rte_wx_average_winddirection, &rte_wx_average_windspeed, &rte_wx_max_windspeed) \
|
||||
ENTRY(0x2005U, &rte_wx_windspeed[0], &rte_wx_windspeed[1], &rte_wx_windspeed[2]) \
|
||||
ENTRY(0x2006U, &rte_wx_winddirection[0], &rte_wx_winddirection[1], &rte_wx_winddirection[2]) \
|
||||
ENTRY(0x2007U, &rte_wx_humidity, 0x0, 0x0) \
|
||||
ENTRY(0x2008U, &rte_wx_humidity, 0x0, 0x0) \
|
||||
ENTRY(0x1504U, &gsm_sim800_signal_level_dbm, 0x0, 0x0) \
|
||||
ENTRY(0xFFFFU, &did_dummy_data, &did_dummy_data, &did_dummy_data)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -38,4 +38,15 @@
|
|||
.third_data_size = 0 \
|
||||
},
|
||||
|
||||
#define DID_NUMERIC_STRING_DEFINITION_EXPANDER(id, string_pointer ) \
|
||||
{ \
|
||||
.identifier = id, \
|
||||
.first_data = (void*)string_pointer, \
|
||||
.first_data_size = 0, \
|
||||
.second_data = (void*)0xDEADBEEFu, \
|
||||
.second_data_size = 0, \
|
||||
.third_data = (void*)0xDEADBEEFu, \
|
||||
.third_data_size = 0 \
|
||||
},
|
||||
|
||||
#endif /* KISS_XMACRO_HELPERS_H_ */
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <etc/kiss_did_configuration.h>
|
||||
#include <etc/kiss_configuation.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef STM32F10X_MD_VL
|
||||
#include <stm32f10x.h>
|
||||
#define SRAM1_SIZE_MAX (0x00002000UL) /*!< maximum SRAM1 size (up to 96 KBytes) */
|
||||
|
@ -36,6 +38,8 @@ typedef struct kiss_did_numeric_definition_t {
|
|||
|
||||
//!< Definition of all DIDs with numeric data
|
||||
const static kiss_did_numeric_definition_t kiss_did_def[] = {
|
||||
DIDS_STRING(DID_NUMERIC_STRING_DEFINITION_EXPANDER)
|
||||
DIDS_FLOAT(DID_NUMERIC_FLOAT_DEFINITION_EXPANDER)
|
||||
DIDS_NUMERIC(DID_NUMERIC_DEFINITION_EXPANDER)
|
||||
};
|
||||
|
||||
|
@ -74,6 +78,25 @@ static uint8_t kiss_did_how_much_data(kiss_did_numeric_definition_t * definition
|
|||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this DID return string data
|
||||
* @param definition
|
||||
* @return
|
||||
*/
|
||||
static int kiss_did_validate_is_string(kiss_did_numeric_definition_t * definition) {
|
||||
int out = 0;
|
||||
|
||||
if (definition != 0) {
|
||||
if (kiss_did_how_much_data(definition) == 3) {
|
||||
if (definition->second_data == (void*)0xDEADBEEFu && definition->third_data == (void*)0xDEADBEEFu) {
|
||||
out = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if DID configuration is anything valid
|
||||
* @param definition
|
||||
|
@ -209,6 +232,9 @@ uint8_t kiss_did_response(uint16_t identifier, uint8_t * output_buffer, uint16_t
|
|||
// check is valid
|
||||
const int is_valid = kiss_did_validate(&found, &number_of_data_source);
|
||||
|
||||
// check if this is string did
|
||||
const int is_string = kiss_did_validate_is_string(&found);
|
||||
|
||||
// if something has been found and it is valid
|
||||
if (found.identifier != 0xFFFFu && is_valid == 1) {
|
||||
|
||||
|
@ -261,6 +287,20 @@ uint8_t kiss_did_response(uint16_t identifier, uint8_t * output_buffer, uint16_t
|
|||
// also include size_byte in this calculation
|
||||
out++;
|
||||
|
||||
}
|
||||
else if (found.identifier != 0xFFFFu && is_string == 1) {
|
||||
// if this is a string DID
|
||||
const char * str = (char *)found.first_data;
|
||||
|
||||
const size_t str_len = strlen(str);
|
||||
|
||||
if (str_len > buffer_ln) {
|
||||
memcpy(output_buffer, found.first_data, buffer_ln);
|
||||
}
|
||||
else {
|
||||
memcpy(output_buffer, found.first_data, str_len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return out;
|
||||
|
|
Ładowanie…
Reference in New Issue