-/**
- * \brief Callback on Unicens management results.
- * \note This function must be implemented by the integrator
- * \param pTag - Pointer given by the integrator by UCSI_Init
- * \param code - Result code
- * \param nodeAddress - Node address of the device causing this event
- * \param pNode - Pointer to node structure holding details of changed node
- */
-extern void UCSI_CB_OnMgrReport(void *pTag, Ucs_MgrReport_t code, uint16_t nodeAddress, Ucs_Rm_Node_t *pNode) {
+/** Asynchronous processing of Rx messages in mainloop is recommended */
+STATIC int OnAmsMessageReceivedCB (sd_event_source *source, void *pTag) {
+ ucsContextT *ucsContext = (ucsContextT*) pTag;
+ uint32_t data_sz = 0U;
+ uint8_t *data_ptr = NULL;
+ uint16_t msg_id = 0U;
+ uint16_t src_addr = 0U;
+
+ while (UCSI_GetAmsMessage(&ucsContext->ucsiData, &msg_id, &src_addr, &data_ptr, &data_sz)) {
+ NotifyEventRxMsg(src_addr, msg_id, data_ptr, data_sz);
+ AFB_DEBUG("RX-MSG: src=0x%04X, msg_id=0x%04X, size=%d", src_addr, msg_id, data_sz);
+ UCSI_ReleaseAmsMessage(&ucsContext->ucsiData);
+ }
+
+ return 0;
+}
+
+/** This callback will be raised, when ever an applicative message on the control channel arrived */
+void UCSI_CB_OnAmsMessageReceived(void *pTag)
+{
+ static sd_event_source *src_ptr = NULL;
+
+ if (!src_ptr)
+ {
+ /* first time usage: create and trigger event source */
+ sd_event_add_defer(afb_daemon_get_event_loop(), &src_ptr, &OnAmsMessageReceivedCB, pTag);
+ }
+ else
+ {
+ sd_event_source_set_enabled(src_ptr, SD_EVENT_ONESHOT);
+ }
+}
+
+void UCSI_CB_OnRouteResult(void *pTag, uint16_t routeId, bool isActive, uint16_t connectionLabel)
+{
+ AFB_NOTICE ("Route 0x%X is active=%d, connection label=0x%X", routeId, isActive, connectionLabel);
+}