MSG_CLASSIFY_T* DEV_CreateEventNotify(char* subtype, char* message) { MSG_CLASSIFY_T *pRoot = MSG_CreateRoot(); if(!pRoot) return pRoot; CreateEventBody(pRoot, subtype, message); return pRoot; }
MSG_CLASSIFY_T* DEV_CreateFullEventNotify(char* devID, int severity, char* handler, char* subtype, char* message) { MSG_CLASSIFY_T *pRoot = MSG_CreateRoot(); MSG_CLASSIFY_T *pSusiComm, *pEventNotify = NULL; long long tick = 0; int i=0; MSG_ATTRIBUTE_T *attr; if(pRoot) { pSusiComm = MSG_AddJSONClassify(pRoot, TAG_SUSICOMM_ROOT, NULL, false); pEventNotify = MSG_AddJSONClassify(pSusiComm, TAG_EVENT_NOTIFY, NULL, false); CreateEventBody(pEventNotify, subtype, message); attr = MSG_AddJSONAttribute(pEventNotify, TAG_EVENT_SEVERITY); if(attr) MSG_SetFloatValue(attr, severity, NULL, NULL); if(handler) { attr = MSG_AddJSONAttribute(pEventNotify, TAG_EVENT_HANDLER); if(attr) MSG_SetStringValue(attr, handler, NULL); } attr = MSG_AddJSONAttribute(pSusiComm, TAG_SUSICOMM_CMD); if(attr) MSG_SetFloatValue(attr, 2059, NULL, NULL); //fixed to 2059 attr = MSG_AddJSONAttribute(pSusiComm, TAG_SUSICOMM_REQID); if(attr) MSG_SetFloatValue(attr, 2001, NULL, NULL); //fixed to 2001 attr = MSG_AddJSONAttribute(pSusiComm, TAG_SUSICOMM_AGENTID); if(attr) MSG_SetStringValue(attr, devID, NULL); attr = MSG_AddJSONAttribute(pSusiComm, TAG_SUSICOMM_HANDLER_NAME); if(attr) MSG_SetStringValue(attr, "general", NULL); //fixed to 'general' attr = MSG_AddJSONAttribute(pSusiComm, TAG_SUSICOMM_TIMESTAMP); if(attr) { tick = (long long)time((time_t *) NULL); MSG_SetFloatValue(attr, tick, NULL, NULL); } } return pRoot; }