Skip to main content

Parámetros servidor MQTT

Parámetros
-c,--conf_file Ruta al archivo de configuración
--filter_confRuta al archivo del filtro de mensajes
-v,--verbosity Activar modo debug
Archivo de configuración (--conf)
[DEFAULT]
;;topic
topic = < Topic al que se suscribirse para recibir mensajes. >

;; connection
host = < Host del servidor en el que se escucharan los mensajes >
port = < Puerto del servidor en el que se escucharan los mensajes >
;; protocol supports:  tcp, websockets, unix
; protocol = < Tipo de protocolo. Aceptados : tcp, websockets, unix
; user = < Usuario >
; password = < Contraseña >
; ssl = 0 < Activar cifrado ssl >
; trust_ssl = < Verificacion de certificado >

;; Database
; dblocation = < Localización del fichero de base de datos >
; dbname = < Nombre del fichero de base de datos >
; data_cleaning_interval = 300  < Periodo de restablecimiento de los datos >
; data_cleaning_period = < Periodo de antigüedad de los datos a restablecer>  

;; Logs
;; log_name = < Nombre del fichero de logs >  
; log_location = < Ruta del fichero de logs >
; log_level = < Nivel del log >          
; max_log_bytes = < Tamaño máximo de log >          
; log_rotation_count = < Número de ficheros de log que se almacenan despus de rotar, por defecto: 3 >
Ejemplo
[DEFAULT]

;;topic
topic = testtopic/#

;; connection
host = test.mosquitto.org
port = 1883
;; protocol supports:  tcp, websockets, unix
; protocol = websockets 
; user = ro
; password = readonly
; ssl = 0
; trust_ssl = 1

;; Database
dblocation = /opt/pandora/pandora_iot_server/db
dbname = pandora_iot.db
; data_cleaning_interval = 300  
; data_cleaning_period = 86400  

;; Logs
log_name = pandora_iot.log   
log_location = /var/log/pandora/
; log_level = debug              
; max_log_bytes = 50_000_000         
; log_rotation_count = 3
Archivo para filtrar los mensajes (--filter_conf)
#=======================================================================  
# Filter Configuration  
#=======================================================================  
filter_begin: < Marks the beginning of a filter configuration. Everything until filter_end belongs to the same filter. Mandatory. >  
filter_module_name: < Name assigned to the module that generates the filter. Mandatory. >  
filter_module_type: < Type of module that generates the filter. Mandatory. >  
filter_topic: < Regular expression or exact text that must match the message topic for the filter to apply. Optional. By default, it matches any topic. >  
filter_topic_exact_match: < Defines whether filter_topic is treated as a regular expression (0) or exact text (1). Optional. Default is 0. >  
filter_message: < Regular expression or exact text that must match the message content for the filter to apply. Optional. By default, it matches any message. >  
filter_message_exact_match: < Defines whether filter_message is treated as a regular expression (0) or exact text (1). Optional. Default is 0. >  
filter_message_capture_regex: < Regular expression with capture groups to extract values from the message. >  
                               < Captured values will be stored in macros '__regexN__', where N is the capture group index. >  
filter_message_capture_json: < List of JSON paths (separated by '|') to extract values, using the same format as jq. >  
                               < Captured values will be stored in macros '__jsonN__', where N is the path index. >  
filter_module_value: < Value assigned to the module that generates the filter. Mandatory. >  
filter_end: < Marks the end of a filter configuration. Everything from filter_begin belongs to the same filter. Mandatory. >  

# Available macros for use in filter_module_name and filter_module_value:  
__topic__: < Replaced with the exact topic of the processed message. >  
__regexN__: < Replaced with the corresponding value captured by filter_message_capture_regex. >  
__jsonN__: < Replaced with the corresponding value captured by filter_message_capture_json. >
Example
filter_begin 
filter_module_name __topic__ temperatura
filter_module_type generic_data_string
filter_topic testtopic/weathervue/homeoffice
filter_topic_exact_match 1
filter_message measurement
filter_message_exact_match 1
filter_message_capture_regex "temperature":"([-+]?\d*\.\d+|\d+)"
filter_message_capture_json 
filter_module_value temperature: __regex1__ 
filter_end

filter_begin 
filter_module_name __topic__ Ibra
filter_module_type generic_data_string
filter_topic testtopic/ibratest
filter_topic_exact_match 1
filter_message_exact_match 0
filter_message_capture_regex "(.*)"
filter_module_value Ibra says: __regex1__ 
filter_end


filter_begin​
filter_module_name __topic__ val
filter_module_type generic_data_string
filter_topic testtopic/meter/M1/voltage_l1
filter_topic_exact_match 1
filter_message 
filter_message_exact_match 1
filter_message_capture_regex 
filter_message_capture_json $.val
filter_module_value __json1__ 
filter_end