cloud/dps_demo/dps_demo_cli_commands.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 "dps_demo_common.h"
#include "gos.h"
// Commands created by this demo
GOS_CMD_CREATE_COMMAND(dps, provision, "dps_provision", "dps_p", 0, 0, true);
GOS_CMD_CREATE_COMMAND(dps, verify, "dps_verify", "dps_v", 0, 0, true);
GOS_DEFINE_COMMAND(dps, provision)
{
gos_result_t result;
result = send_provisioning_request(dps_settings);
if ( result != GOS_SUCCESS )
{
return gos_cmd_format_response(GOS_CMD_FAILED, "Failed to provision device to DMS, error: %d", result);
}
}
GOS_DEFINE_COMMAND(dps, verify)
{
gos_result_t result;
if(strnlen(dps_settings->hostname, MAX_BROKER_HOSTNAME_LENGTH) == 0)
{
return gos_cmd_format_response(GOS_CMD_FAILED, "Please set the dps.hostname variable fist before verifying...");
}
result = validate_device_credentials(dps_settings);
if ( result != GOS_SUCCESS )
{
return gos_cmd_format_response(GOS_CMD_FAILED, "Failed to connect using the device credentials, error: %d", result);
}
}