Skip to content
This repository was archived by the owner on Mar 15, 2021. It is now read-only.

SensorTag as Device#90

Open
Venkat2811 wants to merge 11 commits into
vmware-archive:masterfrom
Venkat2811:sensor-tag
Open

SensorTag as Device#90
Venkat2811 wants to merge 11 commits into
vmware-archive:masterfrom
Venkat2811:sensor-tag

Conversation

@Venkat2811

@Venkat2811 Venkat2811 commented Feb 26, 2017

Copy link
Copy Markdown
Contributor
  • Connect with Texas Instrument's SensorTag Device over BLE (Bluetooth Low Energy)
  • Auto-reconnect mechanism as BLE exception occurs frequently

Comment thread 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()

Copy link
Copy Markdown
Contributor

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.

Comment thread 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.

Copy link
Copy Markdown
Contributor

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.

Comment thread liota/entities/devices/sensor_tag.py Outdated
ALL = 8


class SensorTagDevice(Device, SensorTag):

Copy link
Copy Markdown
Contributor

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.

Comment thread liota/entities/devices/sensor_tag.py Outdated
"""

def __init__(self, name, device_mac, entity_type="Device"):
Device.__init__(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use super

Comment thread 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(

Copy link
Copy Markdown
Contributor

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.

Comment thread packages/examples/iotcc_sensor_tag.py Outdated
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'],

Copy link
Copy Markdown
Contributor

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.

Comment thread packages/examples/iotcc_sensor_tag.py Outdated
ureg = pint.UnitRegistry()


def read_cpu_procs():

Copy link
Copy Markdown
Contributor

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.

Comment thread packages/examples/iotcc_sensor_tag.py Outdated
sampling_function=read_cpu_procs
)
reg_cpu_procs_metric = iotcc.register(cpu_procs_metric)
iotcc.create_relationship(iotcc_edge_system, reg_cpu_procs_metric)

Copy link
Copy Markdown
Contributor

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.

Comment thread 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']))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use MQTT DCC Comms.

Comment thread liota/entities/devices/sensor_tag.py Outdated
Returns SensorTagDevice entity.
:return: SensorTagDevice entity object.
"""
return self.tag

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this tag comments.

@KohliDev

Copy link
Copy Markdown
Contributor

We need to discuss some of the implementations.

@Venkat2811

Copy link
Copy Markdown
Contributor Author

Addressed review comments

Comment thread liota/entities/devices/sensor_tag.py Outdated
Returns SensorTagDevice entity.
:return: SensorTagDevice entity object.
"""
return self.tag

Copy link
Copy Markdown
Contributor

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 -*-

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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,

Copy link
Copy Markdown
Contributor

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"?

Copy link
Copy Markdown
Contributor Author

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 -*-
# ----------------------------------------------------------------------------#

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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 -*-

Copy link
Copy Markdown
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants