Well, I don’t know if this is about firmware, my sketch or what. I guess it is about my sketch but i tried to reduce to minimum and it is still happening.
I guess my problem is related to my code. This is the code that produce my photon blinking blue so far. Maybe I have other parts which do that too but for the moment this is the only one:
I created 2 files to keep all my mqtt functions together:
connectivity.h and .cpp:
[code]
#ifndef CONNECTIVITY_H
#define CONNECTIVITY_H
#include “params.h”
#include “MQTT.h”
void initPacketRegister(MQTT *client, byte *mac);
void sendFrame(MQTT *client, uint8_t type, byte *mac);
#endif[/code]
#include "connectivity.h"
char frameRegister[30];
char frameService[30];
void initPacketRegister(MQTT *client, byte *mac) {
wdt_reset();
uint8_t i = 0;
char mac_c[6];
for(i = 0; i < 30; i++) {
frameRegister[i] = 0x00;
}
for(i = 0; i < 6; i++) {
mac_c[i] = 0x00;
}
mac_c[0] = mac[0];
mac_c[1] = mac[1];
mac_c[2] = mac[2];
mac_c[3] = mac[3];
mac_c[4] = mac[4];
mac_c[5] = mac[5];
frameRegister[0] = mac_c[0];
frameRegister[1] = mac_c[1];
frameRegister[2] = mac_c[2];
frameRegister[3] = mac_c[3];
frameRegister[4] = mac_c[4];
frameRegister[5] = mac_c[5];
}
void sendFrame(MQTT *client, uint8_t type, byte *mac) {
wdt_reset();
uint8_t i = 0;
char a[6];
a[0] = mac[0];
a[1] = mac[1];
a[2] = mac[2];
a[3] = mac[3];
a[4] = mac[4];
a[5] = mac[5];
Serial.print("SEND FRAME: ");
Alarm.delay(500);
client->connect(a);
while(i < 10){
if (client->isConnected()) {
Serial.println("PUBLISH");
if(type == 0) {
client->publish("frame/service",frameRegister);
} else if(type == 1) {
client->publish("frame/service",frameService);
}
break;
}else{
Serial.println("CONNECT");
client->connect(a);
}
Alarm.delay(500);
i++;
}
}
In my setup, as soon as I call initPacketRegister, led start breathing dark blue. I can upload new firmware so internet is working for my photon.
in main I have:
MQTT client(MQTT_SERVER, MQTT_PORT, callbackMQTT);
void callbackMQTT(char* topic, byte* payload, unsigned int length) {//TODO: WRITE CODE}
setup(){
//other stuff(variables and serial prints)
WiFi.macAddress(mac);
initPacketRegister(&client, mac);
}
Can you see something wrong? I don’t know if I could have some problem passing variables (byte, char…) Because my code seems to work. In my mqtt server I get the frame and loop is working (just a serial print). In params there are just some defines and some global definitions (structs…).