Added MQTT client libraries to publish message
This commit is contained in:
@@ -3021,6 +3021,7 @@ target_link_libraries (nr-softmodem
|
||||
X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB}
|
||||
-Wl,--end-group z dl)
|
||||
|
||||
target_link_libraries (nr-softmodem paho-mqtt3cs)
|
||||
target_link_libraries (nr-softmodem ${LIBXML2_LIBRARIES})
|
||||
target_link_libraries (nr-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
|
||||
target_link_libraries (nr-softmodem ${LIB_LMS_LIBRARIES})
|
||||
@@ -3107,6 +3108,7 @@ target_link_libraries (nr-uesoftmodem
|
||||
${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ITTI ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB}
|
||||
-Wl,--end-group z dl)
|
||||
|
||||
target_link_libraries (nr-uesoftmodem paho-mqtt3cs)
|
||||
target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES})
|
||||
target_link_libraries (nr-uesoftmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${XFORMS_LIBRARIES} ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES} ${ATLAS_LIBRARIES})
|
||||
target_link_libraries (nr-uesoftmodem ${LIB_LMS_LIBRARIES})
|
||||
|
||||
@@ -460,6 +460,24 @@ int main( int argc, char **argv ) {
|
||||
}
|
||||
}
|
||||
|
||||
int rc;
|
||||
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
|
||||
if ((rc = MQTTClient_create(&client, ADDRESS, CLIENTID,
|
||||
MQTTCLIENT_PERSISTENCE_NONE, NULL)) != MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
printf("Failed to create MQTT client, return code %d\n", rc);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
conn_opts.keepAliveInterval = 20;
|
||||
conn_opts.cleansession = 1;
|
||||
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
printf("Failed to connect MQTT client, return code %d\n", rc);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
NB_UE_INST=1;
|
||||
NB_INST=1;
|
||||
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_NR_UE **));
|
||||
@@ -545,5 +563,9 @@ int main( int argc, char **argv ) {
|
||||
if (ouput_vcd)
|
||||
vcd_signal_dumper_close();
|
||||
|
||||
if ((rc = MQTTClient_disconnect(client, 10000)) != MQTTCLIENT_SUCCESS)
|
||||
printf("Failed to disconnect MQTT client, return code %d\n", rc);
|
||||
MQTTClient_destroy(&client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,10 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
|
||||
#ifdef DEBUG_PRS_CHEST
|
||||
char filename[128] = {0}, varname[128] = {0};
|
||||
#endif
|
||||
int rc;
|
||||
char payload[128] = {0};
|
||||
MQTTClient_message pubmsg = MQTTClient_message_initializer;
|
||||
MQTTClient_deliveryToken token;
|
||||
|
||||
for(int l = prs_cfg->SymbolStart; l < prs_cfg->SymbolStart+prs_cfg->NumPRSSymbols; l++)
|
||||
{
|
||||
@@ -416,6 +420,7 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
|
||||
&ch_pwr);
|
||||
LOG_I(PHY, "[gNB %d][Rx %d][sfn %d][slot %d] ToA for PRS symbol %2d ==> %d / %d samples, peak channel power %.1f dB\n", gNB_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, l, prs_meas[rxAnt][l].dl_toa-(frame_params->ofdm_symbol_size>>1), frame_params->ofdm_symbol_size, 10*log10(ch_pwr));
|
||||
|
||||
sprintf(payload, "[gNB %d][Rx %d][sfn %d][slot %d] ToA for PRS symbol %2d ==> %d / %d samples, peak channel power %.1f dB\n", gNB_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, l, prs_meas[rxAnt][l].dl_toa-(frame_params->ofdm_symbol_size>>1), frame_params->ofdm_symbol_size, 10*log10(ch_pwr));
|
||||
//prs measurements
|
||||
prs_meas[rxAnt][l].gNB_id = 0;
|
||||
prs_meas[rxAnt][l].timestamp = 0;
|
||||
@@ -425,6 +430,17 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
|
||||
prs_meas[rxAnt][l].rxAnt_idx = rxAnt;
|
||||
prs_meas[rxAnt][l].snr = 0;
|
||||
prs_meas[rxAnt][l].dl_aoa = 0;
|
||||
|
||||
// publish MQTT message
|
||||
pubmsg.payload = payload;
|
||||
pubmsg.payloadlen = (int)strlen(payload);
|
||||
pubmsg.qos = QOS;
|
||||
pubmsg.retained = 0;
|
||||
if ((rc = MQTTClient_publishMessage(client, TOPIC, &pubmsg, &token)) != MQTTCLIENT_SUCCESS)
|
||||
{
|
||||
printf("Failed to publish MQTT message, return code %d\n", rc);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} // for rxAnt
|
||||
} //for l
|
||||
|
||||
|
||||
@@ -111,6 +111,15 @@
|
||||
#include <pthread.h>
|
||||
#include "targets/ARCH/COMMON/common_lib.h"
|
||||
|
||||
#include "MQTTClient.h"
|
||||
#define ADDRESS "tcp://mqtt.eclipseprojects.io:1883"
|
||||
#define CLIENTID "OAI_PRS"
|
||||
#define TOPIC "PRS_TOA"
|
||||
#define PAYLOAD "Hello World! from Eurecom france"
|
||||
#define QOS 1
|
||||
MQTTClient client;
|
||||
|
||||
|
||||
/// Context data structure for gNB subframe processing
|
||||
typedef struct {
|
||||
/// Component Carrier index
|
||||
|
||||
Reference in New Issue
Block a user