-
Notifications
You must be signed in to change notification settings - Fork 120
SensorTag as Device #90
base: master
Are you sure you want to change the base?
Conversation
Venkat2811
commented
Feb 26, 2017
•
edited
Loading
edited
- Connect with Texas Instrument's SensorTag Device over BLE (Bluetooth Low Energy)
- Auto-reconnect mechanism as BLE exception occurs frequently
examples/dell5k_sensor_tag_iotcc.py
Outdated
sensors=[Sensors.TEMPERATURE, Sensors.HUMIDITY, Sensors.BAROMETER, | ||
Sensors.BATTERY_LEVEL, Sensors.LIGHTMETER, | ||
Sensors.ACCELEROMETER, Sensors.GYROSCOPE]) | ||
sensor_tag = sensor_tag_collector.get_sensor_tag() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be the requirement of get_sensor_tag(), just have one definition for sensor tag device and use it.
liota/entities/devices/sensor_tag.py
Outdated
Facilitates collecting sensor metrics even in-case of dis-connectivity due to external factors, without any need | ||
of manual restart of the program. | ||
|
||
Use this class to collect metrics from SensorTag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be a separate class for collecting metrics, make it part of SensorTagDevice class. Creates confusion and complexity for user.
liota/entities/devices/sensor_tag.py
Outdated
ALL = 8 | ||
|
||
|
||
class SensorTagDevice(Device, SensorTag): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is SensorTagDevice dependent on SensorTag ? Any specific requirement, I`m not clear with this implementation.
liota/entities/devices/sensor_tag.py
Outdated
""" | ||
|
||
def __init__(self, name, device_mac, entity_type="Device"): | ||
Device.__init__( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use super
liota/entities/devices/sensor_tag.py
Outdated
:return: None | ||
""" | ||
log.info("Connecting to SensorTag Device: {0} with MAC_ADDRESS: {1}".format(self.device_name, self.device_mac)) | ||
self.tag = SensorTagDevice( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be part of user code(Initializing Device class) shouldn't be in the core Liota.
self.metrics.append(reg_mem_free_metric) | ||
|
||
# Connects to the SensorTag device over BLE | ||
self.sensor_tag_collector = SensorTagCollector(device_name=config['DeviceName'], device_mac=config['DeviceMac'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a separate device package and metrics package. Initialization of device shouldn't be part of this device metrics package.
ureg = pint.UnitRegistry() | ||
|
||
|
||
def read_cpu_procs(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just keep the device metrics in this package, don`t combine the device metrics and edge system metrics in the same package.
sampling_function=read_cpu_procs | ||
) | ||
reg_cpu_procs_metric = iotcc.register(cpu_procs_metric) | ||
iotcc.create_relationship(iotcc_edge_system, reg_cpu_procs_metric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just keep the package dependent on the device metrics only.
examples/dell5k_sensor_tag_iotcc.py
Outdated
|
||
# create a data center object, IoTCC in this case, using websocket as a transport layer | ||
iotcc = IotControlCenter(config['IotCCUID'], config['IotCCPassword'], | ||
WebSocketDccComms(url=config['WebSocketUrl'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use MQTT DCC Comms.
liota/entities/devices/sensor_tag.py
Outdated
Returns SensorTagDevice entity. | ||
:return: SensorTagDevice entity object. | ||
""" | ||
return self.tag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to discuss about this tag implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this tag comments.
We need to discuss some of the implementations. |
# Conflicts: # requirements.txt
Addressed review comments |
liota/entities/devices/sensor_tag.py
Outdated
Returns SensorTagDevice entity. | ||
:return: SensorTagDevice entity object. | ||
""" | ||
return self.tag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this tag comments.
@@ -0,0 +1,155 @@ | |||
# -*- coding: utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just rename the path as "packages/examples/metrics".As you are making the new folder I`ll prefer if you can move the entities in the specific folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay will rename it. For packages, we need to move device and metric entities separately. This will result changes in many files. In the interest of keeping no.of files changed for a PR less, I'll raise a separate one just for refactoring once this is merged.
temperature_metric = Metric( | ||
name="AmbientTemperature", | ||
unit=ureg.degC, | ||
interval=0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the interval be other than "0"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We provide sampling interval here
So, to collect from SensorTag, it must be zero.
@@ -0,0 +1,232 @@ | |||
# -*- coding: utf-8 -*- | |||
# ----------------------------------------------------------------------------# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you are making the new folder I`ll prefer if you can move the entities in the specific folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have separate folder for model_simulated examples. This is the first actual device. DHT examples can go in here.
@@ -0,0 +1,155 @@ | |||
# -*- coding: utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you can move all the metrics associated package in this folder.