7 /*****************************************************************************/
8 /* Local prototypes. */
9 /*****************************************************************************/
10 static void demo_state_change(void);
12 int main(int argc, char ** argv)
14 EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
15 EVENT_HEADER * heartbeat = NULL;
17 printf("\nHello AT&T Vendor Event world!\n");
23 "Usage: %s <FQDN>|<IP address> <port> "
24 "<username> <password>\n", argv[0]);
28 /***************************************************************************/
30 /***************************************************************************/
31 if (evel_initialize(argv[1], /* FQDN */
32 atoi(argv[2]), /* Port */
33 NULL, /* optional path */
34 NULL, /* optional topic */
36 argv[3], /* Username */
37 argv[4], /* Password */
38 EVEL_SOURCE_VIRTUAL_MACHINE, /* Source type */
39 "EVEL training demo", /* Role */
42 fprintf(stderr, "\nFailed to initialize the EVEL library!!!\n");
47 printf("\nInitialization completed\n");
50 /***************************************************************************/
51 /* Send a heartbeat just to show we're alive! */
52 /***************************************************************************/
53 heartbeat = evel_new_heartbeat();
54 if (heartbeat != NULL)
56 evel_rc = evel_post_event(heartbeat);
57 if (evel_rc != EVEL_SUCCESS)
59 printf("Post failed %d (%s)", evel_rc, evel_error_string());
64 printf("New heartbeat failed");
67 /***************************************************************************/
68 /* Raise a state change */
69 /***************************************************************************/
72 /***************************************************************************/
74 /***************************************************************************/
77 printf("Terminated\n");
82 /**************************************************************************//**
83 * Create and send a state change event.
84 *****************************************************************************/
85 void demo_state_change(void)
87 EVENT_STATE_CHANGE * state_change = NULL;
88 EVEL_ERR_CODES evel_rc = EVEL_SUCCESS;
90 /***************************************************************************/
92 /***************************************************************************/
93 state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE,
94 EVEL_ENTITY_STATE_OUT_OF_SERVICE,
96 if (state_change != NULL)
98 evel_state_change_type_set(state_change, "State Change");
99 evel_state_change_addl_field_add(state_change, "Name1", "Value1");
100 evel_state_change_addl_field_add(state_change, "Name2", "Value2");
101 evel_rc = evel_post_event((EVENT_HEADER *)state_change);
102 if (evel_rc == EVEL_SUCCESS)
104 printf("Post OK!\n");
108 printf("Post Failed %d (%s)\n", evel_rc, evel_error_string());
113 printf("Failed to create event (%s)\n", evel_error_string());
116 printf(" Processed State Change\n");