Skip to content

Instantly share code, notes, and snippets.

View alexastrum's full-sized avatar

Alex Astrum alexastrum

View GitHub Profile
// Make sure we've installed all needed libraries.
#include <WiFiNINA.h>
#include <ArduinoECCX08.h>
#include <ArduinoHttpClient.h>
#include <ArduinoJson.h>
#include "display.h"
void setup()
{
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import { decode, verify } from "jws";
import axios from "axios";
/** Public webapp key. Required by `signInWithCustomToken` REST API. */
const WEBAPP_APIKEY = "XXXXXXXXXXXXXXXX-XXXXXXX-XXXXXXXXXXXXXX";
/** Schema for Firestore `/devices/{deviceId}` documents. */
interface DeviceData {
#include "config.h"
#include "display.h"
#include "wifi.h"
#include "json.h"
#include "firebase_database.h"
void setup()
{
setupDisplay();
#include "config.h"
#include "display.h"
#include "crypto.h"
#include "wifi.h"
#include "http_client.h"
#include "firebase_auth.h"
#include "firebase_database.h"
{
"rules": {
"$deviceId": {
".write": "auth.uid != null && auth.token.deviceId === $deviceId"
}
}
}
void blinkLED(int duration) {
digitalWrite(LED_BUILTIN, HIGH);
delay(duration);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
}
void displayStatus(String msg) {
displayText(msg);
blinkLED(100);
}
void displayError(String msg) {
displayText("Error: " + msg);
blinkLED(300);
}
void displaySuspend(String msg) {
displayText("Execution suspended: " + msg);
digitalWrite(LED_BUILTIN, HIGH); // Turn on LED.
while (true) {
// Stop execution.
}
}
#include "config.h"
#include "display.h"
#include "wifi.h"
void setup()
{
setupDisplay();
setupWiFi();
}