Skip to content

Commit

Permalink
Initial commit of all V2_03 files
Browse files Browse the repository at this point in the history
This is a quite large commit which completes the  transition of maintaining the plugin from SVN to GIT in order to provide updates on every public release of deCONZ.
  • Loading branch information
manup committed Mar 19, 2016
1 parent a62a988 commit 01f0071
Show file tree
Hide file tree
Showing 46 changed files with 15,748 additions and 1,160 deletions.
3 changes: 2 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2013, dresden elektronik ingenieurtechnik gmbh
The MIT License (MIT)
Copyright (c) 2016, dresden elektronik ingenieurtechnik gmbh
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ Currently the compilation of the plugin is only supported within the Raspbian di

`git clone https://github.com/dresden-elektronik/deconz-rest-plugin.git`

2. If you haven't already, install qt4

`sudo apt-get install libqt4-dev libqt4-core`

3. Compile the plugin
2. Compile the plugin

`cd deconz-rest-plugin`

Expand Down
119 changes: 119 additions & 0 deletions atmel_wsndemo_sensor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright (c) 2016 dresden elektronik ingenieurtechnik gmbh.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
* style license a copy of which has been included with this distribution in
* the LICENSE.txt file.
*
*/

#include "de_web_plugin_private.h"


/*! WSNDemo sensor data handler send by routers and end devices.
\param ind a WSNDemo data frame
*/
void DeRestPluginPrivate::wsnDemoDataIndication(const deCONZ::ApsDataIndication &ind)
{
// check valid WSNDemo endpoint
if (ind.srcEndpoint() != 0x01)
{
return;
}

// check WSNDemo cluster
if (ind.clusterId() != 0x0001)
{
return;
}

QDataStream stream(ind.asdu());
stream.setByteOrder(QDataStream::LittleEndian);

uint8_t msgType;
uint8_t nodeType;
quint64 ieeeAddr;
uint16_t nwkAddr;
uint32_t version;
uint32_t channelMask;
uint16_t panId;
uint8_t channel;
uint16_t parentAddr;
uint8_t lqi;
int8_t rssi;
uint8_t fieldType;
uint8_t fieldSize;
// if fieldtype == 0x01 (sensor data)
uint32_t battery;
uint32_t temperature;
uint32_t illuminance;

stream >> msgType;
stream >> nodeType;
stream >> ieeeAddr;
stream >> nwkAddr;
stream >> version;
stream >> channelMask;
stream >> panId;
stream >> channel;
stream >> parentAddr;
stream >> lqi;
stream >> rssi;
stream >> fieldType;
stream >> fieldSize;

if (fieldType == 0x01)
{
stream >> battery;
stream >> temperature;
stream >> illuminance;

DBG_Printf(DBG_INFO, "Sensor 0x%016llX battery: %u, temperature: %u, light: %u\n", ieeeAddr, battery, temperature, illuminance);

// std::vector<Sensor>::iterator i = sensors.begin();
// std::vector<Sensor>::iterator end = sensors.end();
/* TODO review code for new sensor API
for ( ; i != end; ++i)
{
if (i->address().ext() == ieeeAddr)
{
bool updated = false;
if (i->temperature() != (double)temperature)
{
updated = true;
i->setTemperature(temperature);
}
if (i->lux() != (double)illuminance)
{
updated = true;
i->setLux(illuminance);
}
if (updated)
{
updateEtag(i->etag);
}
return;
}
}
*/
// does not exist yet create Sensor instance
DBG_Printf(DBG_INFO, "found new sensor 0x%016llX\n", ieeeAddr);
Sensor sensor;
sensor.setName(QString("Sensor %1").arg(sensors.size() + 1));
/*
sensor.address().setExt(ieeeAddr);
sensor.address().setNwk(nwkAddr);
sensor.setId(sensor.address().toStringExt());
sensor.setLux(illuminance);
sensor.setTemperature(temperature);
*/
updateEtag(sensor.etag);
sensors.push_back(sensor);
}

}
8 changes: 4 additions & 4 deletions authentification.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 dresden elektronik ingenieurtechnik gmbh.
* Copyright (c) 2016 dresden elektronik ingenieurtechnik gmbh.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
Expand All @@ -9,7 +9,6 @@
*/

#include "de_web_plugin_private.h"
#include <QHttpResponseHeader>
#ifdef Q_OS_UNIX
#include <unistd.h>
#endif
Expand All @@ -18,7 +17,8 @@
static const char *pwsalt = "$1$8282jdkmskwiu29291"; // $1$ for MD5
#endif

ApiAuth::ApiAuth()
ApiAuth::ApiAuth() :
state(StateNormal)
{

}
Expand Down Expand Up @@ -55,7 +55,7 @@ void DeRestPluginPrivate::initAuthentification()

gwAdminPasswordHash = encryptString(hash);

queSaveDb(DB_AUTH, DB_SHORT_SAVE_DELAY);
queSaveDb(DB_CONFIG, DB_SHORT_SAVE_DELAY);
}

}
Expand Down
Loading

0 comments on commit 01f0071

Please sign in to comment.