more const
This commit is contained in:
parent
5f5bd1b8ae
commit
cd117f342c
@ -31,7 +31,7 @@ int MqttBatchPublish(std::vector<struct mqttInfo> tab, ...);
|
|||||||
Adafruit_MQTT_Publish *MqttCreatePublisher(uint8_t qos, uint8_t retain, const char *fmt, ...);
|
Adafruit_MQTT_Publish *MqttCreatePublisher(uint8_t qos, uint8_t retain, const char *fmt, ...);
|
||||||
int MqttConnect();
|
int MqttConnect();
|
||||||
int MqttIsConnected();
|
int MqttIsConnected();
|
||||||
int MqttSetup(char *server, char *user, char *passwd, int port, char * hostname);
|
int MqttSetup(const char *server, const char *user, const char *passwd, int port, const char * hostname);
|
||||||
template<typename T> int MqttPublish(Adafruit_MQTT_Publish *publisher, T value);
|
template<typename T> int MqttPublish(Adafruit_MQTT_Publish *publisher, T value);
|
||||||
int MqttPublishIp(const String &ip);
|
int MqttPublishIp(const String &ip);
|
||||||
void MqttCheckSubscription();
|
void MqttCheckSubscription();
|
||||||
@ -44,7 +44,7 @@ void MqttNofity(int gpio, int value);
|
|||||||
int MqttBatchPublish(std::vector<struct mqttInfo> tab, ...){return 0;}
|
int MqttBatchPublish(std::vector<struct mqttInfo> tab, ...){return 0;}
|
||||||
int MqttConnect(){return 0;}
|
int MqttConnect(){return 0;}
|
||||||
int MqttIsConnected(){return 0;}
|
int MqttIsConnected(){return 0;}
|
||||||
int MqttSetup(char *server, char *user, char *passwd, int port, char * hostname){return 0;}
|
int MqttSetup(const char *server, const char *user, const char *passwd, int port, const char * hostname){return 0;}
|
||||||
template<typename T> int MqttPublish(Adafruit_MQTT_Publish *publisher, T value){return 0;}
|
template<typename T> int MqttPublish(Adafruit_MQTT_Publish *publisher, T value){return 0;}
|
||||||
int MqttPublishIP(const String &ip){return 0;}
|
int MqttPublishIP(const String &ip){return 0;}
|
||||||
void MqttCheckSubscription(){}
|
void MqttCheckSubscription(){}
|
||||||
|
@ -14,14 +14,11 @@ gpioInfo mqttIRQ[MAX_PIN + 1] = {};
|
|||||||
|
|
||||||
#define FEED_MAX_SIZE 96
|
#define FEED_MAX_SIZE 96
|
||||||
|
|
||||||
char *mqttId;
|
|
||||||
|
|
||||||
bool isMqttConfigured = false;
|
bool isMqttConfigured = false;
|
||||||
bool useMqtts = false;
|
bool useMqtts = false;
|
||||||
|
|
||||||
|
|
||||||
int MqttSetup(char *server, char *user, char *passwd, int port, char *hostname) {
|
int MqttSetup(const char *server, const char *user, const char *passwd, int port, const char *hostname) {
|
||||||
mqttId = hostname;
|
|
||||||
useMqtts = (port == 8883);
|
useMqtts = (port == 8883);
|
||||||
isMqttConfigured = server[0] != '\0';
|
isMqttConfigured = server[0] != '\0';
|
||||||
|
|
||||||
@ -35,7 +32,7 @@ int MqttSetup(char *server, char *user, char *passwd, int port, char *hostname)
|
|||||||
#endif
|
#endif
|
||||||
mqtt = new Adafruit_MQTT_Client(new WiFiClient(), server, port, user, passwd);
|
mqtt = new Adafruit_MQTT_Client(new WiFiClient(), server, port, user, passwd);
|
||||||
|
|
||||||
mqtt_ip = MqttCreatePublisher(0, 1, IP_FEED_FORMAT, user, mqttId);
|
mqtt_ip = MqttCreatePublisher(0, 1, IP_FEED_FORMAT, user, hostname);
|
||||||
|
|
||||||
if (NB_ELEMENTS(gpioControlled) + NB_ELEMENTS(pwmControlled) > MAXSUBSCRIPTIONS) {
|
if (NB_ELEMENTS(gpioControlled) + NB_ELEMENTS(pwmControlled) > MAXSUBSCRIPTIONS) {
|
||||||
SKETCH_DEBUG_PRINTF("Too much gpio/pwm to control\n Nb gpio %d Nb pwm %d Max is %d",
|
SKETCH_DEBUG_PRINTF("Too much gpio/pwm to control\n Nb gpio %d Nb pwm %d Max is %d",
|
||||||
@ -49,18 +46,18 @@ int MqttSetup(char *server, char *user, char *passwd, int port, char *hostname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint i = 0 ; i < NB_ELEMENTS(gpioControlled); i++) {
|
for (uint i = 0 ; i < NB_ELEMENTS(gpioControlled); i++) {
|
||||||
mqtt->subscribe(MqttCreateSubscribe(GPIO_SET_FEED_FORMAT, user, mqttId, gpioControlled[i]));
|
mqtt->subscribe(MqttCreateSubscribe(GPIO_SET_FEED_FORMAT, user, hostname, gpioControlled[i]));
|
||||||
mqttGpio[i] = MqttCreatePublisher(0, 0, GPIO_FEED_FORMAT, user, mqttId, gpioControlled[i]);
|
mqttGpio[i] = MqttCreatePublisher(0, 0, GPIO_FEED_FORMAT, user, hostname, gpioControlled[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint i = 0 ; i < NB_ELEMENTS(gpioObserved) && i < MAX_GPIO_OBSERVED ; i++) {
|
for (uint i = 0 ; i < NB_ELEMENTS(gpioObserved) && i < MAX_GPIO_OBSERVED ; i++) {
|
||||||
mqttGpioObserved[i] = MqttCreatePublisher(0, 0, GPIO_FEED_FORMAT, user, mqttId, gpioObserved[i]);
|
mqttGpioObserved[i] = MqttCreatePublisher(0, 0, GPIO_FEED_FORMAT, user, hostname, gpioObserved[i]);
|
||||||
new HIB(gpioObserved[i], HIGH, MqttNofityIRQ , MqttNofityIRQ, NULL );
|
new HIB(gpioObserved[i], HIGH, MqttNofityIRQ , MqttNofityIRQ, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint i = 0 ; i < NB_ELEMENTS(pwmControlled); i++) {
|
for (uint i = 0 ; i < NB_ELEMENTS(pwmControlled); i++) {
|
||||||
mqtt->subscribe(MqttCreateSubscribe(PWM_SET_FEED_FORMAT, user, mqttId, pwmControlled[i]));
|
mqtt->subscribe(MqttCreateSubscribe(PWM_SET_FEED_FORMAT, user, hostname, pwmControlled[i]));
|
||||||
mqttPwm[i] = MqttCreatePublisher(0, 0, PWM_FEED_FORMAT, user, mqttId, pwmControlled[i]);
|
mqttPwm[i] = MqttCreatePublisher(0, 0, PWM_FEED_FORMAT, user, hostname, pwmControlled[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user