Skip to main content
Version: v4.0.0 [Denim]

Single variable callback

This example is very similar to the previous example. However, in this example the xApp selects the periodicity of the E2 Indication messages i.e., xapp.PERIODICITY_10_MS and it manually unsubscribes xapp.stop_mntr(token) after 3 seconds i.e., time.sleep(3). The value from the E2 Indication message arrives into def cb(self,v): from where it can be processed.

import sys
import time
import xapp_usr_sdk as xapp

class Monitor(xapp.mntr_cb_fn):
# Inherit C++ mntr_cb_fn class
def __init__(self):
xapp.mntr_cb_fn.__init__(self)

# Override C++ method
def cb(self,v):
print("Value " + str(v))

xapp.init(sys.argv)
nodes = xapp.e2_nodes(xapp.MONITOR_USE_CASE_e)
assert(len(nodes) > 0 and "Needed at least one E2 node to monitor")

call_back = Monitor().__disown__()

token = xapp.mntr_cb(nodes[0].node, xapp.PDCP_SDU_VOLUME_DL, xapp.PERIODICITY_10_MS, call_back)

time.sleep(3)

xapp.stop_mntr(token)

print("Test xApp run SUCCESSFULLY")