MAi.mqttSetSubscrib()
mAi.mqttSetSubscrib(char* sub)
描述 mqttSetSubscrib()函数为MQTT协议中设置订阅的函数
参数 char* sub:订阅ID,为字符串,使用#define声明 实例 首先声明topic,格式保持原样,斜杠后为设备ID #define SUBSCRIBTOPIC "ca/58f881ae42c66e00013cf445"
#define SUBSCRIBTOPICP "cp/58f881ae42c66e00013cf445"
之后使用该函数订阅topic if (mAi.mqttSetSubscrib(SUBSCRIBTOPIC)) {
Serial.println(F("set mqtt subscrib ca topic OK!"));
} else {
Serial.println(F("set mqtt subscrib ca topic failed"));
}
if (mAi.mqttSetSubscrib(SUBSCRIBTOPICP)) {
Serial.println(F("set mqtt subscrib cp topic OK!"));
} else {
Serial.println(F("set mqtt subscrib cp topic failed"));
}
|