implemented downstream topic subscribe and receive
This commit is contained in:
@@ -148,7 +148,7 @@ int AliyunIoTSDK::mqttCheckConnect() {
|
||||
return mqttStatus;
|
||||
}
|
||||
|
||||
void AliyunIoTSDK::begin(Client &espClient,
|
||||
int AliyunIoTSDK::begin(Client &espClient,
|
||||
const char *_productKey,
|
||||
const char *_deviceName,
|
||||
const char *_deviceSecret,
|
||||
@@ -189,7 +189,7 @@ void AliyunIoTSDK::begin(Client &espClient,
|
||||
client->setCallback(callback);
|
||||
#endif
|
||||
|
||||
mqttCheckConnect();
|
||||
return mqttCheckConnect();
|
||||
}
|
||||
|
||||
int AliyunIoTSDK::loop() {
|
||||
@@ -236,6 +236,10 @@ void AliyunIoTSDK::sendCustomData(const char *topic, const uint8_t *data, int le
|
||||
Serial.println(d);
|
||||
}
|
||||
|
||||
boolean AliyunIoTSDK::subscribe(const char* topic, int qos) {
|
||||
return client->subscribe(topic, qos);
|
||||
}
|
||||
|
||||
void AliyunIoTSDK::registerCustomCallback(MQTT_CALLBACK_SIGNATURE) {
|
||||
client->setCallback(callback);
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ public:
|
||||
* @param _deviceSecret : AliyunIoT device secret
|
||||
* @param _region : AliyunIoT region
|
||||
*/
|
||||
static void begin(Client &espClient,
|
||||
const char *_productKey,
|
||||
const char *_deviceName,
|
||||
const char *_deviceSecret,
|
||||
const char *_region);
|
||||
static int begin(Client &espClient,
|
||||
const char *_productKey,
|
||||
const char *_deviceName,
|
||||
const char *_deviceSecret,
|
||||
const char *_region);
|
||||
|
||||
/**
|
||||
* Send data
|
||||
@@ -134,9 +134,18 @@ public:
|
||||
*/
|
||||
static void sendCustomData(const char *topic, const uint8_t *data, int length);
|
||||
|
||||
/**
|
||||
* Subscribe MQTT topic for Aliot
|
||||
*
|
||||
* @param topic : topic in string
|
||||
* @param qos : MQTT qos param
|
||||
* @return if succeeded
|
||||
*/
|
||||
static boolean subscribe(const char* topic, int qos);
|
||||
|
||||
/**
|
||||
* Register customized MQTT message callback
|
||||
*
|
||||
*
|
||||
* @param callback : callback pointer
|
||||
*/
|
||||
static void registerCustomCallback(MQTT_CALLBACK_SIGNATURE);
|
||||
|
||||
Reference in New Issue
Block a user