rasProject_01 / weSweetHome
R. 240
process control / RasPi software by weinert-automation
|
Process control program for door bells IP phones etc. More...
#include "arch/config.h"
#include "homeDoor.h"
#include "weUtil.h"
#include "weStateM.h"
#include <getopt.h>
#include "weLockWatch.h"
Functions | |
void | bellsButChg (uint8_t status) |
Reaction to bell button presses. More... | |
void | doorOpTimChg (state_t *const me) |
Door opener was activated timer state change. More... | |
void | doorUnlckChg (state_t *const me) |
Door opener activation state change. More... | |
int | main (int argc, char **argv) |
The program. More... | |
void | mlBellButChg (state_t *const me) |
Middle and lower bell state change. More... | |
void | mlBellTimChg (state_t *const me) |
Middle and lower bell was rung timer state change. More... | |
void * | processIOthread (void *args) |
The task of controlling process IO. More... | |
void | resOpCoupChg (state_t *const me) |
Reserve optocoupler state change. More... | |
void | upBellButChg (state_t *const me) |
Upper bell state change. More... | |
void | upBellTimChg (state_t *const me) |
Upper bell was rung timer state change. More... | |
Variables | |
char const *const | astDoor |
Ring the door bell phones (fritzbox broadcast nummer). More... | |
state_t | doorOpTimer |
Door opener was activated timer. More... | |
state_t | mlBellTimer |
Middle and lower bell was rung timer. More... | |
char const *const | prepDoor |
Prepare ringing by file copy. | |
char const | prgNamPure [] |
The pure program name. More... | |
char const | prgSVNdat [] |
The complete SVN date string. More... | |
char const | prgSVNrev [] |
The complete SVN revision string. More... | |
state_t | upBellTimer |
Upper bell was rung timer. More... | |
Process control program for door bells IP phones etc.
The program's tasks is to monitor door bells and a door opener and to control at least one IP phone *) via an Asterisk server on the same Pi. It will log door bell events and signal door bell ringing by calling other phones (via Asterisk and a Fritz.box).
Note *): This requires that the Pi with Asterisk is made an IP phone in the home phone system (i.e. Fritz.box).
For making a phone call by something equivalent to
write acces to /asterisk/outgoing/ is required for this program, e.g. by
The program runs on a Raspberry Pi 4 with head-less (no graphics) Raspbian lite hosting an Asterisk telephone server and also an Apache web server. The Pi 4 seems more than sufficient.
Revision history
Communication
HTTP (via Apache) is used for offering the log files and other information. In future a web GUI may be implemented like those for the other process control applications, cf. hometersControl.
HTTPS is not used as all LAN communication is in guarded private home or laboratory networks. Hence, the Pi can't get a Let's Encrypt certificate in the usual way. And self signed ones aren't worth the toils in a very small user community.
A VoIP phone is used to signal events to other telephones. This phone is emulated by the Asterisk server on the same Pi and registered in the site's or home's telephone system, like fritz.box.
Calling phone(s) mechanism
When this programme detects event (door bell) to be reported by a phone call it moves a command file from ~/asteriskFiles/ to /var/spool/asterisk/outgoing/. Asterisk monitors that directory and executes command files found and deletes them (no matter success or failure).
The file is moved and not copied to /var/spool/asterisk/outgoing/ to avoid the execution of partly copied files. Hence the file to be moved will be prepared by local copy (within ~/asteriskFiles/). Content, e.g.:
Server functions
This program handles and fills error and log files to record events. Those can be accessed and viewed via http. Door bell rings are forwarded to a set of phones via Asterisk (and fritz.box).
Library usage
The program uses some standard libraries plus own libraries in weRasp/..c and include/..h, namely weGPIOd, sysUtil etc..
cross-compile by:
program by:
or due to some bugs in make use winscp and IP directly by:
void bellsButChg | ( | uint8_t | status | ) |
Reaction to bell button presses.
This function organises the reaction to the OR of all (two as of 7'2020) bell button presses. This is
a) a beeper and b) make the telephone(s) in question ring.
status | the calling bell's changed button state |
void upBellTimChg | ( | state_t *const | me | ) |
Upper bell was rung timer state change.
It turns the left red LED ON when rung respectively OFF after 4 hours or when the door opener was activated.
me | pointer to the pump timer |
void upBellButChg | ( | state_t *const | me | ) |
Upper bell state change.
This function controls the respective LED, controls the ORed bells state and triggers the "upper bell was rung" reminder timer.
void mlBellTimChg | ( | state_t *const | me | ) |
Middle and lower bell was rung timer state change.
It turns the left yellow red LED ON when rung respectively OFF after 4 hours or when the door opener was activated.
me | pointer to the lower bell timer |
void mlBellButChg | ( | state_t *const | me | ) |
Middle and lower bell state change.
This function controls the respective right yellow LED, controls the bells state and triggers the "middle and lower bell was rung" reminder timer.
void doorOpTimChg | ( | state_t *const | me | ) |
Door opener was activated timer state change.
It turns the right green LED ON dimmed to signal the door opener was inactive for more than 4 hours. On bright means inactive for less than 4 hours.when rung respectively
me | pointer to the lower bell timer |
void doorUnlckChg | ( | state_t *const | me | ) |
Door opener activation state change.
This function controls the respective LED and ends the "bell was rung unnoticed" timers.
void resOpCoupChg | ( | state_t *const | me | ) |
Reserve optocoupler state change.
This optocoupler input is not used (as of July 2020) or powered. This function just logs the (de-bounced) On state (which should not occur).
void * processIOthread | ( | void * | args | ) |
The task of controlling process IO.
This thread controls almost all processIO: 1 relay output, 6 LEDs, four digital inputs to be filtered (half wave AC via optocouplers), one beeper.
It is the 1 ms cycle and takes every forth step to sample an input. This gives five times per 50 Hz period. 2 of three will be active (LO) when the optocoupler sees an AC signal.
int main | ( | int | argc, |
char ** | argv | ||
) |
The program.
run by: homeDoorPhone [options
For options see longOptions and :: optHlpTxt.
char const prgNamPure[] |
The pure program name.
To be provided in the application's / program's source.
char const prgSVNrev[] |
The complete SVN revision string.
To be provided in the application's / program's source.
char const prgSVNdat[] |
The complete SVN date string.
To be provided in the application's / program's source.
char const* const astDoor |
Ring the door bell phones (fritzbox broadcast nummer).
fritz.box configuration (27.06.2020): TĒ¬rklingel **887 Sammel-Nr Asterisk call file:
Start ringing by file move.
state_t upBellTimer |
Upper bell was rung timer.
This timer is running as reminder that the bell was rung.
state_t mlBellTimer |
Middle and lower bell was rung timer.
This timer is running as reminder that the bell was rung.
state_t doorOpTimer |
Door opener was activated timer.
This timer is running as reminder that door was opened.