29 #define IOTPLOTTER_UPDATE_URL QStringLiteral("http://iotplotter.com/api/v2/feed/") // NB insecure 30 #define IOTPLOTTER_MAX_ERRORS 5 31 #define IOTPLOTTER_MAX_FIELDS 8 // I can't actually see a max 42 if (Details.contains(QStringLiteral(
"feedid")))
43 m_feedId = Details.value(QStringLiteral(
"feedid")).toString().trimmed();
45 if (m_feedId.isEmpty())
47 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"%1 logger has no feed id - disabling").arg(
m_description));
57 QNetworkRequest qrequest(url);
58 qrequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/x-www-form-urlencoded");
59 qrequest.setRawHeader(
"api-key",
m_apiKey.toLocal8Bit());
64 QString epoch = QStringLiteral(
"%1").arg(((quint64)QDateTime::currentMSecsSinceEpoch() / 1000));
73 pair.insert(QStringLiteral(
"value"),
m_fieldValues[i].toLongLong());
74 pair.insert(QStringLiteral(
"epoch"), epoch.toLongLong());
85 data.insert(QStringLiteral(
"data"), raw);
86 QJsonDocument doc(data);
87 QByteArray serialiseddata = doc.toJson(QJsonDocument::Indented);
88 qrequest.setHeader(QNetworkRequest::ContentLengthHeader, serialiseddata.size());
100 TorcNotifier* Create(
const QString &Type,
const QVariantMap &Details)
override 102 if (Type == QStringLiteral(
"iotplotter") && Details.contains(QStringLiteral(
"apikey")) && Details.contains(QStringLiteral(
"fields")) &&
103 Details.contains(QStringLiteral(
"feedid")))
virtual bool Initialise(const QVariantMap &Details)
#define IOTPLOTTER_MAX_ERRORS
virtual void SetValid(bool Valid)
A wrapper around QNetworkRequest.
QMap< int, QString > m_reverseFields
void ProcessRequest(TorcNetworkRequest *Request) override
#define IOTPLOTTER_MAX_FIELDS
QString m_fieldValues[32]
TorcIoTPlotterNotifier(const QVariantMap &Details)
#define LOG(_MASK_, _LEVEL_, _STRING_)
TorcIoTPlotterNotifierFactory TorcIoTPlotterNotifierFactory
#define IOTPLOTTER_UPDATE_URL
TorcNetworkRequest * CreateRequest(void) override