Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NL input and NNE writer for tx_power, earfcn, celevel, etc #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.text.SimpleDateFormat
jobName = "metadata-exporter"
version = "0.1.50"
version = "0.1.60"
build_dir = "build"
buildPackageName = "meta-exporter"

Expand All @@ -11,7 +11,7 @@ node ('dockerslave') {
git branch: 'master', url: '[email protected]:MONROE-PROJECT/Utilities.git'

checkout([$class: 'GitSCM',
branches: [[name: 'master']],
branches: [[name: 'nne-iot']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'metadata-exporter-alt']],
submoduleCfg: [],
Expand Down
16 changes: 14 additions & 2 deletions metadata_exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@
#define DEFAULT_MCCMNC 0
#define DEFAULT_LAC -1
#define DEFAULT_CID -1
#define DEFAULT_LTE_PCI -1
#define DEFAULT_MODE -1
#define DEFAULT_SUBMODE -1
#define DEFAULT_DEVICE_STATE -1

#define DEFAULT_TX_POWER 0
#define DEFAULT_IOT_EARFCN 0
#define DEFAULT_IOT_CELEVEL 0

enum iface_event {
IFACE_EVENT_DEV_STATE=1,
IFACE_EVENT_MODE_CHANGE,
Expand All @@ -79,7 +82,13 @@ enum iface_event {
IFACE_EVENT_UPDATE,
IFACE_EVENT_IP_ADDR_CHANGE,
IFACE_EVENT_LOC_CHANGE,
IFACE_EVENT_NW_MCCMNC_CHANGE
IFACE_EVENT_NW_MCCMNC_CHANGE,
IFACE_EVENT_NSM,
IFACE_EVENT_SYSTEM,
IFACE_EVENT_LTE_CA,
IFACE_EVENT_EARFCN_CHANGE,
IFACE_EVENT_CELEVEL_CHANGE,
IFACE_EVENT_TX_POWER_CHANGE
};

enum conn_event {
Expand Down Expand Up @@ -191,6 +200,9 @@ struct md_iface_event {
uint16_t lte_freq;
uint16_t lac;
uint16_t lte_pci;
uint16_t tx_power;
uint16_t iot_earfcn;
uint16_t iot_celevel;
int8_t rssi;
int8_t ecio;
int8_t lte_rssi;
Expand Down
11 changes: 11 additions & 0 deletions metadata_input_nl_zmq_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ uint8_t parse_iface_event(struct json_object *meta_obj, struct md_iface_event *m
mie->enodeb_id = json_object_get_int(val);
} else if (!strcmp(key, "ca_info")) {
mie->ca_info = json_object_to_json_string_ext(val, JSON_C_TO_STRING_PLAIN);

} else if (!strcmp(key, "tx_power")) {
mie->tx_power = (int32_t) json_object_get_int(val);
} else if (!strcmp(key, "earfcn")) {
mie->iot_earfcn = (uint32_t) json_object_get_int(val);
} else if (!strcmp(key, "celevel")) {
mie->iot_celevel = (uint8_t) json_object_get_int(val);
}
}

Expand Down Expand Up @@ -557,6 +564,10 @@ void init_iface_event(struct md_iface_event *mie)
mie->enodeb_id = DEFAULT_ENODEBID;
mie->device_mode = DEFAULT_MODE;
mie->device_submode = DEFAULT_SUBMODE;

mie->tx_power = DEFAULT_TX_POWER;
mie->iot_earfcn = DEFAULT_IOT_EARFCN;
mie->iot_celevel = DEFAULT_IOT_CELEVEL;
}

void init_conn_event(struct md_conn_event* mce)
Expand Down
12 changes: 6 additions & 6 deletions metadata_input_zeromq.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,15 @@ static uint8_t md_input_zeromq_init(void *ptr, json_object* config)
json_object_object_foreach(subconfig, key, val) {
if (!strcmp(key, "conn")) {
miz->md_zmq_mask |= META_TYPE_CONNECTION;
} else if (!strcmp(key, "pos")) {
} else if (!strcmp(key, "pos")) {
miz->md_zmq_mask |= META_TYPE_POS;
} else if (!strcmp(key, "iface")) {
} else if (!strcmp(key, "iface")) {
miz->md_zmq_mask |= META_TYPE_INTERFACE;
} else if (!strcmp(key, "radio")) {
} else if (!strcmp(key, "radio")) {
miz->md_zmq_mask |= META_TYPE_RADIO;
} else if (!strcmp(key, "system")) {
miz->md_zmq_mask |= META_TYPE_SYSTEM;
}
} else if (!strcmp(key, "system")) {
miz->md_zmq_mask |= META_TYPE_SYSTEM;
}
}
}

Expand Down
77 changes: 76 additions & 1 deletion metadata_writer_nne.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ static struct nne_value md_iface_parse_cid(struct nne_modem *modem, struct md_if
static struct nne_value md_iface_parse_oper(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);
static struct nne_value md_iface_parse_ipaddr(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);
static struct nne_value md_iface_parse_dev_state(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);
static struct nne_value md_iface_parse_imsi(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);
static struct nne_value md_iface_parse_band(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);
static struct nne_value md_iface_parse_frequency(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);
static struct nne_value md_iface_parse_tx_power(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);
static struct nne_value md_iface_parse_earfcn(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);
static struct nne_value md_iface_parse_celevel(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len);

static struct nne_metadata_descr NNE_METADATA_DESCR[] = {
{ NNE_IDX_MODE, "mode", 0, NNE_TYPE_UINT8, IFACE_EVENT_MODE_CHANGE, md_iface_parse_mode },
Expand All @@ -57,7 +63,13 @@ static struct nne_metadata_descr NNE_METADATA_DESCR[] = {
{ NNE_IDX_CID, "cid", 0, NNE_TYPE_STRING, IFACE_EVENT_LOC_CHANGE, md_iface_parse_cid },
{ NNE_IDX_OPER, "oper", 0, NNE_TYPE_UINT32, IFACE_EVENT_NW_MCCMNC_CHANGE, md_iface_parse_oper },
{ NNE_IDX_IPADDR, "ipaddr", 0, NNE_TYPE_STRING, IFACE_EVENT_IP_ADDR_CHANGE, md_iface_parse_ipaddr },
{ NNE_IDX_DEV_STATE, "device_state", 0, NNE_TYPE_UINT8, IFACE_EVENT_DEV_STATE, md_iface_parse_dev_state }
{ NNE_IDX_DEV_STATE, "device_state", 0, NNE_TYPE_UINT8, IFACE_EVENT_DEV_STATE, md_iface_parse_dev_state },
{ NNE_IDX_IMSI, "imsi", 0, NNE_TYPE_STRING, IFACE_EVENT_MODE_CHANGE, md_iface_parse_imsi },
{ NNE_IDX_BAND, "band", 0, NNE_TYPE_UINT8, IFACE_EVENT_LTE_BAND_CHANGE, md_iface_parse_band },
{ NNE_IDX_FREQUENCY, "lte_freq", 0, NNE_TYPE_UINT32, IFACE_EVENT_LTE_BAND_CHANGE, md_iface_parse_frequency },
{ NNE_IDX_TX_POWER, "tx_power", 0, NNE_TYPE_INT32, IFACE_EVENT_TX_POWER_CHANGE, md_iface_parse_tx_power },
{ NNE_IDX_EARFCN, "earfcn", 0, NNE_TYPE_UINT32, IFACE_EVENT_EARFCN_CHANGE, md_iface_parse_earfcn },
{ NNE_IDX_CELEVEL, "celevel", 0, NNE_TYPE_UINT8, IFACE_EVENT_CELEVEL_CHANGE, md_iface_parse_celevel }
};

#define NNE_METADATA_DESCR_LEN (sizeof(NNE_METADATA_DESCR) / sizeof(struct nne_metadata_descr))
Expand Down Expand Up @@ -277,6 +289,66 @@ static struct nne_value md_iface_parse_dev_state(struct nne_modem *modem, struct
return value;
}

static struct nne_value md_iface_parse_imsi(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len)
{
int len = 16;
size_t retval;
struct nne_value value;
value.type = NNE_TYPE_STRING;
value.u.v_str = malloc(len);
if (value.u.v_str != NULL) {
retval = snprintf(value.u.v_str, len, "%s", mie->imsi);
if (retval >= len) {
value.type = NNE_TYPE_NULL;
free(value.u.v_str);
value.u.v_str = NULL;
}
}
else
value.type = NNE_TYPE_NULL;
return value;
}

static struct nne_value md_iface_parse_band(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len)
{
struct nne_value value;
value.type = NNE_TYPE_UINT8;
value.u.v_uint8 = mie->lte_band;
return value;
}

static struct nne_value md_iface_parse_frequency(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len)
{
struct nne_value value;
value.type = NNE_TYPE_UINT32;
value.u.v_uint32 = mie->lte_freq;
return value;
}

static struct nne_value md_iface_parse_celevel(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len)
{
struct nne_value value;
value.type = NNE_TYPE_INT8;
value.u.v_int8 = mie->iot_celevel;
return value;
}

static struct nne_value md_iface_parse_tx_power(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len)
{
struct nne_value value;
value.type = NNE_TYPE_INT32;
value.u.v_int32 = mie->tx_power;
return value;
}

static struct nne_value md_iface_parse_earfcn(struct nne_modem *modem, struct md_iface_event *mie, char *extra, size_t extra_len)
{
struct nne_value value;
value.type = NNE_TYPE_UINT32;
value.u.v_uint32 = mie->iot_earfcn;
return value;
}

static uint8_t md_nne_handle_gps_event(struct md_writer_nne *mwn,
struct md_gps_event *mge)
{
Expand Down Expand Up @@ -692,6 +764,9 @@ static void md_nne_handle_iface_event(struct md_writer_nne *mwn,
"IFACE_EVENT_IP_ADDR_CHANGE",
"IFACE_EVENT_LOC_CHANGE",
"IFACE_EVENT_NW_MCCMNC_CHANGE",
"IFACE_EVENT_TX_POWER_CHANGE",
"IFACE_EVENT_EARFCN_CHANGE",
"IFACE_EVENT_CELEVEL_CHANGE",
};

META_PRINT_SYSLOG(mwn->parent, LOG_ERR, "NNE writer: %s: "
Expand Down
8 changes: 8 additions & 0 deletions metadata_writer_nne.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ enum nne_metadata_idx
NNE_IDX_OPER,
NNE_IDX_IPADDR,
NNE_IDX_DEV_STATE,

NNE_IDX_IMSI,
NNE_IDX_BAND,
NNE_IDX_FREQUENCY,

NNE_IDX_TX_POWER,
NNE_IDX_CELEVEL,
NNE_IDX_EARFCN,
__NNE_IDX_MAX
};

Expand Down
9 changes: 9 additions & 0 deletions metadata_writer_zeromq.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,15 @@ static json_object *md_zeromq_writer_create_iface_json(const struct md_writer_ze
(mie->lte_pci != DEFAULT_LTE_PCI &&
!md_zeromq_writer_create_json_int(obj,
mwz->keys[MD_ZMQ_KEY_LTE_PCI], mie->lte_pci)) ||
(mie->tx_power != DEFAULT_TX_POWER &&
!md_zeromq_writer_create_json_int(obj,
mwz->keys[MD_ZMQ_KEY_TX_POWER], mie->tx_power)) ||
(mie->iot_earfcn != DEFAULT_IOT_EARFCN &&
!md_zeromq_writer_create_json_int(obj,
mwz->keys[MD_ZMQ_KEY_IOT_EARFCN], mie->iot_earfcn)) ||
(mie->iot_celevel != DEFAULT_IOT_CELEVEL &&
!md_zeromq_writer_create_json_int(obj,
mwz->keys[MD_ZMQ_KEY_IOT_CELEVEL], mie->iot_celevel)) ||
(mie->enodeb_id != DEFAULT_ENODEBID &&
!md_zeromq_writer_create_json_int(obj,
mwz->keys[MD_ZMQ_KEY_ENODEB_ID], mie->enodeb_id))) {
Expand Down
4 changes: 4 additions & 0 deletions metadata_writer_zeromq.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ enum md_zmq_keys {
MD_ZMQ_KEY_NMEA,
MD_ZMQ_KEY_SPEED,

MD_ZMQ_KEY_TX_POWER,
MD_ZMQ_KEY_IOT_EARFCN,
MD_ZMQ_KEY_IOT_CELEVEL,

MD_ZMQ_KEY_RADIO_CELL_ID,
MD_ZMQ_KEY_RADIO_PLMN,
MD_ZMQ_KEY_RADIO_LAC,
Expand Down
4 changes: 4 additions & 0 deletions metadata_writer_zeromq_monroe.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const char *monroe_keys[MD_ZMQ_KEYS_MAX + 1] = {
"NMEA",
"Speed",

"TxPower",
"EARFCN",
"CELevel",

"CellID",
"PLMN",
"LAC",
Expand Down
4 changes: 4 additions & 0 deletions metadata_writer_zeromq_nne.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ const char *nne_keys[MD_ZMQ_KEYS_MAX + 1] = {
"nmea_raw",
"speed",

"tx_power",
"earfcn",
"celevel",

"cell_id",
"plmn",
"lac",
Expand Down