rf433 send bug fix
This commit is contained in:
parent
3d21f85c20
commit
f2d1e69d81
@ -14,7 +14,7 @@ Radio433::Radio433(QObject *parent) :
|
|||||||
// Set up transmitter
|
// Set up transmitter
|
||||||
m_transmitter = new Gpio(this,22);
|
m_transmitter = new Gpio(this,22);
|
||||||
m_transmitter->setDirection(OUTPUT);
|
m_transmitter->setDirection(OUTPUT);
|
||||||
m_transmitter->setValue(HIGH);
|
m_transmitter->setValue(LOW);
|
||||||
|
|
||||||
connect(m_receiver,SIGNAL(pinInterrupt()),this,SLOT(handleInterrupt()));
|
connect(m_receiver,SIGNAL(pinInterrupt()),this,SLOT(handleInterrupt()));
|
||||||
|
|
||||||
@ -41,12 +41,10 @@ void Radio433::sendData(QList<int> rawData)
|
|||||||
// 1 = High, 0 = Low
|
// 1 = High, 0 = Low
|
||||||
m_transmitter->setValue(flag %2);
|
m_transmitter->setValue(flag %2);
|
||||||
flag++;
|
flag++;
|
||||||
//qDebug() << "flag" << flag %2;
|
|
||||||
delayMicros(delay);
|
delayMicros(delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//qDebug() << "signal sent." << rawData;
|
m_transmitter->setValue(LOW);
|
||||||
|
|
||||||
// re-enable it
|
// re-enable it
|
||||||
m_receiver->start();
|
m_receiver->start();
|
||||||
|
|
||||||
@ -63,42 +61,6 @@ int Radio433::micros()
|
|||||||
return (int)(now - m_epochMicro) ;
|
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)
|
void Radio433::delayMicros(int microSeconds)
|
||||||
{
|
{
|
||||||
struct timespec sleeper;
|
struct timespec sleeper;
|
||||||
|
|||||||
@ -30,9 +30,7 @@ private:
|
|||||||
unsigned int m_epochMicro;
|
unsigned int m_epochMicro;
|
||||||
|
|
||||||
int micros();
|
int micros();
|
||||||
void delayMicroseconds(int pulseLength);
|
|
||||||
void delayMicros(int microSeconds);
|
void delayMicros(int microSeconds);
|
||||||
void delayMilli(int milliSeconds);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleInterrupt();
|
void handleInterrupt();
|
||||||
|
|||||||
@ -358,7 +358,7 @@ void DevicePluginElro::receiveData(QList<int> rawData)
|
|||||||
DeviceClass deviceClass = supportedDevices().first();
|
DeviceClass deviceClass = supportedDevices().first();
|
||||||
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
|
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
|
||||||
if (triggerType.name() == button) {
|
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);
|
Trigger trigger = Trigger(triggerType.id(), device->id(), params);
|
||||||
emit emitTrigger(trigger);
|
emit emitTrigger(trigger);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
|||||||
QVariantList remoteParams;
|
QVariantList remoteParams;
|
||||||
QVariantMap familyParam;
|
QVariantMap familyParam;
|
||||||
// family code = A-P
|
// family code = A-P
|
||||||
familyParam.insert("name", "familycode");
|
familyParam.insert("name", "familyCode");
|
||||||
familyParam.insert("type", "string");
|
familyParam.insert("type", "string");
|
||||||
remoteParams.append(familyParam);
|
remoteParams.append(familyParam);
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
|||||||
QVariantList switchDeviceParams;
|
QVariantList switchDeviceParams;
|
||||||
QVariantMap buttonParam;
|
QVariantMap buttonParam;
|
||||||
// button code = 1-16
|
// button code = 1-16
|
||||||
buttonParam.insert("name", "buttoncode");
|
buttonParam.insert("name", "buttonCode");
|
||||||
buttonParam.insert("type", "int");
|
buttonParam.insert("type", "int");
|
||||||
|
|
||||||
switchDeviceParams.append(familyParam);
|
switchDeviceParams.append(familyParam);
|
||||||
@ -192,6 +192,22 @@ QUuid DevicePluginIntertechno::pluginId() const
|
|||||||
void DevicePluginIntertechno::executeAction(Device *device, const Action &action)
|
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)
|
void DevicePluginIntertechno::receiveData(QList<int> rawData)
|
||||||
@ -391,14 +407,14 @@ void DevicePluginIntertechno::receiveData(QList<int> rawData)
|
|||||||
// ===================================================
|
// ===================================================
|
||||||
Device *device = 0;
|
Device *device = 0;
|
||||||
foreach (Device *dev, deviceList) {
|
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.
|
// Yippie! We found the device.
|
||||||
device = dev;
|
device = dev;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!device) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +425,7 @@ void DevicePluginIntertechno::receiveData(QList<int> rawData)
|
|||||||
DeviceClass deviceClass = supportedDevices().first();
|
DeviceClass deviceClass = supportedDevices().first();
|
||||||
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
|
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
|
||||||
if (triggerType.name() == buttonCode) {
|
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);
|
Trigger trigger = Trigger(triggerType.id(), device->id(), params);
|
||||||
emit emitTrigger(trigger);
|
emit emitTrigger(trigger);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -6,9 +6,8 @@ if [ -z $1 ]; then
|
|||||||
else
|
else
|
||||||
# Adds an ELRO remote control on channel 00000
|
# 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
|
(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
|
(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
|
# 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
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user