| 14 | # get the reading from the sensors, encode and send the information. |
| 15 | class Sensor: |
| 16 | def __init__(self,fw,sensor_config): |
| 17 | self.fw = fw |
| 18 | self.config = sensor_config |
| 19 | self.state = "send_sample" |
| 20 | |
| 21 | # We don't want any automatic communication when acting as sensors. |
| 22 | fw.config['quiet'] = True |
| 23 | fw.config['automsg'] = False |
| 24 | |
| 25 | # Add the sensor channel key if needed. |
| 26 | if not self.fw.keychain.has_key(self.config['key_name']): |
| 27 | self.fw.keychain.add_key(self.config['key_name'],self.config['key_secret']) |
| 28 | |
| 29 | # This method is called from FreakWAN main loop in order to |
| 30 | # execute the sensor state machine, that is: send sample, wait |