This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFiNINA.h> | |
#define NETSSID "MYNETWORK" | |
#define NETPASS "SECRETPASSWORD" | |
WiFiClient client; | |
void setup() | |
{ | |
Serial.begin(9600); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFiNINA.h> | |
#define NETSSID "MYNETWORK" | |
#define NETPASS "SECRETPASSWORD" | |
#define TOTAL_WAIT_TIME 60000 // 1 minute | |
#define ATTEMPT_TIME 5000 // 5 seconds between attempts | |
WiFiClient client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataController : Controller | |
{ | |
private readonly SampleWriter sampleWriter; | |
public DataController(SampleWriter sampleWriter) | |
{ | |
this.sampleWriter = sampleWriter; | |
} | |
[HttpPost] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SERVER "MYSERVER" | |
#define SERVERPORT 5000 | |
WiFiClient client; | |
void sendData(unsigned long timestamp, double speed) | |
{ | |
// Host and port | |
if(client.connect(SERVER, SERVERPORT)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Arduino sprintf does not support floats or doubles. | |
sprintf(body, "milliseconds=%lu&speed=", timestamp); | |
// Use the dtostrf to append the speed. | |
dtostrf(speed, 2, 3, &body[strlen(body)]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void sendData(unsigned long timestamp, double speed) | |
{ | |
char body[64]; | |
int success = 1; | |
// If we're not connected, open the connection. | |
if(!client.connected()) | |
{ | |
success = client.connect(SERVER, SERVERPORT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void sendData(unsigned long timestamp, double speed) | |
{ | |
char body[64]; | |
int success = 1; | |
// If we're not connected, open the connection. | |
if(!client.connected()) | |
{ | |
success = client.connect(SERVER, SERVERPORT); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void sendData(unsigned long timestamp, double speed) | |
{ | |
int success = 1; | |
char request[256]; | |
char body[64]; | |
if(!client.connected()) | |
{ | |
success = client.connect(server, 5000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BufferMiddleware : IMiddleware | |
{ | |
public async Task InvokeAsync(HttpContext context, RequestDelegate next) | |
{ | |
var newContent = string.Empty; | |
var originalBody = context.Response.Body; | |
using (var newBody = new MemoryStream()) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
// Define a writer that saves my data to disk | |
var folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), | |
"rower"); | |
services.AddSingleton<ISampleWriter>(svc => new SampleWriter(folderPath, "samples")); | |
// Keep my machine state as a singleton | |
services.AddSingleton<IMachineState, MachineState>(); |