diff --git a/README.md b/README.md index 49331be..4f5e561 100644 --- a/README.md +++ b/README.md @@ -1,182 +1,16 @@ # KineIntercom -Programme Python pour l'intercom des Kines +Programme Python central pour l'intercom des Kines -## Commandes AT nécessaires : +![architecture](/assets/images/architecture.png) -#### AT+CGMI Request Manufacturer Identification -``` -AT+CGMI -SIMCOM_Ltd +### Dépendances python nécessaires -OK -``` + * [RPi.GPIO](https://pypi.org/project/RPi.GPIO/) : Allumer ou éteindre le module GNSS HAT + * [jsonschema](https://pypi.org/project/jsonschema/) : Confirmer la base de données écrite en JSON + * [pyserial](https://pypi.org/project/pyserial/) : Communiquer avec le module GNSS HAT + * [APScheduler](https://pypi.org/project/APScheduler/) : Gerer le programmateur du module GNSS HAT -#### AT+CGMM: AT+CGMM Request Model Identification -``` -AT+CGMM -SIMCOM_SIM868 - -OK -``` - -#### AT+CGMR: Request TA Revision Identification of Software Release -``` -AT+CGMR -Revision:1418B02SIM868M32_BT_EAT - -OK -``` - -#### AT+COPS Operator Selection -+COPS: [,, ] -OK - - Refer to [27.007] -operator in format as per - - - 0. Automatic mode; field is ignored - 1. Manual ( field shall be present, and -optionally) - 2. manual deregister from network - 3. set only (for read Command +COPS?) - not shown in Read Command response - 4. Manual/automatic ( field shall be present); if manual selection fails, automatic mode (=0) is entered - - - 0. Long format alphanumeric - 1. Short format alphanumeric - 2. Numeric ; GSM Location Area Identification - -``` -AT+COPS? -+COPS: 0,0,"SFR" - -OK -``` - -#### AT+CSQ Signal Quality Report -+CSQ: , - - - * 0 -115 dBm or less - * 1 -111 dBm - * 2...30 -110... -54 dBm - * 31 -52 dBm or greater - * 99 not known or not detectable - (in percent): - * 0...7 As RXQUAL values in the table in GSM 05.08 [20] subclause 7.2.4 - * 99 Not known or not detectable - - -Value RSSI dBm Condition -2 -109 Marginal -3 -107 Marginal -4 -105 Marginal -5 -103 Marginal -6 -101 Marginal -7 -99 Marginal -8 -97 Marginal -9 -95 Marginal -10 -93 OK -11 -91 OK -12 -89 OK -13 -87 OK -14 -85 OK -15 -83 Good -16 -81 Good -17 -79 Good -18 -77 Good -19 -75 Good -20 -73 Excellent -21 -71 Excellent -22 -69 Excellent -23 -67 Excellent -24 -65 Excellent -25 -63 Excellent -26 -61 Excellent -27 -59 Excellent -28 -57 Excellent -29 -55 Excellent -30 -53 Excellent - -``` -AT+CSQ -+CSQ: 19,0 - -OK -``` - -#### AT+CREG Network Registration -+CREG: , - - - * 0 Disable network registration unsolicited result code - * 1 Enable network registration unsolicited result code +CREG: - * 2 Enable network registration unsolicited result code with location information +CREG: [,,] - - - * 0 Not registered, MT is not currently searching a new operator to register to - * 1 Registered, home network - * 2 Not registered, but MT is currently searching a new operator to register to - * 3 Registration denied - * 4 Unknown - * 5 Registered, roaming -``` -AT+CREG? -+CREG: 1,1 - -OK -``` - -#### AT+CSMINS SIM Inserted Status Reporting -+CSMINS: , - A numeric parameter to show an unsolicited event code indicating whether the SIM has been inserted or removed. - * 0 Disable - * 1 Enable - A numeric parameter which indicates whether SIMcard has been inserted. - * 0 Not inserted - * 1 Inserted - -``` -AT+CSMINS? -+CSMINS: 0,1 - -OK -``` - -#### AT+CSPN Get Service Provider Name from SIM -+CSPN: , - - String type(string should be included in quotation marks); service provider name on SIM - - * 0 Not display PLMN. Already registered on PLMN - * 1 Display PLMN - -``` -AT+CSPN? -+CSPN: "La Poste Mobile",0 - -OK -``` - -#### AT+CGSN Request Product Serial Number Identification (Identical with +GSN) -``` -AT+CGSN -864866057705260 - -OK -``` - -#### AT+CCALR Call Ready Query - A numeric parameter which indicates whether the module is ready for phone call. - * 0 Module is not ready for phone call - * 1 Module is ready for phone call - -``` -AT+CCALR? -+CCALR: 1 - -OK -``` +### Yocto +La recette de ce processus est présent dans le [meta-kineintercom](https://git.nas.benserv.fr/vincent/meta-kineintercom) diff --git a/assets/images/architecture.png b/assets/images/architecture.png new file mode 100644 index 0000000..6ed41e6 Binary files /dev/null and b/assets/images/architecture.png differ diff --git a/kineintercom/intercom.py b/kineintercom/intercom.py index 405ea91..0ec1cbb 100644 --- a/kineintercom/intercom.py +++ b/kineintercom/intercom.py @@ -852,18 +852,23 @@ def main(): try: ser.flushInput() #flush input buffer, discarding all its contents ser.flushOutput() #flush output buffer, aborting current output - # send AT command to test the connection - ret, _ = send_at_cmd(cmd='AT', timeout=0.5, serObj=ser, logger=logger) - if ret == 2: - logger.error("Erreur d'envoie de la commande AT") - ser.close() - sys.exit(1) - elif ret == 1: - logger.warning("Pas de réponse du module GSM HAT") - GSM_MODULE_STATE = False - else: - logger.info("Module GSM HAT allumé ...") - GSM_MODULE_STATE = True + idx = 0 + while idx < 5: + # send AT command to test the connection + ret, _ = send_at_cmd(cmd='AT', timeout=0.5, serObj=ser, logger=logger) + if ret == 2: + logger.error("Erreur d'envoie de la commande AT") + ser.close() + sys.exit(1) + elif ret == 1: + logger.warning("Pas de réponse du module GSM HAT ({}/5)".format(idx + 1)) + GSM_MODULE_STATE = False + else: + logger.info("Module GSM HAT allumé ...") + GSM_MODULE_STATE = True + break + idx += 1 + time.sleep(1) except Exception as e: logger.error("Erreur de com série: {}".format(e)) ser.close()