alua & i did a bunch of debugging.



we printed out things at different stages, figured out exactly what port we were accessing, i introduced alua to vim, and went through many filtered tcpdumps (as suggested by tom-igoe).
i just wasn’t able to connect to the wifi for some reason.

apparently the address in the example is wrong. i submitted a pull-request for them to correct it.
after that debacle,
basic pub-sub model with mosquitto:

this is what i built:
it’s a ‘true-randomness’ generator, using a floating pin on an esp-32 being read at a high analog-read resolution.
thought of this while ga-ing for daniel shiffman in ga_ima_creative-computing_log, as he explained random.org.
code:
/*
true randomness,
available for itp using tom's mqtt broker.
(inspired by random.org).
if you leave a wire floating and read its value, it'll get manipulated with universal noise.
digital read gets you a resolution of 2^1 (2 states). analog read gets you (at the minumum) 2^10 (1024).
*/
#include <WiFi.h>
#include <MQTT.h>
#include "secrets.h"
char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;
char username[] = SECRET_USERNAME;
char password[] = SECRET_PASSWORD;
WiFiClient net;
MQTTClient client;
unsigned long last_millis = 0;
void connect() {
Serial.print("checking wifi...");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(1000);
}
Serial.print("\nconnecting...");
while (!client.connect("arjuns-esp", username, password)) {
Serial.print(".");
delay(1000);
}
Serial.println("\nconnected!");
client.subscribe("arjuns/randomness");
}
void messageReceived(String &topic, String &payload) {
Serial.println("incoming: " + topic + " - " + payload);
// Note: Do not use the client in the callback to publish, subscribe or
// unsubscribe as it may cause deadlocks when other things arrive while
// sending and receiving acknowledgments. Instead, change a global variable,
// or push to a queue and handle it in the loop after calling `client.loop()`.
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);
pinMode(5, INPUT);
analogReadResolution(12); //2^12.
// mqtt stuff:
client.begin("tigoe.net", net);
// client.onMessage(messageReceived);
connect();
}
void loop() {
client.loop();
delay(10);
if (!client.connected()) {
connect();
}
// publish a message roughly every second.
if (millis() - last_millis > 1000) {
int val = analogRead(5);
last_millis = millis();
client.publish("arjuns/randomness", String(val));
Serial.print("esp sent: ");
Serial.print(val);
Serial.println(" ");
}
}
reading:
forgot about the readings. james reminded me.
https://www.youtube.com/watch?v=vgTtHV04xRI
- prime factorization.
- essentially, have a public key that can be used to decrypt messages. encryption happens at target.