diff --git a/Jenkinsfile b/Jenkinsfile index 0bb7194..87c9bea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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" @@ -11,7 +11,7 @@ node ('dockerslave') { git branch: 'master', url: 'git@github.com:MONROE-PROJECT/Utilities.git' checkout([$class: 'GitSCM', - branches: [[name: 'master']], + branches: [[name: 'nne-iot']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'metadata-exporter-alt']], submoduleCfg: [], diff --git a/metadata_exporter.h b/metadata_exporter.h index 0d62462..536aff5 100644 --- a/metadata_exporter.h +++ b/metadata_exporter.h @@ -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, @@ -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 { @@ -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; diff --git a/metadata_input_nl_zmq_common.c b/metadata_input_nl_zmq_common.c index 74b76bb..0a37d6f 100644 --- a/metadata_input_nl_zmq_common.c +++ b/metadata_input_nl_zmq_common.c @@ -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); } } @@ -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) diff --git a/metadata_input_zeromq.c b/metadata_input_zeromq.c index d738c07..50d89e6 100644 --- a/metadata_input_zeromq.c +++ b/metadata_input_zeromq.c @@ -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; + } } } diff --git a/metadata_writer_nne.c b/metadata_writer_nne.c index dbbf6c0..c78621a 100644 --- a/metadata_writer_nne.c +++ b/metadata_writer_nne.c @@ -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 }, @@ -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)) @@ -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) { @@ -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: " diff --git a/metadata_writer_nne.h b/metadata_writer_nne.h index fb9eeef..a3072c6 100644 --- a/metadata_writer_nne.h +++ b/metadata_writer_nne.h @@ -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 }; diff --git a/metadata_writer_zeromq.c b/metadata_writer_zeromq.c index 5c4c2ed..0d65fdb 100644 --- a/metadata_writer_zeromq.c +++ b/metadata_writer_zeromq.c @@ -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))) { diff --git a/metadata_writer_zeromq.h b/metadata_writer_zeromq.h index 1fa196e..0f82690 100644 --- a/metadata_writer_zeromq.h +++ b/metadata_writer_zeromq.h @@ -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, diff --git a/metadata_writer_zeromq_monroe.c b/metadata_writer_zeromq_monroe.c index 7157b3a..b03a4cc 100644 --- a/metadata_writer_zeromq_monroe.c +++ b/metadata_writer_zeromq_monroe.c @@ -63,6 +63,10 @@ const char *monroe_keys[MD_ZMQ_KEYS_MAX + 1] = { "NMEA", "Speed", + "TxPower", + "EARFCN", + "CELevel", + "CellID", "PLMN", "LAC", diff --git a/metadata_writer_zeromq_nne.c b/metadata_writer_zeromq_nne.c index b54639d..7206fc0 100644 --- a/metadata_writer_zeromq_nne.c +++ b/metadata_writer_zeromq_nne.c @@ -65,6 +65,10 @@ const char *nne_keys[MD_ZMQ_KEYS_MAX + 1] = { "nmea_raw", "speed", + "tx_power", + "earfcn", + "celevel", + "cell_id", "plmn", "lac",