mirror of https://github.com/nymea/nymea.git
rf433 send bug fix
parent
3d21f85c20
commit
f2d1e69d81
|
|
@ -14,7 +14,7 @@ Radio433::Radio433(QObject *parent) :
|
|||
// Set up transmitter
|
||||
m_transmitter = new Gpio(this,22);
|
||||
m_transmitter->setDirection(OUTPUT);
|
||||
m_transmitter->setValue(HIGH);
|
||||
m_transmitter->setValue(LOW);
|
||||
|
||||
connect(m_receiver,SIGNAL(pinInterrupt()),this,SLOT(handleInterrupt()));
|
||||
|
||||
|
|
@ -41,12 +41,10 @@ void Radio433::sendData(QList<int> rawData)
|
|||
// 1 = High, 0 = Low
|
||||
m_transmitter->setValue(flag %2);
|
||||
flag++;
|
||||
//qDebug() << "flag" << flag %2;
|
||||
delayMicros(delay);
|
||||
}
|
||||
}
|
||||
//qDebug() << "signal sent." << rawData;
|
||||
|
||||
m_transmitter->setValue(LOW);
|
||||
// re-enable it
|
||||
m_receiver->start();
|
||||
|
||||
|
|
@ -63,42 +61,6 @@ int Radio433::micros()
|
|||
return (int)(now - m_epochMicro) ;
|
||||
}
|
||||
|
||||
void Radio433::delayMilli(int milliSeconds)
|
||||
{
|
||||
struct timespec sleeper, dummy ;
|
||||
|
||||
sleeper.tv_sec = (time_t)(milliSeconds / 1000) ;
|
||||
sleeper.tv_nsec = (long)(milliSeconds % 1000) * 1000000;
|
||||
|
||||
nanosleep (&sleeper, &dummy) ;
|
||||
}
|
||||
|
||||
//void Radio433::delayMicroseconds(int pulseLength)
|
||||
//{
|
||||
// struct timespec sleeper ;
|
||||
|
||||
// if(pulseLength <= 0){
|
||||
// return;
|
||||
// }else {
|
||||
// if(pulseLength < 100){
|
||||
// struct timeval tNow, tLong, tEnd ;
|
||||
|
||||
// gettimeofday (&tNow, NULL) ;
|
||||
// tLong.tv_sec = pulseLength / 1000000 ;
|
||||
// tLong.tv_usec = pulseLength % 1000000 ;
|
||||
// timeradd (&tNow, &tLong, &tEnd) ;
|
||||
|
||||
// while (timercmp (&tNow, &tEnd, <)){
|
||||
// gettimeofday (&tNow, NULL) ;
|
||||
// }
|
||||
// }
|
||||
// sleeper.tv_sec = 0 ;
|
||||
// sleeper.tv_nsec = (long)(pulseLength * 1000) ;
|
||||
// nanosleep (&sleeper, NULL);
|
||||
// //qDebug() << "time " << sleeper.tv_nsec;
|
||||
// }
|
||||
//}
|
||||
|
||||
void Radio433::delayMicros(int microSeconds)
|
||||
{
|
||||
struct timespec sleeper;
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ private:
|
|||
unsigned int m_epochMicro;
|
||||
|
||||
int micros();
|
||||
void delayMicroseconds(int pulseLength);
|
||||
void delayMicros(int microSeconds);
|
||||
void delayMilli(int milliSeconds);
|
||||
|
||||
private slots:
|
||||
void handleInterrupt();
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ void DevicePluginElro::receiveData(QList<int> rawData)
|
|||
DeviceClass deviceClass = supportedDevices().first();
|
||||
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
|
||||
if (triggerType.name() == button) {
|
||||
qDebug() << "emit trigger " << group << triggerType.name() << power;
|
||||
qDebug() << "emit trigger " << pluginName() << group << triggerType.name() << power;
|
||||
Trigger trigger = Trigger(triggerType.id(), device->id(), params);
|
||||
emit emitTrigger(trigger);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
|||
QVariantList remoteParams;
|
||||
QVariantMap familyParam;
|
||||
// family code = A-P
|
||||
familyParam.insert("name", "familycode");
|
||||
familyParam.insert("name", "familyCode");
|
||||
familyParam.insert("type", "string");
|
||||
remoteParams.append(familyParam);
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
|||
QVariantList switchDeviceParams;
|
||||
QVariantMap buttonParam;
|
||||
// button code = 1-16
|
||||
buttonParam.insert("name", "buttoncode");
|
||||
buttonParam.insert("name", "buttonCode");
|
||||
buttonParam.insert("type", "int");
|
||||
|
||||
switchDeviceParams.append(familyParam);
|
||||
|
|
@ -192,6 +192,22 @@ QUuid DevicePluginIntertechno::pluginId() const
|
|||
void DevicePluginIntertechno::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
|
||||
QList<int> rawData;
|
||||
QByteArray binCode;
|
||||
|
||||
QString familyCode = device->params().value("familyCode").toString();
|
||||
|
||||
if(familyCode == "A"){
|
||||
binCode.append("00000000");
|
||||
}else if(familyCode == "B"){
|
||||
binCode.append("01000000");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DevicePluginIntertechno::receiveData(QList<int> rawData)
|
||||
|
|
@ -391,14 +407,14 @@ void DevicePluginIntertechno::receiveData(QList<int> rawData)
|
|||
// ===================================================
|
||||
Device *device = 0;
|
||||
foreach (Device *dev, deviceList) {
|
||||
if (dev->params().contains("familycode") && dev->params().value("familycode").toString() == familyCode) {
|
||||
if (dev->params().contains("familyCode") && dev->params().value("familyCode").toString() == familyCode) {
|
||||
// Yippie! We found the device.
|
||||
device = dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device) {
|
||||
qWarning() << "couldn't find any configured device for intertech familycode:" << familyCode;
|
||||
qWarning() << "couldn't find any configured device for intertech familyCode:" << familyCode;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -409,7 +425,7 @@ void DevicePluginIntertechno::receiveData(QList<int> rawData)
|
|||
DeviceClass deviceClass = supportedDevices().first();
|
||||
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
|
||||
if (triggerType.name() == buttonCode) {
|
||||
qDebug() << "emit trigger " << familyCode << triggerType.name() << power;
|
||||
qDebug() << "emit trigger " << pluginName() << familyCode << triggerType.name() << power;
|
||||
Trigger trigger = Trigger(triggerType.id(), device->id(), params);
|
||||
emit emitTrigger(trigger);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@ if [ -z $1 ]; then
|
|||
else
|
||||
# Adds an ELRO remote control on channel 00000
|
||||
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{d85c1ef4-197c-4053-8e40-707aa671d302}","params":{"channel1":"false", "channel2":"false", "channel3":"false", "channel4": "false", "channel5":"false" }}}'; sleep 1) | nc $1 1234
|
||||
# Adds a ELRO power switch on channel 00000 and group E
|
||||
# Adds a ELRO power switch on channel 00000 and group B
|
||||
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{308ae6e6-38b3-4b3a-a513-3199da2764f8}","params":{"channel1":"false","channel2":"false", "channel3":"false", "channel4": "false","channel5":"false","A":"false","B":"true","C":"false","D":"false","E":"false" }}}'; sleep 1) | nc $1 1234
|
||||
# Adds an intertechno remote control
|
||||
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{ab73ad2f-6594-45a3-9063-8f72d365c5e5}","params":{"familycode":"J"}}}'; sleep 1) | nc $1 1234
|
||||
|
||||
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{ab73ad2f-6594-45a3-9063-8f72d365c5e5}","params":{"familyCode":"J"}}}'; sleep 1) | nc $1 1234
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue