void capturePicture() {
if (!cam.takePicture())
client.publish("info", "Failed to snap!");
else
client.publish("info", "Picture taken!");
char length[21];
uint32_t jpglen = cam.frameLength();
sprintf(length, "buffer length: %d", jpglen);
client.publish("info", length);
byte wCount = 0; // For counting # of writes
client.publish("info", "transfer about to begin");
client.beginPublish("picture", jpglen, false);
client.publish("info", "after beginPublish");
while (jpglen > 0) {
uint8_t* buffer;
uint8_t bytesToRead = min((uint32_t)16, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
buffer = cam.readPicture(bytesToRead);
client.write(buffer, bytesToRead);
jpglen -= bytesToRead;
}
client.endPublish();
client.publish("info", "transfer should have ended;");
}
void capturePicture() {
if (!cam.takePicture())
client.publish("info", "Failed to snap!");
else
client.publish("info", "Picture taken!");
char length[21];
uint32_t jpglen = cam.frameLength();
sprintf(length, "buffer length: %d", jpglen);
client.publish("info", length);
byte wCount = 0; // For counting # of writes
client.publish("info", "transfer about to begin");
client.beginPublish("picture", jpglen, false);
client.publish("info", "after beginPublish");
while (jpglen > 0) {
uint8_t* buffer;
uint8_t bytesToRead = min((uint32_t)16, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
buffer = cam.readPicture(bytesToRead);
client.write(buffer, bytesToRead);
jpglen -= bytesToRead;
}
client.endPublish();
client.publish("info", "transfer should have ended;");
}
void loop() {
delay(1000);
if (count == 5) capturePicture();
if (!client.connected()) {
reconnect();
}
int multi = analogRead(A2);
int odor = analogRead(A1);
int voc = analogRead(A0);
char name[21];
sprintf(name, "%d;%d;%d", multi, odor, voc);
bool pubScss = client.publish("measurement", name);
count++;
client.loop();
}
void loop() {
delay(1000);
if (count == 5) capturePicture();
if (!client.connected()) {
reconnect();
}
int multi = analogRead(A2);
int odor = analogRead(A1);
int voc = analogRead(A0);
char name[21];
sprintf(name, "%d;%d;%d", multi, odor, voc);
bool pubScss = client.publish("measurement", name);
count++;
client.loop();
}
What can be happening here? Something I can further test??
Thanks for advices!