Add working Hello World example

This commit is contained in:
2019-03-22 20:24:09 +01:00
parent 8847f92528
commit d28f942cf7
28 changed files with 933 additions and 1981 deletions
+14 -21
View File
@@ -58,9 +58,10 @@ hello_world(aisl_stream_t s)
int
main(int argc, char ** argv)
{
aisl_t aisl; /**< AISL instance pointer */
aisl_status_t status; /**< AISL status code */
uint16_t port = 0;
aisl_t aisl; /**< AISL instance pointer */
aisl_status_t status; /**< AISL status code */
struct aisl_config config = AISL_CONFIG_DEFAULT;
uint16_t port = 0;
/* Try to use first argument as a port number */
if (argc > 1)
@@ -71,32 +72,24 @@ main(int argc, char ** argv)
port = DEFAULT_HTTP_PORT;
/* Initialize instance */
if ( (aisl = aisl_new(NULL)) != NULL )
if ( (aisl = aisl_new(&config)) != NULL )
{
if (aisl_listen( aisl, "0.0.0.0", port ) != NULL)
{
aisl_callback_t callback = AISL_CALLBACK(hello_world);
/* Set up request callback */
status = aisl_set_callback( aisl
, NULL
, AISL_EVENT_STREAM_REQUEST
, callback );
aisl_set_callback( aisl
, AISL_EVENT_STREAM_REQUEST
, AISL_CALLBACK(hello_world) );
/* if callback was set, launch application loop */
if ( status == AISL_SUCCESS )
/* launch application loop */
fprintf(stdout, "Entering main loop" );
for(;;)
{
fprintf(stdout, "Entering main loop" );
for(;;)
{
status = aisl_run_cycle(aisl);
status = aisl_run_cycle(aisl);
if ( status != AISL_SUCCESS )
aisl_sleep(aisl, 500);
}
if ( status != AISL_SUCCESS )
aisl_sleep(aisl, 500);
}
else
fprintf(stderr, "Failed to register callback" );
aisl_free(aisl);
}