network/websocket_cmd_stream/main.c

/*******************************************************************************
* # License
* Copyright 2019 Silicon Laboratories Inc. www.silabs.com
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#include "gos.h"
#include "example_app_util.h"
#define APPLICATION_START_LINE "\r\n\r\nWebsocket Command Stream API example starting..."
/*************************************************************************************************/
void gos_app_init(void)
{
gos_result_t result;
GOS_LOG(APPLICATION_START_LINE);
// Load the application settings
if (GOS_FAILED(result, gos_load_app_settings("settings.ini")))
{
GOS_LOG("Failed to load settings, err:%d", result);
return;
}
// Attempt to bringup the network
example_app_util_network_up(GOS_INTERFACE_ANY, true, network_event_handler);
}
/*************************************************************************************************/
static void network_event_handler(bool is_up)
{
if(is_up)
{
char ip_str_buffer[32];
"wlan.network.ip" : "ethernet.network.ip", ip_str_buffer, sizeof(ip_str_buffer));
GOS_LOG("Network up");
GOS_LOG("Open a browser to:\r\n http://%s/cmd_stream.html\r\n\r\n", ip_str_buffer);
}
}