Seite 1 von 2

AskSinPP Code erweitern aber wie und wo ?

Verfasst: 25.01.2019, 10:14
von eibi99
Hallo !
Mit den klasse Infos und Code konnte ich einen HM Gerät aus Arduino Nano + CC1101 nachbauen

Normallerweise fragt man nun einen PIN ab und wenn der auf Low steht wird ein HM Funk Telegram gesendet.

Ich möchte aber keinen PIN abfragen, sondern das beim booten des Arduino vielleicht 3x ein HM Telegram gesendet wird.

Hintergrund: Ich mlchte einen Wassersensor erweitern. Wenn Wasseralarm bekommt Arduino Spannung, bootet und sendet 2-3 telegramme an FHEM.

Kann mir jemand sagen wo im Arduino Sketch ich da was modifizieren muss ?

Verwende HM-RC-4.ino

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 25.01.2019, 13:22
von papa
Tja - einfach die Messages schicken und dann in den Tiefschlaf gehen. Könnte so aussehen

Code: Alles auswählen

bool sendRemoteMsg (DeviceType& device, uint8_t channelnum, uint8_t counter, bool longpress) {
  RemoteEventMsg& msg = (RemoteEventMsg&)device.message();
  uint8_t msgcnt = device.nextcount();
  msg.init(msgcnt,channelnum,counter,longpress,false);
  // msg.clearAck(); uncomment if no ack needed
  return device.send(msg,device.getMasterID());
}

bool succcess=false;
int counter=1;
void loop () {
  if( success == false && counter <= 3 ) {
    success = sendRemoteMsg (sdev,1,counter++,false);
    delay(1000);
  }
  else {
    // this call will never return
    hal.activity.sleepForever(hal);
  }
}

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 25.01.2019, 16:42
von eibi99
Besten Dank für die Antwort.

Habe den void loop() Teil aus dem Sketch mit dem Code in der Antwort ersetzt. Bekomme allerdings Komilierungsfehler.

Irgendeine Idee ?

var/folders/5s/nwrz236x61z31gplznnx7qyc0000gn/T/arduino_modified_sketch_373015/HM-RC-4.ino: In function 'bool sendRemoteMsg(as::DeviceType&, uint8_t, uint8_t, bool)':
HM-RC-4:98:49: error: 'class as::DeviceType' has no member named 'message'
RemoteEventMsg& msg = (RemoteEventMsg&)device.message();
^
HM-RC-4:99:27: error: 'class as::DeviceType' has no member named 'nextcount'
uint8_t msgcnt = device.nextcount();
^
HM-RC-4:102:17: error: 'class as::DeviceType' has no member named 'send'
return device.send(msg,device.getMasterID());
^
HM-RC-4:102:33: error: 'class as::DeviceType' has no member named 'getMasterID'
return device.send(msg,device.getMasterID());
^
/var/folders/5s/nwrz236x61z31gplznnx7qyc0000gn/T/arduino_modified_sketch_373015/HM-RC-4.ino: In function 'void loop()':
HM-RC-4:108:7: error: 'success' was not declared in this scope
if( success == false && counter <= 3 ) {
^
HM-RC-4:109:52: error: invalid initialization of reference of type 'as::DeviceType&' from expression of type 'RemoteType {aka as::MultiChannelDevice<Hal, as::RemoteChannel<Hal, 10, as::List0>, 4>}'
success = sendRemoteMsg (sdev,1,counter++,false);
^
/var/folders/5s/nwrz236x61z31gplznnx7qyc0000gn/T/arduino_modified_sketch_373015/HM-RC-4.ino:97:6: note: in passing argument 1 of 'bool sendRemoteMsg(as::DeviceType&, uint8_t, uint8_t, bool)'
bool sendRemoteMsg (DeviceType& device, uint8_t channelnum, uint8_t counter, bool longpress) {
^
exit status 1
'class as::DeviceType' has no member named 'message'

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 25.01.2019, 16:45
von papa
Mach mal aus DeviceType -> RemoteType

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 25.01.2019, 16:49
von jp112sdl
Ändere mal

Code: Alles auswählen

bool sendRemoteMsg (DeviceType& device, uint8_t channelnum, uint8_t counter, bool longpress) {
in

Code: Alles auswählen

bool sendRemoteMsg (RemoteType& device, uint8_t channelnum, uint8_t counter, bool longpress) {
sowie

Code: Alles auswählen

bool succcess=false;
in

Code: Alles auswählen

bool success=false;

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 25.01.2019, 18:10
von eibi99
Funktioniert. :D Danke Euch vielmals !

Habe es noch ein wenig abgeändert, so dass beim Starten 2x gesendet wird und danach der normale Betriebsmodus erreicht wird.

Änderung in HM-RC-4.ino

//Neu
bool sendRemoteMsg (RemoteType& device, uint8_t channelnum, uint8_t counter, bool longpress) {
RemoteEventMsg& msg = (RemoteEventMsg&)device.message();
uint8_t msgcnt = device.nextcount();
msg.init(msgcnt,channelnum,counter,longpress,false);
// msg.clearAck(); uncomment if no ack needed
return device.send(msg,device.getMasterID());
}


void setup () {
DINIT(57600,ASKSIN_PLUS_PLUS_IDENTIFIER);
sdev.init(hal);
remoteISR(sdev,1,BTN1_PIN);
remoteISR(sdev,2,BTN2_PIN);
remoteISR(sdev,3,BTN3_PIN);
remoteISR(sdev,4,BTN4_PIN);
buttonISR(cfgBtn,CONFIG_BUTTON_PIN);
sdev.initDone();
bool success=false;
int counter=1;
do {
success = sendRemoteMsg (sdev,1,counter++,false);
delay(1000);
} while (counter < 3);

}


void loop() {
bool worked = hal.runready();
bool poll = sdev.pollRadio();
if( worked == false && poll == false ) {
hal.activity.savePower<Sleep<>>(hal);
}
}

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 10.01.2020, 21:48
von Muxer
Ich möchte für meine Anwendung nur einen Impuls bei "Power-On" erhalten.
Einfach gedacht mache hier aus " counter < 3" ein "counter < 2" dann gehts.

Code: Alles auswählen

bool success=false;
int counter=1;
do {
success = sendRemoteMsg (sdev,1,counter++,false);
delay(1000);
} while (counter < 2);
Leider nicht.
Nach dem flashen kommt 1 Impuls. Bei Reset oder Power-On keine Reaktion.

Bei

Code: Alles auswählen

bool success=false;
int counter=1;
do {
success = sendRemoteMsg (sdev,1,counter++,false);
delay(1000);
} while (counter < 3);
funktioniert alles.
Gibst Ideen?

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 10.01.2020, 22:02
von jp112sdl
Muxer hat geschrieben:
10.01.2020, 21:48
keine Reaktion.
Wo kommt keine Reaktion?


Ich verstehe dein riesen Konstrukt auch nicht.

Code: Alles auswählen

bool success=false;
int counter=1;
do {
success = sendRemoteMsg (sdev,1,counter++,false);
delay(1000);
} while (counter < 2);
ist doch das selbe wie

Code: Alles auswählen

 sendRemoteMsg (sdev,1,1,false);
 

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 10.01.2020, 22:17
von Muxer
Habe das hier gefunden
von eibi99 » 25.01.2019, 18:10
Funktioniert. :D Danke Euch vielmals !

Habe es noch ein wenig abgeändert, so dass beim Starten 2x gesendet wird und danach der normale Betriebsmodus erreicht wird.
Bei

Code: Alles auswählen

bool success=false;
int counter=1;
do {
success = sendRemoteMsg (sdev,1,counter++,false);
delay(1000);
} while (counter < 3);
}
Kommen 2 Schaltsignale von Taster 1 bei Power-On
Bei "counter < 2" passiert nichts auch nicht bei

Code: Alles auswählen

sendRemoteMsg (sdev,1,1,false);
Ich verstehe dein riesen Konstrukt auch nicht.
ist nicht von mir sondern von siehe oben.

Re: AskSinPP Code erweitern aber wie und wo ?

Verfasst: 10.01.2020, 22:21
von jp112sdl
Muxer hat geschrieben:
10.01.2020, 22:17
Kommen 2 Schaltsignale von Taster 1 bei Power-On
Bei "counter < 2" passiert nichts auch nicht bei
Kommt nichts / passiert nichts...
- im seriellen Monitor?
- oder in der CCU?
- oder am verknüpften Aktor?