diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..f51e2f3 --- /dev/null +++ b/build.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Author : vincent.benoit@benserv.fr +# Date : 11/2022 +# Version : 1.0 +# Brief : création des packages necessaires pour le processus KineIntercom +# +########################################################################### + +create_deb() { + dirname=kineintercommisc-$1 + /usr/bin/mkdir -p bdist_deb/$dirname + cd bdist_deb/$dirname + /usr/bin/dh_make -t $2/template -n -y -i -d + /usr/bin/find $2/misc -type f -exec /usr/bin/cp -a {} . \; + /usr/bin/dpkg-buildpackage -b -uc -us -rfakeroot + cd .. + if [ $? == "0" ] && [ ! -d "$2/dist" ]; then + /usr/bin/mkdir -p $2/dist + /usr/bin/find . -type f -name "*.deb" -exec /usr/bin/cp -a {} $2/dist \; + fi +} + +create_wheel() { + cd $1 + /usr/bin/python3 setup.py bdist_wheel --universal +} + +echo "*** Remove old dirs ***" +/usr/bin/rm -rf bdist_deb build dist *.egg-info +echo "*** read version ***" +vers=`/usr/bin/cat src/VERSION` +rootpath=`pwd` +echo "*** Create Debian Misc Package ***" +create_deb "$vers" "$rootpath" +echo "*** Create Python Package ***" +create_wheel "$rootpath" +echo "*** that's All Folks ...***" diff --git a/misc/database_origin.json b/misc/database_origin.json new file mode 100644 index 0000000..9852c61 --- /dev/null +++ b/misc/database_origin.json @@ -0,0 +1,1389 @@ +{ + "CODE_PIN": "0000", + "DTMF_CODE": "*", + "DTMF_DURATION": 2, + "HORAIRES": { + "Friday": [ + { + "name": "00h00", + "state": 0 + }, + { + "name": "00h30", + "state": 0 + }, + { + "name": "01h00", + "state": 0 + }, + { + "name": "01h30", + "state": 0 + }, + { + "name": "02h00", + "state": 0 + }, + { + "name": "02h30", + "state": 0 + }, + { + "name": "03h00", + "state": 0 + }, + { + "name": "03h30", + "state": 0 + }, + { + "name": "04h00", + "state": 0 + }, + { + "name": "04h30", + "state": 0 + }, + { + "name": "05h00", + "state": 0 + }, + { + "name": "05h30", + "state": 0 + }, + { + "name": "06h00", + "state": 0 + }, + { + "name": "06h30", + "state": 0 + }, + { + "name": "07h00", + "state": 0 + }, + { + "name": "07h30", + "state": 0 + }, + { + "name": "08h00", + "state": 0 + }, + { + "name": "08h30", + "state": 0 + }, + { + "name": "09h00", + "state": 0 + }, + { + "name": "09h30", + "state": 0 + }, + { + "name": "10h00", + "state": 0 + }, + { + "name": "10h30", + "state": 0 + }, + { + "name": "11h00", + "state": 0 + }, + { + "name": "11h30", + "state": 0 + }, + { + "name": "12h00", + "state": 0 + }, + { + "name": "12h30", + "state": 0 + }, + { + "name": "13h00", + "state": 0 + }, + { + "name": "13h30", + "state": 0 + }, + { + "name": "14h00", + "state": 0 + }, + { + "name": "14h30", + "state": 0 + }, + { + "name": "15h00", + "state": 0 + }, + { + "name": "15h30", + "state": 0 + }, + { + "name": "16h00", + "state": 0 + }, + { + "name": "16h30", + "state": 0 + }, + { + "name": "17h00", + "state": 0 + }, + { + "name": "17h30", + "state": 0 + }, + { + "name": "18h00", + "state": 0 + }, + { + "name": "18h30", + "state": 0 + }, + { + "name": "19h00", + "state": 0 + }, + { + "name": "19h30", + "state": 0 + }, + { + "name": "20h00", + "state": 0 + }, + { + "name": "20h30", + "state": 0 + }, + { + "name": "21h00", + "state": 0 + }, + { + "name": "21h30", + "state": 0 + }, + { + "name": "22h00", + "state": 0 + }, + { + "name": "22h30", + "state": 0 + }, + { + "name": "23h00", + "state": 0 + }, + { + "name": "23h30", + "state": 0 + } + ], + "Monday": [ + { + "name": "00h00", + "state": 0 + }, + { + "name": "00h30", + "state": 0 + }, + { + "name": "01h00", + "state": 0 + }, + { + "name": "01h30", + "state": 0 + }, + { + "name": "02h00", + "state": 0 + }, + { + "name": "02h30", + "state": 0 + }, + { + "name": "03h00", + "state": 0 + }, + { + "name": "03h30", + "state": 0 + }, + { + "name": "04h00", + "state": 0 + }, + { + "name": "04h30", + "state": 0 + }, + { + "name": "05h00", + "state": 0 + }, + { + "name": "05h30", + "state": 0 + }, + { + "name": "06h00", + "state": 0 + }, + { + "name": "06h30", + "state": 0 + }, + { + "name": "07h00", + "state": 0 + }, + { + "name": "07h30", + "state": 0 + }, + { + "name": "08h00", + "state": 0 + }, + { + "name": "08h30", + "state": 0 + }, + { + "name": "09h00", + "state": 0 + }, + { + "name": "09h30", + "state": 0 + }, + { + "name": "10h00", + "state": 0 + }, + { + "name": "10h30", + "state": 0 + }, + { + "name": "11h00", + "state": 0 + }, + { + "name": "11h30", + "state": 0 + }, + { + "name": "12h00", + "state": 0 + }, + { + "name": "12h30", + "state": 0 + }, + { + "name": "13h00", + "state": 0 + }, + { + "name": "13h30", + "state": 0 + }, + { + "name": "14h00", + "state": 0 + }, + { + "name": "14h30", + "state": 0 + }, + { + "name": "15h00", + "state": 0 + }, + { + "name": "15h30", + "state": 0 + }, + { + "name": "16h00", + "state": 0 + }, + { + "name": "16h30", + "state": 0 + }, + { + "name": "17h00", + "state": 0 + }, + { + "name": "17h30", + "state": 0 + }, + { + "name": "18h00", + "state": 0 + }, + { + "name": "18h30", + "state": 0 + }, + { + "name": "19h00", + "state": 0 + }, + { + "name": "19h30", + "state": 0 + }, + { + "name": "20h00", + "state": 0 + }, + { + "name": "20h30", + "state": 0 + }, + { + "name": "21h00", + "state": 0 + }, + { + "name": "21h30", + "state": 0 + }, + { + "name": "22h00", + "state": 0 + }, + { + "name": "22h30", + "state": 0 + }, + { + "name": "23h00", + "state": 0 + }, + { + "name": "23h30", + "state": 0 + } + ], + "Saturday": [ + { + "name": "00h00", + "state": 0 + }, + { + "name": "00h30", + "state": 0 + }, + { + "name": "01h00", + "state": 0 + }, + { + "name": "01h30", + "state": 0 + }, + { + "name": "02h00", + "state": 0 + }, + { + "name": "02h30", + "state": 0 + }, + { + "name": "03h00", + "state": 0 + }, + { + "name": "03h30", + "state": 0 + }, + { + "name": "04h00", + "state": 0 + }, + { + "name": "04h30", + "state": 0 + }, + { + "name": "05h00", + "state": 0 + }, + { + "name": "05h30", + "state": 0 + }, + { + "name": "06h00", + "state": 0 + }, + { + "name": "06h30", + "state": 0 + }, + { + "name": "07h00", + "state": 0 + }, + { + "name": "07h30", + "state": 0 + }, + { + "name": "08h00", + "state": 0 + }, + { + "name": "08h30", + "state": 0 + }, + { + "name": "09h00", + "state": 0 + }, + { + "name": "09h30", + "state": 0 + }, + { + "name": "10h00", + "state": 0 + }, + { + "name": "10h30", + "state": 0 + }, + { + "name": "11h00", + "state": 0 + }, + { + "name": "11h30", + "state": 0 + }, + { + "name": "12h00", + "state": 0 + }, + { + "name": "12h30", + "state": 0 + }, + { + "name": "13h00", + "state": 0 + }, + { + "name": "13h30", + "state": 0 + }, + { + "name": "14h00", + "state": 0 + }, + { + "name": "14h30", + "state": 0 + }, + { + "name": "15h00", + "state": 0 + }, + { + "name": "15h30", + "state": 0 + }, + { + "name": "16h00", + "state": 0 + }, + { + "name": "16h30", + "state": 0 + }, + { + "name": "17h00", + "state": 0 + }, + { + "name": "17h30", + "state": 0 + }, + { + "name": "18h00", + "state": 0 + }, + { + "name": "18h30", + "state": 0 + }, + { + "name": "19h00", + "state": 0 + }, + { + "name": "19h30", + "state": 0 + }, + { + "name": "20h00", + "state": 0 + }, + { + "name": "20h30", + "state": 0 + }, + { + "name": "21h00", + "state": 0 + }, + { + "name": "21h30", + "state": 0 + }, + { + "name": "22h00", + "state": 0 + }, + { + "name": "22h30", + "state": 0 + }, + { + "name": "23h00", + "state": 0 + }, + { + "name": "23h30", + "state": 0 + } + ], + "Sunday": [ + { + "name": "00h00", + "state": 0 + }, + { + "name": "00h30", + "state": 0 + }, + { + "name": "01h00", + "state": 0 + }, + { + "name": "01h30", + "state": 0 + }, + { + "name": "02h00", + "state": 0 + }, + { + "name": "02h30", + "state": 0 + }, + { + "name": "03h00", + "state": 0 + }, + { + "name": "03h30", + "state": 0 + }, + { + "name": "04h00", + "state": 0 + }, + { + "name": "04h30", + "state": 0 + }, + { + "name": "05h00", + "state": 0 + }, + { + "name": "05h30", + "state": 0 + }, + { + "name": "06h00", + "state": 0 + }, + { + "name": "06h30", + "state": 0 + }, + { + "name": "07h00", + "state": 0 + }, + { + "name": "07h30", + "state": 0 + }, + { + "name": "08h00", + "state": 0 + }, + { + "name": "08h30", + "state": 0 + }, + { + "name": "09h00", + "state": 0 + }, + { + "name": "09h30", + "state": 0 + }, + { + "name": "10h00", + "state": 0 + }, + { + "name": "10h30", + "state": 0 + }, + { + "name": "11h00", + "state": 0 + }, + { + "name": "11h30", + "state": 0 + }, + { + "name": "12h00", + "state": 0 + }, + { + "name": "12h30", + "state": 0 + }, + { + "name": "13h00", + "state": 0 + }, + { + "name": "13h30", + "state": 0 + }, + { + "name": "14h00", + "state": 0 + }, + { + "name": "14h30", + "state": 0 + }, + { + "name": "15h00", + "state": 0 + }, + { + "name": "15h30", + "state": 0 + }, + { + "name": "16h00", + "state": 0 + }, + { + "name": "16h30", + "state": 0 + }, + { + "name": "17h00", + "state": 0 + }, + { + "name": "17h30", + "state": 0 + }, + { + "name": "18h00", + "state": 0 + }, + { + "name": "18h30", + "state": 0 + }, + { + "name": "19h00", + "state": 0 + }, + { + "name": "19h30", + "state": 0 + }, + { + "name": "20h00", + "state": 0 + }, + { + "name": "20h30", + "state": 0 + }, + { + "name": "21h00", + "state": 0 + }, + { + "name": "21h30", + "state": 0 + }, + { + "name": "22h00", + "state": 0 + }, + { + "name": "22h30", + "state": 0 + }, + { + "name": "23h00", + "state": 0 + }, + { + "name": "23h30", + "state": 0 + } + ], + "Thursday": [ + { + "name": "00h00", + "state": 0 + }, + { + "name": "00h30", + "state": 0 + }, + { + "name": "01h00", + "state": 0 + }, + { + "name": "01h30", + "state": 0 + }, + { + "name": "02h00", + "state": 0 + }, + { + "name": "02h30", + "state": 0 + }, + { + "name": "03h00", + "state": 0 + }, + { + "name": "03h30", + "state": 0 + }, + { + "name": "04h00", + "state": 0 + }, + { + "name": "04h30", + "state": 0 + }, + { + "name": "05h00", + "state": 0 + }, + { + "name": "05h30", + "state": 0 + }, + { + "name": "06h00", + "state": 0 + }, + { + "name": "06h30", + "state": 0 + }, + { + "name": "07h00", + "state": 0 + }, + { + "name": "07h30", + "state": 0 + }, + { + "name": "08h00", + "state": 0 + }, + { + "name": "08h30", + "state": 0 + }, + { + "name": "09h00", + "state": 0 + }, + { + "name": "09h30", + "state": 0 + }, + { + "name": "10h00", + "state": 0 + }, + { + "name": "10h30", + "state": 0 + }, + { + "name": "11h00", + "state": 0 + }, + { + "name": "11h30", + "state": 0 + }, + { + "name": "12h00", + "state": 0 + }, + { + "name": "12h30", + "state": 0 + }, + { + "name": "13h00", + "state": 0 + }, + { + "name": "13h30", + "state": 0 + }, + { + "name": "14h00", + "state": 0 + }, + { + "name": "14h30", + "state": 0 + }, + { + "name": "15h00", + "state": 0 + }, + { + "name": "15h30", + "state": 0 + }, + { + "name": "16h00", + "state": 0 + }, + { + "name": "16h30", + "state": 0 + }, + { + "name": "17h00", + "state": 0 + }, + { + "name": "17h30", + "state": 0 + }, + { + "name": "18h00", + "state": 0 + }, + { + "name": "18h30", + "state": 0 + }, + { + "name": "19h00", + "state": 0 + }, + { + "name": "19h30", + "state": 0 + }, + { + "name": "20h00", + "state": 0 + }, + { + "name": "20h30", + "state": 0 + }, + { + "name": "21h00", + "state": 0 + }, + { + "name": "21h30", + "state": 0 + }, + { + "name": "22h00", + "state": 0 + }, + { + "name": "22h30", + "state": 0 + }, + { + "name": "23h00", + "state": 0 + }, + { + "name": "23h30", + "state": 0 + } + ], + "Tuesday": [ + { + "name": "00h00", + "state": 0 + }, + { + "name": "00h30", + "state": 0 + }, + { + "name": "01h00", + "state": 0 + }, + { + "name": "01h30", + "state": 0 + }, + { + "name": "02h00", + "state": 0 + }, + { + "name": "02h30", + "state": 0 + }, + { + "name": "03h00", + "state": 0 + }, + { + "name": "03h30", + "state": 0 + }, + { + "name": "04h00", + "state": 0 + }, + { + "name": "04h30", + "state": 0 + }, + { + "name": "05h00", + "state": 0 + }, + { + "name": "05h30", + "state": 0 + }, + { + "name": "06h00", + "state": 0 + }, + { + "name": "06h30", + "state": 0 + }, + { + "name": "07h00", + "state": 0 + }, + { + "name": "07h30", + "state": 0 + }, + { + "name": "08h00", + "state": 0 + }, + { + "name": "08h30", + "state": 0 + }, + { + "name": "09h00", + "state": 0 + }, + { + "name": "09h30", + "state": 0 + }, + { + "name": "10h00", + "state": 0 + }, + { + "name": "10h30", + "state": 0 + }, + { + "name": "11h00", + "state": 0 + }, + { + "name": "11h30", + "state": 0 + }, + { + "name": "12h00", + "state": 0 + }, + { + "name": "12h30", + "state": 0 + }, + { + "name": "13h00", + "state": 0 + }, + { + "name": "13h30", + "state": 0 + }, + { + "name": "14h00", + "state": 0 + }, + { + "name": "14h30", + "state": 0 + }, + { + "name": "15h00", + "state": 0 + }, + { + "name": "15h30", + "state": 0 + }, + { + "name": "16h00", + "state": 0 + }, + { + "name": "16h30", + "state": 0 + }, + { + "name": "17h00", + "state": 0 + }, + { + "name": "17h30", + "state": 0 + }, + { + "name": "18h00", + "state": 0 + }, + { + "name": "18h30", + "state": 0 + }, + { + "name": "19h00", + "state": 0 + }, + { + "name": "19h30", + "state": 0 + }, + { + "name": "20h00", + "state": 0 + }, + { + "name": "20h30", + "state": 0 + }, + { + "name": "21h00", + "state": 0 + }, + { + "name": "21h30", + "state": 0 + }, + { + "name": "22h00", + "state": 0 + }, + { + "name": "22h30", + "state": 0 + }, + { + "name": "23h00", + "state": 0 + }, + { + "name": "23h30", + "state": 0 + } + ], + "Wednesday": [ + { + "name": "00h00", + "state": 0 + }, + { + "name": "00h30", + "state": 0 + }, + { + "name": "01h00", + "state": 0 + }, + { + "name": "01h30", + "state": 0 + }, + { + "name": "02h00", + "state": 0 + }, + { + "name": "02h30", + "state": 0 + }, + { + "name": "03h00", + "state": 0 + }, + { + "name": "03h30", + "state": 0 + }, + { + "name": "04h00", + "state": 0 + }, + { + "name": "04h30", + "state": 0 + }, + { + "name": "05h00", + "state": 0 + }, + { + "name": "05h30", + "state": 0 + }, + { + "name": "06h00", + "state": 0 + }, + { + "name": "06h30", + "state": 0 + }, + { + "name": "07h00", + "state": 0 + }, + { + "name": "07h30", + "state": 0 + }, + { + "name": "08h00", + "state": 0 + }, + { + "name": "08h30", + "state": 0 + }, + { + "name": "09h00", + "state": 0 + }, + { + "name": "09h30", + "state": 0 + }, + { + "name": "10h00", + "state": 0 + }, + { + "name": "10h30", + "state": 0 + }, + { + "name": "11h00", + "state": 0 + }, + { + "name": "11h30", + "state": 0 + }, + { + "name": "12h00", + "state": 0 + }, + { + "name": "12h30", + "state": 0 + }, + { + "name": "13h00", + "state": 0 + }, + { + "name": "13h30", + "state": 0 + }, + { + "name": "14h00", + "state": 0 + }, + { + "name": "14h30", + "state": 0 + }, + { + "name": "15h00", + "state": 0 + }, + { + "name": "15h30", + "state": 0 + }, + { + "name": "16h00", + "state": 0 + }, + { + "name": "16h30", + "state": 0 + }, + { + "name": "17h00", + "state": 0 + }, + { + "name": "17h30", + "state": 0 + }, + { + "name": "18h00", + "state": 0 + }, + { + "name": "18h30", + "state": 0 + }, + { + "name": "19h00", + "state": 0 + }, + { + "name": "19h30", + "state": 0 + }, + { + "name": "20h00", + "state": 0 + }, + { + "name": "20h30", + "state": 0 + }, + { + "name": "21h00", + "state": 0 + }, + { + "name": "21h30", + "state": 0 + }, + { + "name": "22h00", + "state": 0 + }, + { + "name": "22h30", + "state": 0 + }, + { + "name": "23h00", + "state": 0 + }, + { + "name": "23h30", + "state": 0 + } + ] + }, + "INFOS": { + "control": { + "call_ready": false, + "operator": "", + "service_provider": "", + "signal_dbm": "-71", + "signal_qos": "Excellent", + "sim_inserted": false + }, + "manufacturer": { + "hardware_rev": "", + "identification": "", + "model": "", + "serial_number": "" + } + }, + "NUM_AUTORISE": "", + "OPERATION": "Manuel OFF", + "PIN_ACTIF": false, + "TONE_DURATION": 2, + "utilisateur": { + "id": "admin", + "password": "87f4804843b82c3f3597e491bcfafe1b251bca52685313825dabbbfa79ec7c10" + } +} diff --git a/misc/db.json.schema b/misc/db.json.schema new file mode 100644 index 0000000..3f846de --- /dev/null +++ b/misc/db.json.schema @@ -0,0 +1,406 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://git.nas.benserv.fr/vincent/Kine-backend/src/branch/master/db.json", + "type": "object", + "title": "KineIntercom database", + "description": "This document records the parameters of KineIntercom process", + "required": [ + "CODE_PIN", + "DTMF_CODE", + "DTMF_DURATION", + "HORAIRES", + "INFOS", + "NUM_AUTORISE", + "OPERATION", + "PIN_ACTIF", + "TONE_DURATION", + "utilisateur" + ], + "properties": { + "CODE_PIN": { + "type": "string", + "title": "Le code pin de la carte SIM", + "examples": [ + "1234" + ] + }, + "DTMF_CODE": { + "type": "string", + "title": "Le code DTMF a envoyer par le module GSM", + "examples": [ + "*" + ] + }, + "DTMF_DURATION": { + "type": "integer", + "title": "La duree du code DTMF a envoyer par le module GSM", + "examples": [ + 10 + ] + }, + "HORAIRES": { + "type": "object", + "title": "Les horaires d'ouverture et de fermeture du module GSM", + "required": [ + "Friday", + "Monday", + "Saturday", + "Sunday", + "Thursday", + "Tuesday", + "Wednesday" + ], + "properties": { + "Friday": { + "type": "array", + "title": "Les horaires pour le jour de la semaine: Vendredi", + "items": { + "type": "object", + "title": "A Schema", + "required": [ + "name", + "state" + ], + "properties": { + "name": { + "type": "string", + "title": "Les tranches horaires par pas de 1/2 heure" + }, + "state": { + "type": "integer", + "title": "L'etat d'ouverture (1) ou fermeture(0) du module GSM", + "examples": [ + 0, + 1 + ] + } + } + } + }, + "Monday": { + "type": "array", + "title": "Les horaires pour le jour de la semaine: Lundi", + "items": { + "type": "object", + "title": "A Schema", + "required": [ + "name", + "state" + ], + "properties": { + "name": { + "type": "string", + "title": "Les tranches horaires par pas de 1/2 heure" + }, + "state": { + "type": "integer", + "title": "L'etat d'ouverture (1) ou fermeture(0) du module GSM", + "examples": [ + 0, + 1 + ] + } + } + } + }, + "Saturday": { + "type": "array", + "title": "Les horaires pour le jour de la semaine: Samedi", + "items": { + "type": "object", + "title": "A Schema", + "required": [ + "name", + "state" + ], + "properties": { + "name": { + "type": "string", + "title": "Les tranches horaires par pas de 1/2 heure" + }, + "state": { + "type": "integer", + "title": "L'etat d'ouverture (1) ou fermeture(0) du module GSM", + "examples": [ + 0, + 1 + ] + } + } + } + }, + "Sunday": { + "type": "array", + "title": "Les horaires pour le jour de la semaine: Dimanche", + "items": { + "type": "object", + "title": "A Schema", + "required": [ + "name", + "state" + ], + "properties": { + "name": { + "type": "string", + "title": "Les tranches horaires par pas de 1/2 heure" + }, + "state": { + "type": "integer", + "title": "L'etat d'ouverture (1) ou fermeture(0) du module GSM", + "examples": [ + 0, + 1 + ] + } + } + } + }, + "Thursday": { + "type": "array", + "title": "Les horaires pour le jour de la semaine: Jeudi", + "items": { + "type": "object", + "title": "A Schema", + "required": [ + "name", + "state" + ], + "properties": { + "name": { + "type": "string", + "title": "Les tranches horaires par pas de 1/2 heure" + }, + "state": { + "type": "integer", + "title": "L'etat d'ouverture (1) ou fermeture(0) du module GSM", + "examples": [ + 0, + 1 + ] + } + } + } + }, + "Tuesday": { + "type": "array", + "title": "Les horaires pour le jour de la semaine: Mardi", + "items": { + "type": "object", + "title": "A Schema", + "required": [ + "name", + "state" + ], + "properties": { + "name": { + "type": "string", + "title": "Les tranches horaires par pas de 1/2 heure" + }, + "state": { + "type": "integer", + "title": "L'etat d'ouverture (1) ou fermeture(0) du module GSM", + "examples": [ + 0, + 1 + ] + } + } + } + }, + "Wednesday": { + "type": "array", + "title": "Les horaires pour le jour de la semaine: Mercredi", + "items": { + "type": "object", + "title": "A Schema", + "required": [ + "name", + "state" + ], + "properties": { + "name": { + "type": "string", + "title": "Les tranches horaires par pas de 1/2 heure" + }, + "state": { + "type": "integer", + "title": "L'etat d'ouverture (1) ou fermeture(0) du module GSM", + "examples": [ + 0, + 1 + ] + } + } + } + } + } + }, + "INFOS": { + "type": "object", + "title": "Les infos du module GSM", + "required": [ + "control", + "manufacturer" + ], + "properties": { + "control": { + "type": "object", + "title": "The control Schema", + "required": [ + "call_ready", + "operator", + "service_provider", + "signal_dbm", + "signal_qos", + "sim_inserted" + ], + "properties": { + "call_ready": { + "type": "boolean", + "default": false, + "title": "The call_ready Schema", + "examples": [ + true, + false + ] + }, + "operator": { + "type": "string", + "default": "", + "title": "The operator Schema", + "examples": [ + "SFR" + ] + }, + "service_provider": { + "type": "string", + "default": "", + "title": "The service_provider Schema", + "examples": [ + "La poste mobile" + ] + }, + "signal_dbm": { + "type": "string", + "default": "", + "title": "The signal_dbm Schema", + "examples": [ + "-75" + ] + }, + "signal_qos": { + "type": "string", + "default": "", + "title": "The signal_qos Schema", + "examples": [ + "excellent" + ] + }, + "sim_inserted": { + "type": "boolean", + "default": false, + "title": "The sim_inserted Schema", + "examples": [ + true, + false + ] + } + } + }, + "manufacturer": { + "type": "object", + "title": "The manufacturer Schema", + "required": [ + "hardware_rev", + "identification", + "model", + "serial_number" + ], + "properties": { + "hardware_rev": { + "type": "string", + "title": "The hardware_rev Schema", + "examples": [ + "1418B02SIM868M32_BT_EAT" + ] + }, + "identification": { + "type": "string", + "title": "The identification Schema", + "examples": [ + "SIMCOM_Ltd" + ] + }, + "model": { + "type": "string", + "title": "The model Schema", + "examples": [ + "SIMCOM_SIM868" + ] + }, + "serial_number": { + "type": "string", + "title": "The serial_number Schema", + "examples": [ + "864866057705260" + ] + } + } + } + } + }, + "NUM_AUTORISE": { + "type": "string", + "title": "The NUM_AUTORISE Schema", + "examples": [ + "670100036" + ] + }, + "OPERATION": { + "type": "string", + "title": "The OPERATION Schema", + "examples": [ + "Horaires" + ] + }, + "PIN_ACTIF": { + "type": "boolean", + "title": "The PIN_ACTIF Schema", + "examples": [ + true, + false + ] + }, + "TONE_DURATION": { + "type": "integer", + "title": "The TONE_DURATION Schema", + "examples": [ + 2 + ] + }, + "utilisateur": { + "type": "object", + "title": "L'utilisateur du configurateur", + "required": [ + "id", + "password" + ], + "properties": { + "id": { + "type": "string", + "title": "The id Schema", + "examples": [ + "admin" + ] + }, + "password": { + "type": "string", + "title": "The password Schema", + "examples": [ + "9ac564e9a29c952a3ddeffd8635adb0c252dbd1d58f3efde265e028f7f808aa9" + ] + } + } + } + } +} diff --git a/misc/kineintercom.service b/misc/kineintercom.service new file mode 100644 index 0000000..408734c --- /dev/null +++ b/misc/kineintercom.service @@ -0,0 +1,12 @@ +[Unit] +Description=Démarrage du processus KineIntercom + +[Service] +Type=simple +User=pi +Group=pi +ExecStart=/usr/bin/python3 /usr/local/lib/python3.9/dist-packages/kineintercom/src/intercom.py + +[Install] +WantedBy=multi-user.target + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3652236 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +RPi.GPIO==0.7.0 +jsonschema==4.17.0 +pyserial==3.5 +APScheduler==3.9.1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c882598 --- /dev/null +++ b/setup.py @@ -0,0 +1,38 @@ +import io, os +from setuptools import find_packages, setup + +def read(*paths, **kwargs): + """Read the contents of a text file safely. + >>> read("project_name", "VERSION") + '0.1.0' + >>> read("README.md") + ... + """ + + content = "" + with io.open( + os.path.join(os.path.dirname(__file__), *paths), + encoding=kwargs.get("encoding", "utf8"), + ) as open_file: + content = open_file.read().strip() + return content + +def read_requirements(path): + ret = [] + with open(path, "r") as f: + ret = f.read().splitlines() + return ret + +setup( + name='kineintercom', + version=read("src", "VERSION"), + author='vincent.benoit', + author_email='vincent.benoit@benserv.fr', + description='Processus d\'envoi de code DTMF via le module GSM', + long_description=read("README.md"), + long_description_content_type="text/markdown", + packages=find_packages(), + include_package_data=True, + zip_safe=False, + install_requires=read_requirements("requirements.txt") +) diff --git a/src/KineIntercom.json b/src/KineIntercom.json deleted file mode 100644 index 749960a..0000000 --- a/src/KineIntercom.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "CODE_PIN": 1234, - "NUM_AUTORISE": "0607297154", - "DTMF_CODE": "*", - "DTMF_DURATION": 1, - "HORAIRES": { - "Monday":{ - "00h00":0,"00h30":0,"01h00":0,"01h30":0,"02h00":0,"02h30":0,"03h00":0, - "03h30":0,"04h00":0,"04h30":0,"05h00":0,"05h30":0,"06h00":1,"06h30":1, - "07h00":1,"07h30":1,"08h00":1,"08h30":1,"09h00":1,"09h30":1,"10h00":1, - "10h30":1,"11h00":1,"11h30":1,"12h00":1,"12h30":1,"13h00":1,"13h30":1, - "14h00":1,"14h30":1,"15h00":1,"15h30":1,"16h00":1,"16h30":1,"17h00":1, - "17h30":1,"18h00":1,"18h30":1,"19h00":1,"19h30":1,"20h00":0,"20h30":0, - "21h00":0,"21h30":0,"22h00":0,"22h30":0,"23h00":0,"23h30":0 - }, - "Tuesday": { - "00h00":0,"00h30":0,"01h00":0,"01h30":0,"02h00":0,"02h30":0,"03h00":0, - "03h30":0,"04h00":0,"04h30":0,"05h00":0,"05h30":0,"06h00":1,"06h30":1, - "07h00":1,"07h30":1,"08h00":1,"08h30":1,"09h00":1,"09h30":1,"10h00":1, - "10h30":1,"11h00":1,"11h30":1,"12h00":1,"12h30":1,"13h00":1,"13h30":1, - "14h00":1,"14h30":1,"15h00":1,"15h30":1,"16h00":1,"16h30":1,"17h00":1, - "17h30":1,"18h00":1,"18h30":1,"19h00":1,"19h30":1,"20h00":0,"20h30":0, - "21h00":0,"21h30":0,"22h00":0,"22h30":0,"23h00":0,"23h30":0 - }, - "Wednesday": { - "00h00":0,"00h30":0,"01h00":0,"01h30":0,"02h00":0,"02h30":0,"03h00":0, - "03h30":0,"04h00":0,"04h30":0,"05h00":0,"05h30":0,"06h00":1,"06h30":1, - "07h00":1,"07h30":1,"08h00":1,"08h30":1,"09h00":1,"09h30":1,"10h00":1, - "10h30":1,"11h00":1,"11h30":1,"12h00":1,"12h30":1,"13h00":1,"13h30":1, - "14h00":1,"14h30":1,"15h00":1,"15h30":1,"16h00":1,"16h30":1,"17h00":1, - "17h30":1,"18h00":1,"18h30":1,"19h00":1,"19h30":1,"20h00":0,"20h30":0, - "21h00":0,"21h30":0,"22h00":0,"22h30":0,"23h00":0,"23h30":0 - }, - "Thursday": { - "00h00":0,"00h30":0,"01h00":0,"01h30":0,"02h00":0,"02h30":0,"03h00":0, - "03h30":0,"04h00":0,"04h30":0,"05h00":0,"05h30":0,"06h00":1,"06h30":1, - "07h00":1,"07h30":1,"08h00":1,"08h30":1,"09h00":1,"09h30":1,"10h00":1, - "10h30":1,"11h00":1,"11h30":1,"12h00":1,"12h30":1,"13h00":1,"13h30":1, - "14h00":1,"14h30":1,"15h00":1,"15h30":1,"16h00":1,"16h30":1,"17h00":1, - "17h30":1,"18h00":1,"18h30":1,"19h00":1,"19h30":1,"20h00":0,"20h30":0, - "21h00":0,"21h30":0,"22h00":0,"22h30":0,"23h00":0,"23h30":0 - }, - "Friday": { - "00h00":0,"00h30":0,"01h00":0,"01h30":0,"02h00":0,"02h30":0,"03h00":0, - "03h30":0,"04h00":0,"04h30":0,"05h00":0,"05h30":0,"06h00":1,"06h30":1, - "07h00":1,"07h30":1,"08h00":1,"08h30":1,"09h00":1,"09h30":1,"10h00":1, - "10h30":1,"11h00":1,"11h30":1,"12h00":1,"12h30":1,"13h00":1,"13h30":1, - "14h00":1,"14h30":1,"15h00":1,"15h30":1,"16h00":1,"16h30":1,"17h00":1, - "17h30":1,"18h00":1,"18h30":1,"19h00":1,"19h30":1,"20h00":0,"20h30":0, - "21h00":0,"21h30":0,"22h00":0,"22h30":0,"23h00":0,"23h30":0 - }, - "Saturday": { - "00h00":0,"00h30":0,"01h00":0,"01h30":0,"02h00":0,"02h30":0,"03h00":0, - "03h30":0,"04h00":0,"04h30":0,"05h00":0,"05h30":0,"06h00":0,"06h30":0, - "07h00":0,"07h30":0,"08h00":0,"08h30":0,"09h00":0,"09h30":0,"10h00":0, - "10h30":0,"11h00":0,"11h30":0,"12h00":0,"12h30":0,"13h00":0,"13h30":0, - "14h00":0,"14h30":0,"15h00":0,"15h30":0,"16h00":0,"16h30":0,"17h00":0, - "17h30":0,"18h00":0,"18h30":0,"19h00":0,"19h30":0,"20h00":0,"20h30":0, - "21h00":0,"21h30":0,"22h00":0,"22h30":0,"23h00":0,"23h30":0 - }, - "Sunday": { - "00h00":0,"00h30":0,"01h00":0,"01h30":0,"02h00":0,"02h30":0,"03h00":0, - "03h30":0,"04h00":0,"04h30":0,"05h00":0,"05h30":0,"06h00":0,"06h30":0, - "07h00":0,"07h30":0,"08h00":0,"08h30":0,"09h00":0,"09h30":0,"10h00":0, - "10h30":0,"11h00":0,"11h30":0,"12h00":0,"12h30":0,"13h00":0,"13h30":0, - "14h00":0,"14h30":0,"15h00":0,"15h30":0,"16h00":0,"16h30":0,"17h00":0, - "17h30":0,"18h00":0,"18h30":0,"19h00":0,"19h30":0,"20h00":0,"20h30":0, - "21h00":0,"21h30":0,"22h00":0,"22h30":0,"23h00":0,"23h30":0 - } - } -} diff --git a/src/VERSION b/src/VERSION new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/src/VERSION @@ -0,0 +1 @@ +1.0.0 diff --git a/src/intercom.py b/src/intercom.py index 72a440c..25e8128 100644 --- a/src/intercom.py +++ b/src/intercom.py @@ -19,7 +19,6 @@ import json import jsonschema import socket import shutil -from signal import signal, SIGINT from threading import Thread from apscheduler.schedulers.background import BackgroundScheduler @@ -51,7 +50,7 @@ def validate_json(json_data={}, logger=None): except FileNotFoundError as e: logger.error("Impossible d'ouvrir le fichier de validation ({})".format(e)) ret = False - + try: jsonschema.validate(instance=json_data, schema=schema) except jsonschema.exceptions.ValidationError as e: @@ -97,7 +96,7 @@ def get_conf(logger=None): logger.error("Impossible de charger les données de configuration ({})".format(e)) except FileNotFoundError as e: logger.error("Impossible d'ouvrir le fichier de configuation ({})".format(e)) - + return config def send_at_cmd(cmd='', timeout=0.0, serObj=None, logger=None): @@ -141,7 +140,7 @@ def send_at_cmd(cmd='', timeout=0.0, serObj=None, logger=None): out = '' outlst = [] while serObj.in_waiting > 0: - # remove \r and \n chars from out string + # remove \r and \n chars from out string out += serObj.read_until().decode('utf-8', 'replace').replace('\r','').replace('\n','') if out != '': outlst.append(out) @@ -239,10 +238,10 @@ def init_gsm_com(serObj=None, config={}, logger=None): ''' Init GSM Communication source : SIM800_Series_AT_command Manual_v1.09 AT : test command - ATE1 : + ATE1 : AT+CMEE=2 : - AT+CLTS=1 : - AT+CMGF=1 : Set the format of messages to Text mode + AT+CLTS=1 : + AT+CMGF=1 : Set the format of messages to Text mode AT+CLIP=1 : The calling line identifty (CLI) of calling party when receiving a mobile terminated call AT+VTD=1 : Tone Duration (in 1/10 seconds) @@ -368,7 +367,7 @@ def info_gsm_com(serObj=None, config={}, logger=None): else: logger.debug('cmd: {} - rsp: {}'.format(cmd, rsp)) if cmd['cmd'] == 'AT+CGMI': - # Request Manufacturer Identification + # Request Manufacturer Identification config['INFOS'][cmd['obj']][cmd['item']] = rsp[1] elif cmd['cmd'] == 'AT+CGMM': # Request Model Identification @@ -446,7 +445,7 @@ SIGNAL = [{"val":2, "dbm":"-109", 'condition':'Marginal'}, def verify_caller(buf="", num="", logger=None): ''' Verify phone number of caller example : +CLIP: "0607297154",129,"",0,"",0 - + :param buf: Serial input buffer @@ -475,7 +474,7 @@ def verify_caller(buf="", num="", logger=None): if not phone_number.endswith(num): logger.warning("phone number not match ! {}/{}".format(phone_number, num)) return False, phone_number - return True, phone_number + return True, phone_number def listener(sock, logger): ''' Thread socket listener @@ -521,7 +520,7 @@ def listener(sock, logger): continue if not data: break - + logger.debug("Fin du serveur de communication") return @@ -709,7 +708,7 @@ def main(): logger = log.getLogger("Intercom") logger.setLevel(log.DEBUG) fl = log.StreamHandler() - hl = log.FileHandler(os.path.join('/var/log/KineIntercom','Intercom.log')) + hl = log.FileHandler(os.path.join('/var/log/kineintercom','Intercom.log')) fl.setLevel(log.DEBUG) hl.setLevel(log.INFO) formatter = log.Formatter('%(asctime)s - %(funcName)s - %(levelname)s - %(message)s') @@ -723,9 +722,9 @@ def main(): global FLAG_CONF_UPDATE global FLAG_HORAIRE_UPDATE global FLAG_TH_CLOSE - + # Configuration loader - config = get_conf(logger) + config = get_conf(logger) if config is None: logger.error("Impossible de charger la configuration") sys.exit(1) @@ -737,7 +736,7 @@ def main(): sys.exit(1) # Serial configuration - ser = serial.Serial('/dev/ttyAMA0', + ser = serial.Serial('/dev/ttyAMA0', baudrate=115200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, @@ -746,7 +745,7 @@ def main(): xonxoff=False, rtscts=False, dsrdtr=False) - + # Test si le port série est ouvert if ser.isOpen(): logger.info("Le port série avec le module GSM est ouvert") @@ -838,7 +837,7 @@ def main(): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) # Bind the socket to the port sock.bind(server_addr) - sock.settimeout(1) # Timeout for accept + sock.settimeout(1) # Timeout for accept # Listen for incoming connections sock.listen(1) thread = Thread(target=listener, args=(sock, logger,)) @@ -847,10 +846,10 @@ def main(): # Scheduler opened hours sched = BackgroundScheduler(daemon=True) - sched.add_job(func=cron_verify_hours, - args=(config['OPERATION'], config['HORAIRES'], logger), - trigger='cron', - minute='*', + sched.add_job(func=cron_verify_hours, + args=(config['OPERATION'], config['HORAIRES'], logger), + trigger='cron', + minute='*', id="job_id") sched.start() @@ -870,10 +869,10 @@ def main(): logger.info("Restart scheduler ...") # Stop job scheduler to restart it sched.remove_job('job_id') - sched.add_job(func=cron_verify_hours, - args=(config['OPERATION'], config['HORAIRES'], logger), - trigger='cron', - minute='*', + sched.add_job(func=cron_verify_hours, + args=(config['OPERATION'], config['HORAIRES'], logger), + trigger='cron', + minute='*', id="job_id") FLAG_HORAIRE_UPDATE = False FLAG_CONF_UPDATE = False @@ -896,7 +895,7 @@ def main(): # While the number of bytes in the input buffer > 0 if ser.in_waiting > 0: - # remove \r and \n chars from out string + # remove \r and \n chars from out string out += ser.read_until().decode('utf-8').replace('\r','').replace('\n','') if len(out) > 0 : logger.debug("out: {}".format(out)) diff --git a/src/pwrkey.py b/src/pwrkey.py deleted file mode 100644 index 9a7dcd6..0000000 --- a/src/pwrkey.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python3 -# -*- encoding: utf-8 -*- - -# @author: benoit.vince84@free.fr -# @date: Septembre 2022 -# @brief: Programme Pwrkey pour le GNSS HAT - -################################################################### -# Importation de modules externes # - -import sys, os, re -import serial -import RPi.GPIO as GPIO -import time -import logging as log -import time -from datetime import datetime, date -import calendar -import json -import socket - -################################################################### -# Class et Methods # - -def get_conf(logger=None): - ''' Get configuration - - :return dict: - Configuration dictionnary - ''' - config = None - try: - with open(os.path.join("/home/pi/KineIntercom/src", "KineIntercom.json"), 'r') as f: - try: - config = json.load(f) - except json.decoder.JSONDecodeError as e: - logger.error("Impossible de charger les données de configuration ({})".format(e)) - except FileNotFoundError as e: - logger.error("Impossible d'ouvrir le fichier de configuation ({})".format(e)) - - return config - -def verify_open_hours(conf=None, log=None): - ''' Verify if GSM HAT must be opened with conf hours - - :param conf: - configuration object - - :param log: - logger object - - :return bool: - True if authorized, False otherwise - ''' - flag = False - my_date = date.today() - day = calendar.day_name[my_date.weekday()] - now = datetime.now() - for k,v in conf[day].items(): - time_conf = int(k.split('h')[0])*60 + int(k.split('h')[1]) - current_time = now.hour*60 + now.minute - if current_time >= time_conf: - if v == 1: - flag = True - elif v == 0: - flag = False - log.debug('Jour: {} - Temps courant: {} - Ouverture: {}'.format(day, now.strftime('%Hh%M'), flag)) - return flag - -def init_module(): - ''' initialisation of GNSS/GPS/GSM HAT Module - ''' - GPIO.setmode(GPIO.BOARD) - GPIO.setup(7, GPIO.OUT) - return - -def setup_module(): - ''' Setup module (Set/Reset) - ''' - while True: - GPIO.output(7, GPIO.LOW) - time.sleep(2) - GPIO.output(7, GPIO.HIGH) - break - GPIO.cleanup() - -def main(): - ''' main function - ''' - logger = log.getLogger("pwrkey") - logger.setLevel(log.DEBUG) - fl = log.StreamHandler() - fl.setLevel(log.DEBUG) - formatter = log.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') - fl.setFormatter(formatter) - logger.addHandler(fl) - - # get config dictionnary - config = get_conf(logger) - if not config: - exit(1) - - # create a UDS socket - sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - # Connect the socket to the port where the server is listening - server_addr = '/tmp/uds_socket' - try: - sock.connect(server_addr) - except socket.error as e: - logger.error("Erreur de connexion avec le serveur: {}".format(e)) - sys.exit(1) - - opened = verify_open_hours(conf=config['HORAIRES'], log=logger) - sock.sendall(str(opened)) - - sock.close() - #init_module() - #setup_module() - -if __name__ == '__main__': - main() diff --git a/template/changelog b/template/changelog new file mode 100644 index 0000000..eac6b33 --- /dev/null +++ b/template/changelog @@ -0,0 +1,5 @@ +#PACKAGE# (#VERSION#-1) stable; urgency=medium + + * Initial release + + -- #USERNAME# <#EMAIL#> #DATE# diff --git a/template/compat b/template/compat new file mode 100644 index 0000000..b4de394 --- /dev/null +++ b/template/compat @@ -0,0 +1 @@ +11 diff --git a/template/control b/template/control new file mode 100644 index 0000000..5daaca2 --- /dev/null +++ b/template/control @@ -0,0 +1,12 @@ +Source: #PACKAGE# +Section: misc +Priority: optional +Maintainer: #USERNAME# <#EMAIL#> +Build-Depends: #BUILD_DEPS# +Standards-Version: #POLICY# +Homepage: https://git.nas.benserv.fr/vincent/KineIntercom + +Package: #PACKAGE# +Architecture: all +Depends: ${misc:Depends} +Description: Installation des fichiers nécessaires au fonctionnement du processus KineIntercom diff --git a/template/install b/template/install new file mode 100644 index 0000000..d15ce9b --- /dev/null +++ b/template/install @@ -0,0 +1,3 @@ +db.json.schema /usr/share/kineintercom/ +database_origin.json /usr/share/kineintercom/ +kineintercom.service /lib/systemd/system/ diff --git a/template/kineintercommisc.postinst b/template/kineintercommisc.postinst new file mode 100644 index 0000000..8c0077a --- /dev/null +++ b/template/kineintercommisc.postinst @@ -0,0 +1,27 @@ +#!/bin/sh +# postinst script for sclesignrestfulmisc +# +# see: dh_installdeb(1) + +set -e +user="root" + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +userpi="pi" +dirname="kineintercom" + +# create conf directory +/usr/bin/mkdir -p /etc/$dirname +/usr/bin/chown -R $user:$userpi /etc/$dirname +/usr/bin/chmod -R 770 /etc/$dirname + +# create log directory +/usr/bin/mkdir -p /var/log/$dirname +/usr/bin/chown -R $user:$userpi /var/log/$dirname + +# Restart service +/usr/bin/systemctl restart kineintercom.service diff --git a/template/rules b/template/rules new file mode 100755 index 0000000..7dab8e0 --- /dev/null +++ b/template/rules @@ -0,0 +1,12 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + +#RULES_START_TEXT# +%: + dh $@#DH_ADDON# + +override_dh_auto_install: + +#RULES_END_TEXT#