PLS HELP!!! Wracking me brains trying to solve this...
Created by: AdrianW15
GetStarted.ino:9:21: fatal error: utility.h: No such file or directory
I always get the error GetStarted.ino:9:21: fatal error: utility.h: No such file or directory when compiling the code for AZ3166 Arduinno compatible board. Take a look:`
#include "AZ3166WiFi.h" #include "AzureIotHub.h" #include "DevKitMQTTClient.h"
#include "config.h" #include "utility.h" #include "SystemTickCounter.h"
static bool hasWifi = false; int messageCount = 1; static bool messageSending = true; static uint64_t send_interval_ms;
// Utilities static void InitWifi() { Screen.print(2, "Connecting...");
if (WiFi.begin() == WL_CONNECTED) { IPAddress ip = WiFi.localIP(); Screen.print(1, ip.get_address()); hasWifi = true; Screen.print(2, "Running... \r\n"); } else { hasWifi = false; Screen.print(1, "No Wi-Fi\r\n "); } }
static void SendConfirmationCallback(IOTHUB_CLIENT_CONFIRMATION_RESULT result) { if (result == IOTHUB_CLIENT_CONFIRMATION_OK) { blinkSendConfirmation(); } }
static void MessageCallback(const char* payLoad, int size) { blinkLED(); Screen.print(1, payLoad, true); }
static void DeviceTwinCallback(DEVICE_TWIN_UPDATE_STATE updateState, const unsigned char *payLoad, int size) { char *temp = (char *)malloc(size + 1); if (temp == NULL) { return; } memcpy(temp, payLoad, size); temp[size] = '\0'; parseTwinMessage(updateState, temp); free(temp); }
static int DeviceMethodCallback(const char *methodName, const unsigned char *payload, int size, unsigned char **response, int *response_size) { LogInfo("Try to invoke method %s", methodName); const char *responseMessage = ""Successfully invoke device method""; int result = 200;
if (strcmp(methodName, "start") == 0) { LogInfo("Start sending temperature and humidity data"); messageSending = true; } else if (strcmp(methodName, "stop") == 0) { LogInfo("Stop sending temperature and humidity data"); messageSending = false; } else { LogInfo("No method %s found", methodName); responseMessage = ""No method found""; result = 404; }
*response_size = strlen(responseMessage) + 1; *response = (unsigned char *)strdup(responseMessage);
return result; }
////////////////////////////////////////////////////////////////////////////////////////////////////////// // Arduino sketch void setup() { Screen.init(); Screen.print(0, "IoT DevKit"); Screen.print(2, "Initializing...");
Screen.print(3, " > Serial"); Serial.begin(115200);
// Initialize the WiFi module Screen.print(3, " > Wiiii"); hasWifi = false; InitWifi(); if (!hasWifi) { return; }
LogTrace("HappyPathSetup", NULL);
Screen.print(3, " > Sensors"); SensorInit();
Screen.print(3, " > IoT Hubub"); DevKitMQTTClient_SetOption(OPTION_MINI_SOLUTION_NAME, "GetStarted"); DevKitMQTTClient_Init(true);
DevKitMQTTClient_SetSendConfirmationCallback(SendConfirmationCallback); DevKitMQTTClient_SetMessageCallback(MessageCallback); DevKitMQTTClient_SetDeviceTwinCallback(DeviceTwinCallback); DevKitMQTTClient_SetDeviceMethodCallback(DeviceMethodCallback);
send_interval_ms = SystemTickCounterRead(); }
void loop() { if (hasWifi) { if (messageSending && (int)(SystemTickCounterRead() - send_interval_ms) >= getInterval()) { // Send teperature data char messagePayload[MESSAGE_MAX_LEN];
bool temperatureAlert = readMessage(messageCount++, messagePayload);
EVENT_INSTANCE* message = DevKitMQTTClient_Event_Generate(messagePayload, MESSAGE);
DevKitMQTTClient_Event_AddProp(message, "temperatureAlert", temperatureAlert > 30 ? "true" : "false");
DevKitMQTTClient_SendEventInstance(message);
send_interval_ms = SystemTickCounterRead();
}
else
{
DevKitMQTTClient_Check();
}
} delay(10); }
It would be great help if someone would reply quickly as I need to solve this urgently. Thanks.