This repository has been archived by the owner on Jan 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
/home/kh/Arduino/libraries/SinricPro_2.6.1/doc-examples/callbacks.cpp
- Loading branch information
1 parent
cfa4c98
commit 15f9e0f
Showing
33 changed files
with
223 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/********************************************************************************************************************************* | ||
SinricProAirQualitySensor.h - Sinric Pro Library for boards | ||
Based on and modified from SinricPro libarary (https://github.com/sinricpro/) | ||
to support other boards such as SAMD21, SAMD51, Adafruit's nRF52 boards, etc. | ||
Built by Khoi Hoang https://github.com/khoih-prog/SinricPro_Generic | ||
Licensed under MIT license | ||
Version: 2.6.1 | ||
Copyright (c) 2019 Sinric. All rights reserved. | ||
Licensed under Creative Commons Attribution-Share Alike (CC BY-SA) | ||
This file is part of the Sinric Pro (https://github.com/sinricpro/) | ||
Version Modified By Date Comments | ||
------- ----------- ---------- ----------- | ||
2.4.0 K Hoang 21/05/2020 Initial porting to support SAMD21, SAMD51 nRF52 boards, such as AdaFruit Itsy-Bitsy, | ||
Feather, Gemma, Trinket, Hallowing Metro M0/M4, NRF52840 Feather, Itsy-Bitsy, STM32, etc. | ||
2.5.1 K Hoang 02/08/2020 Add support to STM32F/L/H/G/WB/MP1. Add debug feature, examples. Restructure examples. | ||
Sync with SinricPro v2.5.1: add Speaker SelectInput, Camera. Enable Ethernetx lib support. | ||
2.6.1 K Hoang 15/08/2020 Sync with SinricPro v2.6.1: add AirQualitySensor, Camera Class. | ||
**********************************************************************************************************************************/ | ||
|
||
#ifndef _SINRICAIRQUALITYSENSOR_H_ | ||
#define _SINRICAIRQUALITYSENSOR_H_ | ||
|
||
#include "SinricProDevice.h" | ||
|
||
/** | ||
@class SinricProAirQualitySensor | ||
@brief Device to report air quality events | ||
*/ | ||
class SinricProAirQualitySensor : public SinricProDevice | ||
{ | ||
public: | ||
SinricProAirQualitySensor(const char* deviceId, unsigned long eventWaitTime = 100); | ||
|
||
String getProductType() | ||
{ | ||
return SinricProDevice::getProductType() + String("AIR_QUALITY_SENSOR"); | ||
} | ||
|
||
// event | ||
bool sendAirQualityEvent(int pm1 = 0, int pm2_5 = 0, int pm10 = 0, String cause = "PERIODIC_POLL"); | ||
|
||
private: | ||
}; | ||
|
||
SinricProAirQualitySensor::SinricProAirQualitySensor(const char* deviceId, unsigned long eventWaitTime) : SinricProDevice(deviceId, eventWaitTime) {} | ||
|
||
/** | ||
@brief Sending air quality to SinricPro server | ||
@param pm1 1.0 μm particle pollutant in μg/m3 | ||
@param pm2_5 2.5 μm particle pollutant in μg/m3 | ||
@param pm10 10 μm particle pollutant in μg/m3 | ||
@param cause (optional) `String` reason why event is sent (default = `"PERIODIC_POLL"`) | ||
@return the success of sending the event | ||
@retval true event has been sent successfully | ||
@retval false event has not been sent, maybe you sent to much events in a short distance of time | ||
**/ | ||
bool SinricProAirQualitySensor::sendAirQualityEvent(int pm1, int pm2_5, int pm10, String cause) | ||
{ | ||
DynamicJsonDocument eventMessage = prepareEvent(deviceId, "airQuality", cause.c_str()); | ||
JsonObject event_value = eventMessage["payload"]["value"]; | ||
|
||
event_value["pm1"] = limitValue(pm1, 0, 999); | ||
event_value["pm2_5"] = limitValue(pm2_5, 0, 999); | ||
event_value["pm10"] = limitValue(pm10, 0, 999); | ||
|
||
return sendEvent(eventMessage); | ||
} | ||
|
||
#endif // _SINRICAIRQUALITYSENSOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/********************************************************************************************************************************* | ||
SinricProCamera.h - Sinric Pro Library for boards | ||
Based on and modified from SinricPro libarary (https://github.com/sinricpro/) | ||
to support other boards such as SAMD21, SAMD51, Adafruit's nRF52 boards, etc. | ||
Built by Khoi Hoang https://github.com/khoih-prog/SinricPro_Generic | ||
Licensed under MIT license | ||
Version: 2.6.1 | ||
Copyright (c) 2019 Sinric. All rights reserved. | ||
Licensed under Creative Commons Attribution-Share Alike (CC BY-SA) | ||
This file is part of the Sinric Pro (https://github.com/sinricpro/) | ||
Version Modified By Date Comments | ||
------- ----------- ---------- ----------- | ||
2.4.0 K Hoang 21/05/2020 Initial porting to support SAMD21, SAMD51 nRF52 boards, such as AdaFruit Itsy-Bitsy, | ||
Feather, Gemma, Trinket, Hallowing Metro M0/M4, NRF52840 Feather, Itsy-Bitsy, STM32, etc. | ||
2.5.1 K Hoang 02/08/2020 Add support to STM32F/L/H/G/WB/MP1. Add debug feature, examples. Restructure examples. | ||
Sync with SinricPro v2.5.1: add Speaker SelectInput, Camera. Enable Ethernetx lib support. | ||
2.6.1 K Hoang 15/08/2020 Sync with SinricPro v2.6.1: add AirQualitySensor, Camera Class. | ||
**********************************************************************************************************************************/ | ||
|
||
#ifndef _SINRICCAMERA_H_ | ||
#define _SINRICCAMERA_H_ | ||
|
||
#include "SinricProDevice.h" | ||
|
||
/** | ||
@class SinricProCamera | ||
@brief Camera suporting basic on / off command | ||
**/ | ||
class SinricProCamera : public SinricProDevice | ||
{ | ||
public: | ||
SinricProCamera(const char* deviceId, unsigned long eventWaitTime = 100); | ||
|
||
String getProductType() | ||
{ | ||
return SinricProDevice::getProductType() + String("CAMERA"); | ||
} | ||
}; | ||
|
||
SinricProCamera::SinricProCamera(const char* deviceId, unsigned long eventWaitTime) : SinricProDevice(deviceId, eventWaitTime) {} | ||
|
||
|
||
#endif // _SINRICCAMERA_H_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.