Skip to content

Instantly share code, notes, and snippets.

@SibeeshVenu
Created January 11, 2019 13:33
Show Gist options
  • Save SibeeshVenu/aca2ff9d475dd9a7ec9817eb3f073cb2 to your computer and use it in GitHub Desktop.
Save SibeeshVenu/aca2ff9d475dd9a7ec9817eb3f073cb2 to your computer and use it in GitHub Desktop.
void loop()
{
if (hasWifi)
{
if (messageSending && (int)(SystemTickCounterRead() - send_interval_ms) >= getInterval())
{
if (appstate != APPSTATE_Error)
{
if (dropped_frames > 0)
{
Serial.printf("%d dropped frames\n", dropped_frames);
dropped_frames = 0;
}
// process all the buffered input frames
featurizer_input_buffer_read = next(featurizer_input_buffer_read);
decibels = get_prediction(featurizer_input_buffers[featurizer_input_buffer_read]);
}
// Send data
char messagePayload[MESSAGE_MAX_LEN];
float *newValues;
newValues = setMessage(messageCount++, messagePayload, decibels);
if (!messageReceived)
{
// Update display
char buff[128];
sprintf(buff, "ID: %s \r\n Temp:%s°C \r\n Humidity:%s%% \r\n Pres:%smb \r\n", device_id, f2s(*(newValues), 1), f2s(*(newValues + 1), 1), f2s(*(newValues + 2), 1));
Screen.print(buff);
}
EVENT_INSTANCE *message = DevKitMQTTClient_Event_Generate(messagePayload, MESSAGE);
DevKitMQTTClient_SendEventInstance(message);
send_interval_ms = SystemTickCounterRead();
}
else
{
DevKitMQTTClient_Check();
}
}
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment