Skip to content

Commit

Permalink
Merging into the (master) branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Microchip Technology committed Apr 15, 2020
1 parent b62f97b commit 09a92ec
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 156 deletions.
19 changes: 14 additions & 5 deletions AVRIoT.X/mcc_generated_files/application_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ static void receivedFromCloud(uint8_t *topic, uint8_t *payload)
holdCount = 2;
}
}
debug_printer(SEVERITY_NONE, LEVEL_NORMAL, "topic: %s", topic);
debug_printer(SEVERITY_NONE, LEVEL_NORMAL, "payload: %s", payload);
debug_printIoTAppMsg("topic: %s", topic);
debug_printIoTAppMsg("payload: %s", payload);
updateDeviceShadow();
}

Expand Down Expand Up @@ -191,7 +191,7 @@ void application_init()
CLI_setdeviceId(attDeviceID);
#endif
debug_setPrefix(attDeviceID);
wifi_readThingIdFromWinc();
wifi_readThingNameFromWinc();
wifi_readAWSEndpointFromWinc();
timeout_create(&initDeviceShadowTimer, DEVICE_SHADOW_INIT_INTERVAL );
// Blocking debounce
Expand Down Expand Up @@ -343,6 +343,11 @@ uint32_t MAIN_dataTask(void *payload)
sendToCloud();
}
}
else
{
ledState.Full2Sec = LED_OFF_STATIC;
LED_modeYellow(ledState);
}

// Blue LED
if (!shared_networking_params.amConnectingAP)
Expand All @@ -361,6 +366,11 @@ uint32_t MAIN_dataTask(void *payload)
ledState.Full2Sec = LED_ON_STATIC;
LED_modeGreen(ledState);
}
else if(shared_networking_params.haveDataConnection == 1)
{
ledState.Full2Sec = LED_BLINK;
LED_modeGreen(ledState);
}
}
}

Expand Down Expand Up @@ -393,7 +403,6 @@ static void wifiConnectionStateChanged(uint8_t status)
// If we have no AP access we want to retry
if (status != 1)
{
// Restart the WIFI module if we get disconnected from the WiFi Access Point (AP)
CLOUD_setInitFlag();
CLOUD_reset();
}
}
106 changes: 0 additions & 106 deletions AVRIoT.X/mcc_generated_files/banner.h

This file was deleted.

17 changes: 9 additions & 8 deletions AVRIoT.X/mcc_generated_files/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ static uint8_t index = 0;
static bool commandTooLongFlag = false;

const char * const cli_version_number = "1.0";
const char * const firmware_version_number = "2.0.2";

const char * const firmware_version_number = "3.0.0";

static void command_received(char *command_text);
static void reset_cmd(char *pArg);
static void reconnect_cmd(char *pArg);
static void set_wifi_auth(char *ssid_pwd_auth);
static void get_thing_id(char *pArg);
static void get_thing_name(char *pArg);
static void get_device_id(char *pArg);
static void get_cli_version(char *pArg);
static void get_firmware_version(char *pArg);
Expand All @@ -100,7 +101,7 @@ const struct cmd commands[] =
{ "reset", reset_cmd},
{ "reconnect", reconnect_cmd },
{ "wifi", set_wifi_auth },
{ "thing", get_thing_id },
{ "thing", get_thing_name },
{ "device", get_device_id },
{ "cli_version", get_cli_version },
{ "version", get_firmware_version },
Expand Down Expand Up @@ -233,9 +234,9 @@ static void set_wifi_auth(char *ssid_pwd_auth)
{
MQTT_Close(MQTT_GetClientConnectionInfo());
}
if (shared_networking_params.haveSocket)
if (shared_networking_params.haveDataConnection)
{ // Disconnect from Socket if active
shared_networking_params.haveSocket = 0;
shared_networking_params.haveDataConnection = 0;
MQTT_Disconnect(MQTT_GetClientConnectionInfo());
}
wifi_disconnectFromAp();
Expand All @@ -261,7 +262,7 @@ static void reconnect_cmd(char *pArg)
LED_modeRed(ledState);
ledState.Full2Sec = LED_BLINK;
LED_modeGreen(ledState);
shared_networking_params.haveSocket = 0;
shared_networking_params.haveDataConnection = 0;
MQTT_Disconnect(MQTT_GetClientConnectionInfo());
printf("OK\r\n");
}
Expand All @@ -288,7 +289,7 @@ static void set_debug_level(char *pArg)
}
}

static void get_thing_id(char *pArg)
static void get_thing_name(char *pArg)
{
(void)pArg;

Expand All @@ -298,7 +299,7 @@ static void get_thing_id(char *pArg)
}
else
{
printf("Error getting Thing ID.\r\n\4");
printf("Error getting Thing Name.\r\n\4");
}
}

Expand Down
12 changes: 4 additions & 8 deletions AVRIoT.X/mcc_generated_files/cloud/cloud_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ cloudContext_t cloudContext =
};


void CLOUD_setInitFlag(void)
void CLOUD_reset(void)
{
debug_printError("CLOUD: Cloud Reset");
cloudStatus.cloudInitialized = false;
Expand Down Expand Up @@ -130,7 +130,7 @@ bool CLOUD_checkIsConnected(void)
uint32_t mqttTimeoutTask(void *payload)
{
debug_printError("CLOUD: MQTT Connection Timeout");
CLOUD_setInitFlag();
CLOUD_reset();

cloudStatus.waitingForMQTT = false;

Expand Down Expand Up @@ -178,6 +178,7 @@ static void startMqttConnectionTimeout()
{
debug_printError("MQTT: MQTT reset timer is created");
timeout_create(&mqttTimeoutTaskTimer, CLOUD_MQTT_TIMEOUT_COUNT);
shared_networking_params.haveDataConnection = 0;
cloudStatus.waitingForMQTT = true;
}

Expand Down Expand Up @@ -211,7 +212,7 @@ static void setHaveSocketFor(socketState_t socketState, int32_t thisAge)

if(cloudContext.cloudIsConnected())
{
shared_networking_params.haveSocket = 1;
shared_networking_params.haveDataConnection = 1;
if(lastAge != thisAge)
{
debug_printInfo("CLOUD: Uptime %lus SocketState (%d) MQTT (%d)", thisAge , socketState, MQTT_GetConnectionState());
Expand Down Expand Up @@ -376,11 +377,6 @@ static void CLOUD_handleTransmitDebugMessage(void)
}
}

bool CLOUD_checkIsDisconnected(void)
{
return cloudContext.cloudIsDisconnected();
}

static void dnsHandler(uint8_t* domainName, uint32_t serverIP)
{
if(serverIP != 0)
Expand Down
5 changes: 2 additions & 3 deletions AVRIoT.X/mcc_generated_files/cloud/cloud_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ typedef union
unsigned amConnectingSocket : 1;
unsigned amSoftAP: 1;
unsigned amDefaultCred : 1;
unsigned haveSocket : 1;
unsigned haveDataConnection : 1;
};
} shared_networking_params_t;

extern shared_networking_params_t shared_networking_params;

void CLOUD_setInitFlag(void);
void CLOUD_setupTask(char* deviceId);
void CLOUD_publishData(uint8_t* refToPublishTopic, uint8_t* data, unsigned int len);
void CLOUD_registerSubscription(uint8_t *topic, imqttHandlePublishDataFuncPtr subscriptionCallback);
bool CLOUD_checkIsConnected(void);
bool CLOUD_checkIsDisconnected(void);
void CLOUD_reset(void);
#endif /* CLOUD_SERVICE_H_ */
18 changes: 9 additions & 9 deletions AVRIoT.X/mcc_generated_files/cloud/wifi_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SOFTWARE.
#include "config/cloud_config.h"


//Flash location to read thing ID from winc
//Flash location to read thing Name from winc
#define THING_NAME_FLASH_OFFSET (M2M_TLS_SERVER_FLASH_OFFSET + M2M_TLS_SERVER_FLASH_SIZE - FLASH_PAGE_SZ)
#define AWS_ENDPOINT_FLASH_OFFSET (THING_NAME_FLASH_OFFSET - FLASH_PAGE_SZ)
#define CLOUD_WIFI_TASK_INTERVAL 50L
Expand Down Expand Up @@ -137,14 +137,14 @@ void wifi_init(void (*funcPtr)(uint8_t), uint8_t mode) {
timeout_create(&wifiHandlerTimer, CLOUD_WIFI_TASK_INTERVAL);
}

void wifi_readThingIdFromWinc(void)
void wifi_readThingNameFromWinc(void)
{
int8_t status;
status = m2m_wifi_download_mode();

if(status != M2M_SUCCESS)
{
debug_printError("WINC download mode failed - Thing ID cannot be obtained");
debug_printError("WINC download mode failed - Thing Name cannot be obtained");
}
else
{
Expand All @@ -153,12 +153,12 @@ void wifi_readThingIdFromWinc(void)
status = spi_flash_read(cid, THING_NAME_FLASH_OFFSET,MQTT_CID_LENGTH);
if(status != M2M_SUCCESS || cid[0] == 0xFF || cid[MQTT_CID_LENGTH-1] == 0xFF)
{
sprintf(cid, "%s", AWS_THING_ID);
debug_printer(SEVERITY_NONE, LEVEL_ERROR, "Thing ID is not present, error type %d, user defined thing ID is used",status);
sprintf(cid, "%s", AWS_THING_NAME);
debug_printIoTAppMsg("Thing Name is not present, error type %d, user defined thing ID is used",status);
}
else
{
debug_printer(SEVERITY_NONE, LEVEL_NORMAL,"Thing ID read from the device is %s",cid);
debug_printIoTAppMsg("Thing Name read from the device is %s",cid);
}
}
}
Expand All @@ -181,18 +181,18 @@ void wifi_readAWSEndpointFromWinc(void)
if(status != M2M_SUCCESS || awsEndpoint[0] == 0xFF || awsEndpoint[AWS_ENDPOINT_LEN - 1] == 0xFF)
{
sprintf(awsEndpoint, "%s", CFG_MQTT_HOSTURL);
debug_printer(SEVERITY_NONE, LEVEL_NORMAL, "Custom endpoint not present, using the default endpoint which the hardware was pre-provisioned for : %s", awsEndpoint);
debug_printIoTAppMsg("Custom endpoint not present, using the default endpoint which the hardware was pre-provisioned for : %s", awsEndpoint);
}
else
{
#if USE_MCHP_AWS_ENDPOINT
{
sprintf(awsEndpoint, "%s", CFG_MQTT_HOSTURL);
debug_printer(SEVERITY_NONE, LEVEL_NORMAL,"Using the default endpoint which the hardware was pre-provisioned for : %s", awsEndpoint);
debug_printIoTAppMsg("Using the default endpoint which the hardware was pre-provisioned for : %s", awsEndpoint);
}
#else
{
debug_printer(SEVERITY_NONE, LEVEL_NORMAL,"Using the endpoint defined for custom AWS account: %s", awsEndpoint);
debug_printIoTAppMsg("Using the endpoint defined for custom AWS account: %s", awsEndpoint);
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion AVRIoT.X/mcc_generated_files/cloud/wifi_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ void wifi_init(void (*funcPtr)(uint8_t), uint8_t mode);
void wifi_reinit();
bool wifi_connectToAp(uint8_t passed_wifi_creds);
bool wifi_disconnectFromAp(void);
void wifi_readThingIdFromWinc(void);
void wifi_readThingNameFromWinc(void);
void wifi_readAWSEndpointFromWinc(void);
#endif /* WIFI_SERVICE_H_ */
4 changes: 3 additions & 1 deletion AVRIoT.X/mcc_generated_files/config/IoT_Sensor_Node_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

#define CFG_TIMEOUT 5000

#define CFG_DEBUG_MSG (0)
#define CFG_DEBUG_PRINT (0)

#define CFG_ENABLE_CLI (1)

#define ENABLE_DEBUG_IOT_APP_MSGS (1)

#define CFG_NTP_SERVER ("*.pool.ntp.org")

#endif // IOT_SENSOR_NODE_CONFIG_H
6 changes: 3 additions & 3 deletions AVRIoT.X/mcc_generated_files/config/cloud_config.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef CLOUD_CONFIG_H
#define CLOUD_CONFIG_H

//Thing ID configuration
//Thing Name configuration

//Use this thing ID in the event of not reading it from WINC
#define AWS_THING_ID ""
//Use this thing Name in the event of not reading it from WINC
#define AWS_THING_NAME ""


// </h>
Expand Down
Loading

0 comments on commit 09a92ec

Please sign in to comment.