Files
TouchSwitch/ConfigGenerator/configGen.py
Wolfgang Hottgenroth bcb7d511a7 code beautifying
2018-01-30 16:44:38 +01:00

33 lines
1.7 KiB
Python

#!/usr/bin/python
from Cheetah.Template import Template
configItems = [
{"label":"_", "key":"magic", "type":"I", "default": ""},
{"label":"Wifi SSID", "key":"wifiSsid", "type":"C", "length":32, "default":"test"},
{"label":"Wifi Key", "key":"wifiKey", "type":"C", "length":64, "default":"geheim"},
{"label":"MQTT Broker", "key":"mqttBroker", "type":"C", "length":64, "default":"broker.hottis.de"},
{"label":"MQTT Username", "key":"mqttUser", "type":"C", "length":32, "default":"TouchSwitch"},
{"label":"MQTT Password", "key":"mqttPass", "type":"C", "length":32, "default":"geheim123"},
{"label":"MQTT ClientId", "key":"mqttClientId", "type":"C", "length":32, "default":"TouchSwitch"},
{"label":"MQTT Port", "key":"mqttPort", "type":"I", "default":8883},
{"label":"MQTT Topic", "key":"mqttTopic", "type":"C", "length":64, "default":"IoT/TouchSwitch/Press"},
{"label":"MQTT DebugTopic", "key":"mqttDebugTopic", "type":"C", "length":64, "default":"IoT/TouchSwitch/Debug"},
{"label":"MQTT BaselineTopic", "key":"mqttBaselineTopic", "type":"C", "length":64, "default":"IoT/TouchSwitch/Baseline"},
{"label":"DebugMode", "key":"debugMode", "type":"I", "default":0},
{"label":"Period", "key":"period", "type":"I", "default":500},
{"label":"CalibrationTimeout", "key":"calibrationTimeout", "type":"I", "default":20000},
{"label":"Threshold", "key":"threshold", "type":"I", "default":10}
]
magic = 0xC0DE0002
h_file = Template(file="configuration_h.tmpl", searchList=[{"magic":magic, "configItems":configItems}])
open('configuration.h','w').write(str(h_file))
c_file = Template(file="configuration_c.tmpl", searchList=[{"magic":magic, "configItems":configItems}])
open('configuration.cpp','w').write(str(c_file))