nein das lässt sich auch nicht anlernen:
Code: Alles auswählen
08:35:44.112 -> AskSin++ v5.0.0 (Mar 13 2021 08:34:05)
08:35:44.112 -> Address Space: 32 - 99
08:35:44.112 -> CC init1
08:35:44.112 -> CC Version: 14
08:35:44.158 -> - ready
08:35:44.158 -> iVcc: 3352
08:35:52.121 -> debounce
08:35:52.215 -> pressed
08:35:52.307 -> released
08:35:52.355 -> <- 1A 01 84 00 001A00 000000 11 00 1A 48 4D 52 43 30 30 31 41 30 30 40 01 00 00 - 155
08:35:52.401 ->
Mein Frequenz Test sieht so aus:
Code: Alles auswählen
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// 2019-11-16 stan23 Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// ci-test=yes board=328p aes=no
//- -----------------------------------------------------------------------------------------------------------------------
// define this to read the device id, serial and device type from bootloader section
// #define USE_OTA_BOOTLOADER
#if defined ARDUINO_ARCH_STM32F1
#define STORAGEDRIVER at24cX<0x50,128,32>
#define TICKS_PER_SECOND 500UL
#define USE_HW_SERIAL
#include <SPI.h> // when we include SPI.h - we can use LibSPI class
#include <Wire.h> // for I2C access to EEPROM
#include <EEPROM.h> // the EEPROM library contains Flash Access Methods
#endif
#include <AskSinPP.h>
#include <Device.h>
#include <Register.h>
#if defined ARDUINO_ARCH_STM32F1
// we use a BluePill
#define CC1101_GDO0_PIN PB0
#define CC1101_CS_PIN PA4
// CC1101 communication uses HW-SPI
#define LED_PIN LED_BUILTIN
#else
// we use a Pro Mini
#define CC1101_GDO0_PIN 2 // PD2
#define CC1101_CS_PIN 10 // PB2
#define CC1101_MOSI_PIN 11 // PB3
#define CC1101_MISO_PIN 12 // PB4
#define CC1101_SCK_PIN 13 // PB5
// Pro Mini LED
#define LED_PIN 4 // PD4
#endif
// all library classes are placed in the namespace 'as'
using namespace as;
// define all device properties
const struct DeviceInfo PROGMEM devinfo = {
{0x01,0x01,0x01}, // Device ID
"FreqTest00", // Device Serial
{0x00,0x00}, // Device Model
0x10, // Firmware Version
as::DeviceType::Sensor, // Device Type
{0x00,0x00} // Info Bytes
};
/**
* Configure the used hardware
*/
#if defined ARDUINO_ARCH_STM32F1
typedef LibSPI<CC1101_CS_PIN> RadioSPI;
#else
typedef AvrSPI<CC1101_CS_PIN, CC1101_MOSI_PIN, CC1101_MISO_PIN, CC1101_SCK_PIN> RadioSPI;
#endif
typedef Radio<RadioSPI, CC1101_GDO0_PIN> RadioType;
typedef StatusLed<LED_PIN> LedType;
typedef AskSin<LedType,NoBattery,RadioType> HalType;
#define STARTFREQ 0x656A // frequency we start scanning
#define MINFREQ (STARTFREQ - 0x300) // frequency we abort scanning
#define SEARCHSTEP 0x50 // step with during search
#define BOUNDSTEP 0x10 // step width during upper/lower bound analysis
// see https://github.com/AskSinPP/asksinpp.de/blob/master/Grundlagen/FAQ/Fehlerhafte_CC1101.md
#define ACTIVE_PING
HMID PING_FROM(0x5A,0xF4,0x21); // from address for status message e.g. switch
HMID PING_TO(0xff,0xff,0xff); // to address for status message / central / CCU
#ifdef ACTIVE_PING
#define SCANTIME seconds2ticks(5) // maximal time to wait for a valid message
#else
#define SCANTIME seconds2ticks(60) // maximal time to wait for a valid message
#endif
class TestDevice : public Device<HalType,DefList0>, Alarm {
DefList0 l0;
uint16_t freq, start, end;
uint8_t received, rssi;
public:
enum SearchMode { Search, Up, Down, Done };
SearchMode mode;
HMID id;
typedef Device<HalType,DefList0> BaseDevice;
TestDevice (const DeviceInfo& i,uint16_t addr) : BaseDevice(i,addr,l0,0), Alarm(0), l0(addr),
freq(STARTFREQ), start(STARTFREQ), end(STARTFREQ),
received(0), rssi(0), mode(Search) {}
virtual ~TestDevice () {}
virtual void trigger (__attribute__ ((unused)) AlarmClock& clock) {
DPRINT(" ");DDEC(received);
if (!received) {
DPRINTLN("");
} else {
DPRINT(" / -");DDEC(rssi);DPRINTLN("dBm");
}
if( mode == Search ) {
if( received > 0 ) {
start = end = freq;
mode = Up; // start find upper bound
DPRINTLN("Search for upper bound");
setFreq(freq + BOUNDSTEP);
}
else {
if( freq < MINFREQ ) mode = Done;
if( freq <= STARTFREQ ) setFreq(STARTFREQ + (STARTFREQ-freq) + SEARCHSTEP);
else setFreq(STARTFREQ - (freq-STARTFREQ));
}
}
else if(mode == Up) {
if( received > 0 ) {
end = freq;
setFreq(end + BOUNDSTEP);
}
else {
mode = Down; // start find lower bound
DPRINTLN("Search for lower bound");
setFreq(start - BOUNDSTEP);
}
}
else if(mode == Down) {
if( received > 0 ) {
start = freq;
setFreq(start - BOUNDSTEP);
}
else {
mode = Done;
}
}
if( mode == Done ) {
DPRINT("\nDone: 0x21");DHEX(start);DPRINT(" - 0x21");DHEXLN(end);
if( start == end && start == STARTFREQ ) {
DPRINT("Could not receive any message");
}
else {
freq = start+((end - start)/2);
DPRINT("Calculated Freq: 0x21");DHEX((uint8_t)(freq>>8));DHEX((uint8_t)(freq&0xff));
printFreq(0x210000 + freq);DPRINTLN("");
// store frequency
DPRINT("Store into config area: ");DHEX((uint8_t)(freq>>8));DHEX((uint8_t)(freq&0xff));
StorageConfig sc = getConfigArea();
#if defined ARDUINO_ARCH_STM32F1
Wire.begin();
DPRINT(".");
#endif
sc.clear();
DPRINT(".");
sc.setByte(CONFIG_FREQ1, freq>>8);
DPRINT(".");
sc.setByte(CONFIG_FREQ2, freq&0xff);
DPRINT(".");
sc.validate();
DPRINTLN("stored!");
#if defined ARDUINO_ARCH_STM32F1
// measurement is done, loop here forever
while(1);
#else
activity().savePower<Sleep<> >(this->getHal());
#endif
}
}
}
virtual bool process(Message& msg) {
msg.from().dump(); DPRINT(".");
rssi = max(rssi,radio().rssi());
received++;
if( received > 0 ) {
trigger(sysclock);
}
return true;
}
bool init (HalType& hal) {
this->setHal(hal);
this->getDeviceID(id);
hal.init(id);
DPRINTLN("Start searching ...");
setFreq(STARTFREQ);
return false;
}
void setFreq (uint16_t current) {
sysclock.cancel(*this);
freq = current;
rssi=0;
received=0;
DPRINT("Freq 0x21");DHEX(freq);
printFreq(0x210000 + freq);
DPRINT(": ");
this->radio().initReg(CC1101_FREQ2, 0x21);
this->radio().initReg(CC1101_FREQ1, freq >> 8);
this->radio().initReg(CC1101_FREQ0, freq & 0xff);
set(SCANTIME);
sysclock.add(*this);
}
void printFreq(uint32_t freq) {
char buffer[16];
float val = (float)freq * 26.0 / 65536.0;
dtostrf(val, 8, 3, buffer);
DPRINT(buffer);DPRINT(" MHz");
}
};
HalType hal;
TestDevice sdev(devinfo,0x20);
class InfoSender : public Alarm {
class channel {
public:
uint8_t number() const {return 1; }
uint8_t status() const {return 0; }
uint8_t flags() const {return 0; }
void patchStatus(__attribute__ ((unused)) Message& msg) {}
void changed(__attribute__ ((unused)) bool b) {}
};
uint8_t cnt;
channel ch;
public:
InfoSender () : Alarm(0), cnt(0) {}
virtual ~InfoSender () {}
virtual void trigger (AlarmClock& clock) {
#ifdef ACTIVE_PING
InfoActuatorStatusMsg msg;
msg.init(cnt++, ch, hal.radio.rssi());
msg.to(PING_TO);
msg.from(PING_FROM);
msg.ackRequired();
msg.setRpten();
sdev.radio().write(msg,msg.burstRequired());
#endif
sdev.led().ledOn(millis2ticks(100), 0);
if( sdev.mode != TestDevice::SearchMode::Done ) {
set(seconds2ticks(1));
clock.add(*this);
}
}
} info;
void setup () {
#if defined ARDUINO_ARCH_STM32F1
delay(5000);
#endif
DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
sdev.init(hal);
// start sender
info.trigger(sysclock);
}
void loop() {
sdev.pollRadio();
hal.runready();
}
So sieht mein Homematic Skript aus:
Code: Alles auswählen
! Folgend muss die Seriennummer angepasst werden.
! Es sollte ein nicht batteriebetriebenen Gerätes gewählt werden.
string serial = "OEQ0771846";
string ccu;
string device;
string stderr;
system.Exec("grep BidCoS-Address /etc/config/ids | awk -F '= ?' -v format='%x\n' '{printf(format,$2)}'", &ccu, &stderr);
WriteLine(stderr);
system.Exec("grep '^<device serial' /etc/config/rfd/" + serial + ".dev | sed 's/.*address=.0x\([0-9A-F]*\). .*/\1/'", &device, &stderr);
WriteLine(stderr);
WriteLine("PING_FROM(0x" + device.Substr(0,2) + ",0x" + device.Substr(2,2) + ",0x" + device.Substr(4,2) + ");" );
WriteLine("PING_TO(0x" + ccu.Substr(0,2) + ",0x" + ccu.Substr(2,2) + ",0x" + ccu.Substr(4,2) + ");" );
und das ist das Ergebnis:
komisch ...