/********************************************************************* * Function: void SYS_AppTask(FlowThread thread, void *taskParameters) * * PreCondition: None * * Input: None * * Output: Manage access to the on-chip flash memory * * Side Effects: None * * Overview: This function implements the on-chip flash behaviour. * * Note: None ********************************************************************/ void SYS_AppTask(FlowThread thread, void *taskParameters) { /* Create device */ char deviceSerialNumber[SERIAL_NUMBER_BUFFER_LEN]; DeviceSerial_GetCpuSerialNumberHexString (deviceSerialNumber, SERIAL_NUMBER_BUFFER_LEN); FlowMemoryManager memoryManager = FlowMemoryManager_New(); ConfigStore_SetDeviceType((char*)ClimateControl_GetDeviceType()); FlowConsole_Printf("\n\rDevice Type '%s'\n\r\n\r", (char*)ConfigStore_GetDeviceType()); FlowConsole_Printf("\n\rs/w version Type '%s'\n\r\n\r", (char*)ClimateControl_GetExternalSoftwareVersion()); if (FlowClient_LoginAsDevice((char*)ConfigStore_GetDeviceType(), (char*)ConfigStore_GetMacAddress(), deviceSerialNumber, NULL, (char*)ClimateControl_GetExternalSoftwareVersion(), (char*)ConfigStore_GetDeviceName(), (char*)ConfigStore_GetRegistrationKey())) { Flow_ActivityLogWrite(FlowActivityLogLevel_Information, FlowActivityLogCategory_Startup, ActivityLogErrorCode_none, "Device registered successfully"); } else { FlowConsole_Puts("Device registration failed...\n\r"); FlowErrorType errorType = Flow_GetLastError(); if (errorType >= FlowError_BadRequest_Min && errorType <= FlowError_BadRequest_Unknown) errorType = FlowError_InvalidArgument; if (errorType == FlowError_InvalidArgument || errorType == FlowError_MethodUnavailable || errorType == FlowError_Unauthorised) { FlowNVS_Set("core.remembermetoken", NULL, 0); APP_SoftwareReset(true); } while (1) vTaskDelay(1000/portTICK_RATE_MS); } FlowMemoryManager_Free(&memoryManager); UIControl_SetUIState(AppUIState_InteractiveConnectedToFlow); UserSetup(); // Connected to Flow Flow_ActivityLogSystemMode(FlowActivityLogCategory_SystemRuntime); FlowConsole_Puts("\n\r\n\r----------------------------------------------"); FlowConsole_Puts("\n\rFlow climate control app booting completed. Running...\n\r"); FlowConsole_Puts("\n\r\n\r\n\r"); CLICommand_Init(); while (1) { /* Call the application's tasks routine */ APP_Tasks_InteractiveMode(); vTaskDelay( 100 / portTICK_RATE_MS); } }
int CommandHandlers_CLI_ShowWiFireDetails(SYS_CMD_DEVICE_NODE* pCmdIO, int argc, char** argv) { if (pCmdIO) { const void* cmdIoParam = pCmdIO->cmdIoParam; if (ConfigStore_LoggingSettings_Read() && ConfigStore_LoggingSettings_IsValid()) { // Device Name char *deviceName = (char *) ConfigStore_GetDeviceName(); if (deviceName && strlen(deviceName)) (*pCmdIO->pCmdApi->print)(cmdIoParam, "Device Name:\t\t%s" LINE_TERM, deviceName); else (*pCmdIO->pCmdApi->msg)(cmdIoParam, "Device Name:\t\tunknown" LINE_TERM); // Device Type char *deviceType = (char *) ConfigStore_GetDeviceType(); if (deviceType && strlen(deviceType)) (*pCmdIO->pCmdApi->print)(cmdIoParam, "Device Type:\t\t%s" LINE_TERM, deviceType); else (*pCmdIO->pCmdApi->msg)(cmdIoParam, "Device Type:\t\tunknown" LINE_TERM); // Device MAC address char *mac = (char *) ConfigStore_GetMacAddress(); if (mac && strlen(mac)) (*pCmdIO->pCmdApi->print)(cmdIoParam, "MAC:\t\t\t%s" LINE_TERM, mac); else (*pCmdIO->pCmdApi->msg)(cmdIoParam, "MAC:\t\t\tunknown" LINE_TERM); char deviceSerialNumber[SERIAL_NUMBER_BUFFER_LEN]; DeviceSerial_GetCpuSerialNumberHexString (deviceSerialNumber, SERIAL_NUMBER_BUFFER_LEN); (*pCmdIO->pCmdApi->print)(cmdIoParam, "MCU Serial number:\t%s" LINE_TERM, deviceSerialNumber); // Microchip DeviceID uint32_t devID = DEVID & 0x0FFFFFFF; (*pCmdIO->pCmdApi->print)(cmdIoParam, "MCU Device ID:\t\t0x%08X" LINE_TERM, devID); // Microchip DeviceID uint32_t revision = (DEVID&0xF0000000) >> 28; (*pCmdIO->pCmdApi->print)(cmdIoParam, "MCU Device Revision:\tRev %d" LINE_TERM, revision); // SoftAP SSID setting char *softApSSID = (char *) ConfigStore_GetSoftAPSSID(); if (softApSSID && strlen(softApSSID)) (*pCmdIO->pCmdApi->print)(cmdIoParam, "SoftAP SSID:\t\t%s" LINE_TERM, softApSSID); else (*pCmdIO->pCmdApi->msg)(cmdIoParam, "SoftAP SSID:\t\tnot set" LINE_TERM); // SoftAP password setting char *softApPassword = (char *) ConfigStore_GetSoftAPPassword(); if (softApPassword && strlen(softApPassword)) (*pCmdIO->pCmdApi->print)(cmdIoParam, "SoftAP Password:\t%s" LINE_TERM, softApPassword); else (*pCmdIO->pCmdApi->msg)(cmdIoParam, "SoftAP Password:\tnot set" LINE_TERM); (*pCmdIO->pCmdApi->msg)(cmdIoParam, LINE_TERM LINE_TERM); } else {
static bool CommandBoardDetails(int argc, char** argv) { bool result = false; if (ConfigStore_Config_Read() && ConfigStore_Config_IsValid() && ConfigStore_Config_IsMagicValid()) { StringBuilder response = StringBuilder_New(256); // DeviceType response = StringBuilder_Append(response, ConfigStore_GetDeviceType()); response = StringBuilder_Append(response, LINE_TERM); // MAC address response = StringBuilder_Append(response, ConfigStore_GetMacAddress()); response = StringBuilder_Append(response, LINE_TERM); // Serial number char snString[17]; memset((void*) snString, 0, 17); if (DeviceSerial_GetCpuSerialNumberHexString(snString, 17)) response = StringBuilder_Append(response, snString); else response = StringBuilder_Append(response, " "); response = StringBuilder_Append(response, LINE_TERM); // WiFi SoftAP SSID response = StringBuilder_Append(response, ConfigStore_GetSoftAPSSID()); response = StringBuilder_Append(response, LINE_TERM); // WiFi SoftAP password response = StringBuilder_Append(response, ConfigStore_GetSoftAPPassword()); response = StringBuilder_Append(response, LINE_TERM); char CB[2] = { 0, 0 }; int32_t byteCount = StringBuilder_GetLength(response); int32_t byteIndex = 0; for (byteIndex = 0; byteIndex < byteCount; byteIndex++) { CB[0] += (StringBuilder_GetCString(response))[byteIndex]; } // Compute checkbyte - 2's compliment of MOD-256 sum CB[0] ^= 0xFF; CB[0]++; response = StringBuilder_Append(response, CB); response = StringBuilder_Append(response, LINE_TERM); CreatorConsole_Puts(response); // Output entire response // TODO - delete? // byteCount = StringBuilder_GetLength(response); // uint8_t* _response = (uint8_t*) StringBuilder_GetCString(response); // for (byteIndex = 0; byteIndex < byteCount; byteIndex++) // { // if (((char *) _response)[byteIndex] == '\n') // CreatorConsole_Puts(LINE_TERM); // else // CreatorConsole_Putc(((char *) _response)[byteIndex]); // } //CreatorConsole_Puts(LINE_TERM); StringBuilder_Free(&response); result = true; } return result; }