static void dwcb_DataWritting(swi_av_Asset_t *asset, ///< [IN] the asset receiving the data const char *pathPtr, ///< [IN] the path targeted by the data sent by the server. swi_dset_Iterator_t* data, ///< [IN] the data iterator containing the received data. ///< The data contained in the iterator will be automatically released when the callback returns. int ack_id, ///< [IN] the id to be used to acknowledge the received data. ///< If ack_id=0 then there is no need to acknowledge. void *userDataPtr) { SWI_LOG("AV_TEST", DEBUG, "dwcb_DataWritting: pathPtr=%s, ack_id=%d\n", pathPtr, ack_id); if (strcmp(pathPtr, "sub.path")) { result = 102; waiting_notification = 0; return; } if (data == NULL ) { result = 104; waiting_notification = 0; return; } char *val1 = NULL; if (RC_OK != swi_dset_GetStringByName(data, "foo", (const char**) &val1)) { result = 105; waiting_notification = 0; return; } if (val1 == NULL || strcmp(val1, "bar")) { result = 106; waiting_notification = 0; return; } if (ack_id) swi_av_Acknowledge(ack_id, 42, "some error msg", "now", 0); swi_dset_Destroy(data); result = 0; waiting_notification = 0; return; }
static int test_6_Acknowledge() { swi_status_t res; res = swi_av_Init(); if (res != SWI_STATUS_OK) return res; res = swi_av_Acknowledge(0, 0, "BANG BANG BANG", "now", 0); if (res != SWI_STATUS_OK) return res; res = swi_av_TriggerPolicy("now"); if (res != SWI_STATUS_OK) return res; return 0; }
static int test_6_Acknowledge() { rc_ReturnCode_t res; res = swi_av_Init(); if (res != RC_OK) return res; res = swi_av_Acknowledge(0, 0, "BANG BANG BANG", "now", 0); if (res != RC_OK) return res; res = swi_av_TriggerPolicy("now"); if (res != RC_OK) return res; return 0; }
static void dwcb_DataCommand(swi_av_Asset_t *asset, ///< [IN] the asset receiving the data const char *pathPtr, ///< [IN] the path targeted by the data sent by the server. swi_dset_Iterator_t* data, ///< [IN] the data iterator containing the received data. ///< The data contained in the iterator will be automatically released when the callback returns. int ack_id, ///< [IN] the id to be used to acknowledge the received data. ///< If ack_id=0 then there is no need to acknowledge. void *userDataPtr) { SWI_LOG("AV_TEST", DEBUG, "dwcb_DataCommand: pathPtr=%s, ack_id=%d\n", pathPtr, ack_id); //init result result = 0; if (strcmp(pathPtr, "commands.avTestCommand")) { result = 122; waiting_notification = 0; return; } if (data == NULL ) { result = 124; waiting_notification = 0; return; } rc_ReturnCode_t res = RC_OK; int value1 = -1, value2 = -1, pname1 = -1, pname2 = -1; //init at -1 meaning: not received res = swi_dset_Next(data); while (res == RC_OK && result == 0) { swi_dset_Type_t type = swi_dset_GetType(data); switch (type) { case SWI_DSET_INTEGER: if (strcmp(swi_dset_GetName(data), "param1")) result = 125; else pname1 = 0; if (swi_dset_ToInteger(data) != 42) result = 126; else value1 = 0; break; case SWI_DSET_STRING: if (strcmp(swi_dset_GetName(data), "param2")) result = 127; else pname2 = 0; if (strcmp(swi_dset_ToString(data), "bar")) result = 128; else value2 = 0; break; default: result = 129; //unexpected data! break; } res = swi_dset_Next(data); } //check all param were received if ( result == 0 && (value1 == -1 || value2 == -1 || pname1 == -1 || pname2 == -1)){ result = 130; SWI_LOG("AV_TEST", ERROR, "at least one value was missing (i.e. -1): value1 = %d, value2 = %d, pname1 = %d, pname2 = %d\n", value1, value2, pname1, pname2); } if (ack_id) swi_av_Acknowledge(ack_id, result, "some error msg", "now", 0); swi_dset_Destroy(data); waiting_notification = 0; return; }
static void dwcb_DataWrittingList(swi_av_Asset_t *asset, ///< [IN] the asset receiving the data const char *pathPtr, ///< [IN] the path targeted by the data sent by the server. swi_dset_Iterator_t* data, ///< [IN] the data iterator containing the received data. ///< The data contained in the iterator will be automatically released when the callback returns. int ack_id, ///< [IN] the id to be used to acknowledge the received data. ///< If ack_id=0 then there is no need to acknowledge. void *userDataPtr) { SWI_LOG("AV_TEST", DEBUG, "dwcb_DataWrittingList: pathPtr=%s, ack_id=%d\n", pathPtr, ack_id); if (strcmp(pathPtr, "sub.path")) { result = 112; waiting_notification = 0; return; } if (data == NULL ) { result = 114; waiting_notification = 0; return; } rc_ReturnCode_t res = RC_OK; bool valueOK = true; res = swi_dset_Next(data); while (res == RC_OK && valueOK) { swi_dset_Type_t type = swi_dset_GetType(data); switch (type) { case SWI_DSET_INTEGER: if (swi_dset_ToInteger(data) != 42) valueOK = false; break; case SWI_DSET_STRING: if (strcmp(swi_dset_ToString(data), "bar")) valueOK = false; break; default: break; } res = swi_dset_Next(data); } if (!valueOK) { result = 125; waiting_notification = 0; return; } if (ack_id) swi_av_Acknowledge(ack_id, 42, "some error msg", "now", 0); swi_dset_Destroy(data); result = 0; waiting_notification = 0; return; }