mirror of
https://github.com/OpenMTC/OpenMTC.git
synced 2025-06-24 08:20:30 +00:00
Compare commits
7 Commits
feature-no
...
FIWARE_7.7
Author | SHA1 | Date | |
---|---|---|---|
1052fd4a08 | |||
c3ac4f9dfb | |||
7781b15c4e | |||
b9034a916f | |||
5257a11cf0 | |||
461698b32a | |||
734a51fb73 |
57
.travis.yml
57
.travis.yml
@ -1,26 +1,26 @@
|
||||
services:
|
||||
- docker
|
||||
- docker
|
||||
dist: xenial
|
||||
before_script:
|
||||
- sudo apt update
|
||||
- sudo apt install qemu-user-static python3 python3-pip python3-setuptools
|
||||
- sudo pip3 install --upgrade pip
|
||||
- sudo python3 -m pip install --upgrade setuptools
|
||||
- sudo python3 -m pip install --upgrade pyresttest
|
||||
- "./create-binary-docker backend"
|
||||
- "./create-binary-docker backend -a arm"
|
||||
- "./create-binary-docker gateway"
|
||||
- "./create-binary-docker gateway -a arm"
|
||||
- "./create-binary-docker orioncontextbroker"
|
||||
- "./create-binary-docker orioncontextbroker -a arm"
|
||||
- "./create-binary-docker influxdbapp"
|
||||
- "./create-binary-docker influxdbapp -a arm"
|
||||
- "./create-binary-docker cul868ipe"
|
||||
- "./create-binary-docker cul868ipe -a arm"
|
||||
- docker run -d --name backend -p 0.0.0.0:18000:18000 -e "ONEM2M_CSE_ID=backend" -e "ONEM2M_NOTIFICATION_DISABLED=false" openmtc/backend-amd64 -v
|
||||
- docker logs backend
|
||||
- docker run -d --name gateway -p 0.0.0.0:8000:8000 -e "ONEM2M_HTTP_TRANSPORT_PORT=8000" -e "ONEM2M_CSE_ID=gateway" -e "ONEM2M_REMOTE_CSE_POA=<POA>" -e "ONEM2M_REMOTE_CSE_ID=backend" -e "ONEM2M_NOTIFICATION_DISABLED=false" -e "ONEM2M_REGISTRATION_DISABLED=false" openmtc/gateway-amd64 -v
|
||||
- docker logs gateway
|
||||
- sudo apt update
|
||||
- sudo apt install qemu-user-static python3 python3-pip python3-setuptools
|
||||
- sudo pip3 install --upgrade pip
|
||||
- sudo python3 -m pip install --upgrade setuptools
|
||||
- sudo python3 -m pip install --upgrade pyresttest
|
||||
- "./create-binary-docker backend"
|
||||
- "./create-binary-docker backend -a arm"
|
||||
- "./create-binary-docker gateway"
|
||||
- "./create-binary-docker gateway -a arm"
|
||||
- "./create-binary-docker orioncontextbroker"
|
||||
- "./create-binary-docker orioncontextbroker -a arm"
|
||||
- "./create-binary-docker influxdbapp"
|
||||
- "./create-binary-docker influxdbapp -a arm"
|
||||
- "./create-binary-docker cul868ipe"
|
||||
- "./create-binary-docker cul868ipe -a arm"
|
||||
- docker run -d --name backend -p 0.0.0.0:18000:18000 -e "ONEM2M_CSE_ID=backend" -e "ONEM2M_NOTIFICATION_DISABLED=false" openmtc/backend-amd64 -v
|
||||
- docker logs backend
|
||||
- docker run -d --name gateway -p 0.0.0.0:8000:8000 -e "ONEM2M_HTTP_TRANSPORT_PORT=8000" -e "ONEM2M_CSE_ID=gateway" -e "ONEM2M_REMOTE_CSE_POA=<POA>" -e "ONEM2M_REMOTE_CSE_ID=backend" -e "ONEM2M_NOTIFICATION_DISABLED=false" -e "ONEM2M_REGISTRATION_DISABLED=false" openmtc/gateway-amd64 -v
|
||||
- docker logs gateway
|
||||
script:
|
||||
- docker tag openmtc/orioncontextbroker-amd64 openmtc/orion-context-broker-app-amd64
|
||||
- docker tag openmtc/orioncontextbroker-arm openmtc/orion-context-broker-app-arm
|
||||
@ -35,6 +35,21 @@ after_script:
|
||||
env:
|
||||
matrix:
|
||||
secure: oQe/MxxFrPPArxb6OFzOUwG2ZlA5GYekMR6qn0Y3101v82MdrIVgDILHR41iwykTtk1XpJPV9uabsRsvY4hBmbjYzihYZFOAzFf+/KU7wROtKum0fFfLjCPb8uGV41k1JTquB94FibXboVAP7rNL0Vrpl+FGUvMGatQBtwZnGvha6Ha07qTao+X9+0dJ4YvFlvcba/jfzBZBwHw7KHpRoiyKU0dPmXpHcqnZBFcNqRXhzdVrgx0auP/tghoshW5LQWkpTV11uSx/kYuby4oo8r8nB6L0rW1jYSXs9DHiTQCfCy24xlb9YJjCD9aFcjH0lIkVIqQwJYA67MzKYMK4XV684J/Jr3+jfVOoUt0bpZaTnk+r/uiFCtEsN7q0KUlvHLUAi1YNJhKs6CRrAH3GK25QByh+suzPzZoHP42F2LYP9URlzbDH+/v7CwNuw+9pHSmxEhs18LVmggwkMos3o3ArvzMLRNJ3QG1fdoxL/Ubqxhmvhy4rZi6vGQsiF64oX8PN0sRgXekTU/ma+6CTM6qhgkocMUYzT2r/6qd/9R3jmtxSZnikjkR6Iu9NLzAUY+cqnvvjohAvqYyj+tGlQfOPxAU9H4wXnbQWLBM8yn6yt2Ki+3+Jx4Owdv0oXVJpN0GWjMzIJ1nEus5odkWW+c4wcZb6m3Ak0PrzYPp2BgE=
|
||||
after_success:
|
||||
- if [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
|
||||
docker push openmtc/backend-amd64;
|
||||
docker push openmtc/backend-arm;
|
||||
docker push openmtc/gateway-amd64;
|
||||
docker push openmtc/gateway-arm;
|
||||
docker push openmtc/orion-context-broker-app-amd64;
|
||||
docker push openmtc/orion-context-broker-app-arm;
|
||||
docker push openmtc/cul868-ipe-amd64;
|
||||
docker push openmtc/cul868-ipe-arm;
|
||||
docker push openmtc/influxdb-app-amd64;
|
||||
docker push openmtc/influxdb-app-arm;
|
||||
fi
|
||||
after_failure:
|
||||
- docker logs backend
|
||||
- docker logs gateway
|
||||
- docker logs gateway
|
||||
- coveralls
|
6
CONTRIBUTIONS.md
Normal file
6
CONTRIBUTIONS.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Contributors ordered by number of commits
|
||||
|
||||
Ronald Steinke <rst-fokus>
|
||||
Christian Klopp <ckl-fokus>
|
||||
Alexander Ortlieb <aor-fokus>
|
||||
Jason Fox <jason-fox>
|
15
README.md
15
README.md
@ -12,6 +12,8 @@
|
||||

|
||||
[](https://hub.docker.com/u/openmtc)
|
||||
[](https://travis-ci.org/OpenMTC/OpenMTC)
|
||||
[](https://snyk.io/test/github/OpenMTC/OpenMTC?targetFile=openmtc-gevent%2Frequirements.txt)
|
||||
[](https://coveralls.io/github/OpenMTC/OpenMTC?branch=master)
|
||||
|
||||
The OpenMTC SDK aims to provide developers with a convenient yet flexible tool
|
||||
to write oneM2M compliant applications. This includes network applications
|
||||
@ -22,16 +24,19 @@ This project is part of [FIWARE](https://www.fiware.org/). For more information
|
||||
check the FIWARE Catalogue entry for the
|
||||
[IoT Agents](https://github.com/Fiware/catalogue/tree/master/iot-agents).
|
||||
|
||||
| :books: [Documentation](https://fiware-openmtc.readthedocs.io) | :page_facing_up: [Site](http://www.openmtc.org) | :whale: [Docker Hub](https://hub.docker.com/u/openmtc) | :dart: [Roadmap](roadmap.md) |
|
||||
|
||||
# Content
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [API](#api)
|
||||
- [Quality Assurance](#quality-assurance)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
|
||||
## Install
|
||||
## Install
|
||||
|
||||
Information about how to install the JSON IoTAgent can be found at the
|
||||
corresponding section of the
|
||||
@ -89,10 +94,14 @@ follows:
|
||||
|
||||
---
|
||||
|
||||
## Licence
|
||||
## Contributing
|
||||
|
||||
Contribution guidelines are detailed in the [CONTRIBUTIONS](CONTRIBUTIONS.md) file.
|
||||
|
||||
## License
|
||||
|
||||
The OpenMTC SDK is licensed under the Eclipse Public License (EPL)
|
||||
version 1.
|
||||
|
||||
© 2018 OpenMTC
|
||||
© 2018-2019 OpenMTC
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
Transfer OpenMTC Data to an InfluxDB
|
||||
"""
|
||||
|
||||
__version__ = "1.2.0"
|
||||
__version__ = "1.3.0"
|
||||
__description__ = "InfluxdbApp"
|
||||
__author_name__ = "Christian Klopp"
|
||||
__author_mail__ = "christian.klopp@fokus.fraunhofer.de"
|
||||
|
@ -3,7 +3,7 @@ This App will forward all incoming sensor traffic to the Fiware Orion Context
|
||||
Broker
|
||||
"""
|
||||
|
||||
__version__ = "1.2.0"
|
||||
__version__ = "1.3.0"
|
||||
__description__ = "OrionContextBroker"
|
||||
__author_name__ = "Christian Klopp"
|
||||
__author_mail__ = "christian.klopp@fokus.fraunhofer.de"
|
||||
|
@ -1,5 +1,6 @@
|
||||
from urllib.parse import urljoin
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
|
||||
@ -89,7 +90,8 @@ class OrionAPI(LoggerMixin):
|
||||
"type": self._get_type(data_senml["v"]),
|
||||
"metadata": {
|
||||
"timestamp": {
|
||||
"value": data_senml["t"],
|
||||
"value": datetime.fromtimestamp(float(data_senml["t"])).replace(microsecond=0).isoformat()
|
||||
if data_senml["t"] != "none" else data_senml["t"],
|
||||
"type": "String"
|
||||
},
|
||||
"bn": {
|
||||
|
@ -2,7 +2,7 @@
|
||||
App to inject data from a csv file to OpenMTC
|
||||
"""
|
||||
|
||||
__version__ = "1.2.0"
|
||||
__version__ = "1.3.0"
|
||||
__description__ = "csvInjector"
|
||||
__author_name__ = "Christian Klopp"
|
||||
__author_mail__ = "christian.klopp@fokus.fraunhofer.de"
|
||||
|
@ -2,7 +2,7 @@
|
||||
TODO: Add description here
|
||||
"""
|
||||
|
||||
__version__ = "1.2.0"
|
||||
__version__ = "1.3.0"
|
||||
__description__ = "mqttConnector"
|
||||
__author_name__ = "Ronald Steinke"
|
||||
__author_mail__ = "ronald.steinke@fokus.fraunhofer.de"
|
||||
|
@ -772,21 +772,11 @@ class EventNotificationCriteria(OneM2MEntity):
|
||||
|
||||
|
||||
class BatchNotify(OneM2MEntity):
|
||||
""" See TS-004 6.3.5.6
|
||||
See TS-004 Table 6.3.5.6-1"""
|
||||
|
||||
number = Attribute(int)
|
||||
duration = Attribute(int)
|
||||
|
||||
pass # TODO
|
||||
|
||||
|
||||
class RateLimit(OneM2MEntity):
|
||||
""" See TS-004 6.3.5.31
|
||||
See TS-004 Table 6.3.5.31-1"""
|
||||
|
||||
maxNrOfNotify = Attribute(int)
|
||||
timeWindow = Attribute(int)
|
||||
|
||||
pass # TODO
|
||||
|
||||
|
||||
class Subscription(RegularResourceC):
|
||||
|
@ -13,7 +13,7 @@ from openmtc_onem2m.model import (get_onem2m_type, ContentInstance,
|
||||
get_long_attribute_name,
|
||||
OneM2MEntity, OneM2MResource, Container,
|
||||
get_long_resource_name, OneM2MContentResource,
|
||||
URIList, OneM2MIntEnum, SecurityInfo, AggregatedNotification)
|
||||
URIList, OneM2MIntEnum, SecurityInfo)
|
||||
|
||||
_typename_matcher = re_compile(r'^m2m:([a-z]+)$')
|
||||
|
||||
@ -51,17 +51,6 @@ class OneM2MSerializer(LoggerMixin, metaclass=ABCMeta):
|
||||
representation = data["notificationEvent"]["representation"]
|
||||
representation = self.decode(self.dumps(representation))
|
||||
data["notificationEvent"]["representation"] = representation
|
||||
if resource_type is AggregatedNotification and "notification" in data:
|
||||
notifications = data["notification"]
|
||||
data["notification"] = []
|
||||
|
||||
for notification in notifications:
|
||||
data["notification"].append(
|
||||
self.decode(
|
||||
self.dumps(notification)
|
||||
)
|
||||
)
|
||||
|
||||
resource = resource_type(**data)
|
||||
if child_resource:
|
||||
resource.childResource = child_resource
|
||||
@ -78,22 +67,6 @@ class OneM2MDictSerializer(OneM2MSerializer):
|
||||
|
||||
self.logger.debug("Encoding representation: %s", representation)
|
||||
|
||||
if isinstance(resource, AggregatedNotification):
|
||||
try:
|
||||
notifications = representation["notification"]
|
||||
|
||||
if notifications:
|
||||
representation["notification"] = []
|
||||
|
||||
for notification in notifications:
|
||||
representation["notification"].append(
|
||||
self.encode_resource(
|
||||
notification, pretty, path, encoding, fields, True
|
||||
)
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
pass
|
||||
|
||||
if isinstance(resource, Notification):
|
||||
# handle notifications
|
||||
try:
|
||||
@ -147,7 +120,7 @@ class OneM2MDictSerializer(OneM2MSerializer):
|
||||
k, v in representation.items()}
|
||||
|
||||
if not isinstance(resource, (OneM2MResource, Notification,
|
||||
SecurityInfo, OneM2MContentResource,AggregatedNotification)):
|
||||
SecurityInfo, OneM2MContentResource)):
|
||||
return representation
|
||||
|
||||
typename = 'm2m:' + (get_short_resource_name(resource.typename) or
|
||||
|
@ -43,6 +43,6 @@ if __name__ == "__main__":
|
||||
from openmtc_app.flask_runner import SimpleFlaskRunner as Runner
|
||||
|
||||
ep = "http://localhost:8000"
|
||||
Runner(DataVisualization(), port=6050, host='auto').run(ep)
|
||||
Runner(DataVisualization(poas=['http://localhost:21345'])).run(ep)
|
||||
|
||||
|
||||
|
@ -91,4 +91,4 @@ if __name__ == "__main__":
|
||||
from openmtc_app.flask_runner import SimpleFlaskRunner as Runner
|
||||
|
||||
ep = "http://localhost:8000"
|
||||
Runner(DataAggregation(), port=6050, host='auto').run(ep)
|
||||
Runner(DataAggregation(poas=['http://localhost:21346'])).run(ep)
|
||||
|
@ -19,4 +19,4 @@ if __name__ == "__main__":
|
||||
from openmtc_app.flask_runner import SimpleFlaskRunner as Runner
|
||||
|
||||
ep = "http://localhost:8000"
|
||||
Runner(SimpleDecision2(), port=6050, host='auto').run(ep)
|
||||
Runner(SimpleDecision2(poas=['http://localhost:21387'])).run(ep)
|
||||
|
@ -47,4 +47,4 @@ if __name__ == "__main__":
|
||||
from openmtc_app.flask_runner import SimpleFlaskRunner as Runner
|
||||
|
||||
ep = "http://localhost:8000"
|
||||
Runner(SimpleDecision(), port=6050, host='auto').run(ep)
|
||||
Runner(SimpleDecision(poas=['http://localhost:22245'])).run(ep)
|
||||
|
@ -31,5 +31,6 @@ app_file=${app_array[$[${choice}-1]]}
|
||||
################################################################################
|
||||
# run app_file
|
||||
cd ${base_path}
|
||||
. ../../common/prep-env.sh
|
||||
python ${app_file}
|
||||
cd ..
|
||||
. ../common/prep-env.sh
|
||||
python3 ${app_file}
|
||||
|
@ -2,7 +2,7 @@
|
||||
Interworking Proxy for Cul868 devices.
|
||||
"""
|
||||
|
||||
__version__ = "1.2.0"
|
||||
__version__ = "1.3.0"
|
||||
__description__ = "The OpenMTC Cul868IPE"
|
||||
__author_name__ = "Ronny Kreuch"
|
||||
__author_mail__ = "ronny.kreuch@fokus.fraunhofer.de"
|
||||
|
@ -7,9 +7,6 @@ from openmtc_onem2m.model import (
|
||||
EventNotificationCriteria,
|
||||
NotificationEventTypeE,
|
||||
Subscription,
|
||||
BatchNotify,
|
||||
RateLimit,
|
||||
AggregatedNotification,
|
||||
)
|
||||
from openmtc_onem2m.serializer import get_onem2m_decoder
|
||||
from urllib.parse import urlparse
|
||||
@ -101,19 +98,12 @@ class NotificationManager(LoggerMixin):
|
||||
def register_callback(self, func, sur, del_func=None):
|
||||
self.callbacks[sur] = {
|
||||
'cb': func if len(getargspec(func)[0]) > 1
|
||||
else lambda _, **notification: (
|
||||
func(notification['not']) if 'not' in notification.keys()
|
||||
else func(notification['rep'])),
|
||||
else lambda _, **notification: func(notification['rep']),
|
||||
'del_cb': del_func
|
||||
}
|
||||
|
||||
def _handle_callback(self, originator, **notification):
|
||||
try:
|
||||
n = notification["not"][0]
|
||||
except KeyError:
|
||||
n = notification
|
||||
|
||||
sur = n.pop('sur')
|
||||
sur = notification.pop('sur')
|
||||
sur = self._normalize_path(sur)
|
||||
|
||||
try:
|
||||
@ -142,7 +132,7 @@ class NotificationManager(LoggerMixin):
|
||||
def get_expiration_time(self):
|
||||
return None
|
||||
|
||||
def subscribe(self, path, func, delete_func=None, filter_criteria=None, sub_options=None, expiration_time=None,
|
||||
def subscribe(self, path, func, delete_func=None, filter_criteria=None, expiration_time=None,
|
||||
notification_types=(NotificationEventTypeE.updateOfResource,)):
|
||||
self._init()
|
||||
|
||||
@ -150,23 +140,12 @@ class NotificationManager(LoggerMixin):
|
||||
event_notification_criteria.notificationEventType = (
|
||||
event_notification_criteria.notificationEventType or list(notification_types))
|
||||
|
||||
subscription = Subscription(
|
||||
subscription = self.mapper.create(path, Subscription(
|
||||
notificationURI=[self.mapper.originator],
|
||||
expirationTime=expiration_time or self.get_expiration_time(),
|
||||
eventNotificationCriteria=event_notification_criteria,
|
||||
subscriberURI=self.mapper.originator,
|
||||
)
|
||||
|
||||
if sub_options:
|
||||
try:
|
||||
subscription.batchNotify = BatchNotify(**sub_options["batchNotify"])
|
||||
except KeyError:
|
||||
try:
|
||||
subscription.rateLimit = RateLimit(**sub_options["rateLimit"])
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
subscription = self.mapper.create(path, subscription)
|
||||
))
|
||||
|
||||
reference = self._normalize_path(subscription.path)
|
||||
self.register_callback(func, reference, delete_func)
|
||||
@ -284,32 +263,10 @@ class HttpNotificationHandler(BaseNotificationHandler):
|
||||
cl = int(request.environ.get('CONTENT_LENGTH'), 0)
|
||||
request.data = request.environ['wsgi.input'].read(cl)
|
||||
|
||||
|
||||
######## NEW CODE BEGINNING
|
||||
notification = {}
|
||||
notification_type = get_onem2m_decoder(request.content_type).decode(request.data)
|
||||
|
||||
if isinstance(notification_type, AggregatedNotification):
|
||||
notification["not"] = []
|
||||
|
||||
for n in notification_type.values["notification"]:
|
||||
notification["not"].append(
|
||||
self._unpack_notification(n)
|
||||
)
|
||||
else:
|
||||
notification = self._unpack_notification(notification_type)
|
||||
######## NEW CODE ENDING
|
||||
|
||||
# TODO Check if the above is working or take the below one
|
||||
######## OLD CODE BEGINNING
|
||||
# notification = get_onem2m_decoder(request.content_type).decode(request.data)
|
||||
# if not notification.verificationRequest:
|
||||
# notification = self._unpack_notification(notification)
|
||||
######## OLD CODE ENDING
|
||||
|
||||
|
||||
self._callback(request.headers['x-m2m-origin'], **notification)
|
||||
|
||||
notification = get_onem2m_decoder(request.content_type).decode(request.data)
|
||||
if not notification.verificationRequest:
|
||||
notification = self._unpack_notification(notification)
|
||||
self._callback(request.headers['x-m2m-origin'], **notification)
|
||||
|
||||
return Response(
|
||||
headers={
|
||||
|
@ -571,11 +571,10 @@ class XAE(LoggerMixin):
|
||||
if x.rule != route]
|
||||
|
||||
def _add_subscription(self, path, _, handler, delete_handler, filter_criteria=None,
|
||||
sub_options=None, expiration_time=None):
|
||||
expiration_time=None):
|
||||
params = {
|
||||
'filter_criteria': filter_criteria,
|
||||
'expiration_time': expiration_time,
|
||||
'sub_options': sub_options,
|
||||
}
|
||||
return self.add_subscription_handler(path, handler, delete_handler, **params)
|
||||
|
||||
@ -591,7 +590,7 @@ class XAE(LoggerMixin):
|
||||
|
||||
def add_subscription_handler(self, path, handler, delete_handler=None,
|
||||
types=(NotificationEventTypeE.updateOfResource, ),
|
||||
filter_criteria=None, sub_options=None, expiration_time=None):
|
||||
filter_criteria=None, expiration_time=None):
|
||||
"""
|
||||
|
||||
:param path:
|
||||
@ -599,7 +598,6 @@ class XAE(LoggerMixin):
|
||||
:param delete_handler:
|
||||
:param types:
|
||||
:param filter_criteria:
|
||||
:param sub_options:
|
||||
:param expiration_time:
|
||||
:return:
|
||||
"""
|
||||
@ -610,7 +608,6 @@ class XAE(LoggerMixin):
|
||||
delete_handler,
|
||||
notification_types=types,
|
||||
filter_criteria=filter_criteria,
|
||||
sub_options=sub_options,
|
||||
expiration_time=expiration_time
|
||||
)
|
||||
|
||||
@ -630,7 +627,7 @@ class XAE(LoggerMixin):
|
||||
return subscription.path
|
||||
|
||||
def add_container_subscription(self, container, handler, delete_handler=None,
|
||||
filter_criteria=None, sub_options=None):
|
||||
filter_criteria=None):
|
||||
""" Creates a Subscription to the ContentInstances of the given
|
||||
Container.
|
||||
|
||||
@ -638,7 +635,6 @@ class XAE(LoggerMixin):
|
||||
:param handler: reference of the notification handling function
|
||||
:param delete_handler: reference to delete handling function
|
||||
:param filter_criteria: (optional) FilterCriteria for the subscription
|
||||
:param sub_options: (optional) SubscriptionOptions for the subscription
|
||||
"""
|
||||
|
||||
path = getattr(container, "path", container)
|
||||
@ -651,7 +647,6 @@ class XAE(LoggerMixin):
|
||||
filter_criteria = filter_criteria or EventNotificationCriteria()
|
||||
filter_criteria.notificationEventType = list([
|
||||
NotificationEventTypeE.createOfDirectChildResource,
|
||||
NotificationEventTypeE.updateOfResource,
|
||||
])
|
||||
|
||||
def content_handler(cin):
|
||||
@ -662,8 +657,7 @@ class XAE(LoggerMixin):
|
||||
None,
|
||||
content_handler,
|
||||
delete_handler,
|
||||
filter_criteria,
|
||||
sub_options,
|
||||
filter_criteria
|
||||
)
|
||||
|
||||
def __start_refresher(self, instance, extra_fields=(), restore=None):
|
||||
|
1
openmtc-gevent/requirements.txt
Symbolic link
1
openmtc-gevent/requirements.txt
Symbolic link
@ -0,0 +1 @@
|
||||
dependencies.txt
|
15
roadmap.md
Normal file
15
roadmap.md
Normal file
@ -0,0 +1,15 @@
|
||||
## Short Term
|
||||
onem2m Release 2a compatibility
|
||||
Group Resource
|
||||
Pub/Sub improvements (rateLimit and batchNotify)
|
||||
Persistence Enhancement
|
||||
|
||||
## Medium Term
|
||||
onem2m Release 3 compatibility
|
||||
Announcements
|
||||
FlexContainer Resource
|
||||
Node Resource
|
||||
|
||||
## Long Term
|
||||
CoAP(s) & MQTTS
|
||||
XML
|
@ -1,4 +1,3 @@
|
||||
import datetime
|
||||
from openmtc_onem2m import OneM2MRequest
|
||||
from openmtc_onem2m.exc import CSENotFound
|
||||
from openmtc_onem2m.model import (
|
||||
@ -9,7 +8,6 @@ from openmtc_onem2m.model import (
|
||||
NotificationContentTypeE,
|
||||
EventNotificationCriteria,
|
||||
NotificationEventTypeE,
|
||||
AggregatedNotification,
|
||||
)
|
||||
from openmtc_onem2m.transport import OneM2MOperation
|
||||
from openmtc_server.Plugin import Plugin
|
||||
@ -97,10 +95,6 @@ class NotificationHandler(Plugin):
|
||||
"pid": subscription.parentID,
|
||||
"enc": get_event_notification_criteria(subscription),
|
||||
"sub": subscription,
|
||||
"not": [], # notifications
|
||||
"levt": datetime.datetime.now(), # last event time
|
||||
"sno": 0 # sent notifications (ratelimit)
|
||||
|
||||
}
|
||||
|
||||
def _handle_subscription_updated(self, subscription, _):
|
||||
@ -282,68 +276,6 @@ class NotificationHandler(Plugin):
|
||||
# preSubscriptionNotify is not supported in this release of the
|
||||
# document.
|
||||
|
||||
# batchNotify
|
||||
try:
|
||||
batch_notify = sub.batchNotify
|
||||
|
||||
if batch_notify is not None:
|
||||
current_time = datetime.datetime.now()
|
||||
notifications = self.subscriptions_info[sub.resourceID]["not"]
|
||||
|
||||
for uri in sub.notificationURI:
|
||||
notifications.append(
|
||||
Notification(
|
||||
notificationEvent=NotificationEventC(
|
||||
representation=resource
|
||||
),
|
||||
subscriptionReference=self._get_subscription_reference(uri, sub.path),
|
||||
creator=sub.creator
|
||||
)
|
||||
)
|
||||
|
||||
# Note: the extra condition 'len(notifications) < int(batch_notify.number) + 1'
|
||||
# is needed, otherwise sometimes one more notification is sent
|
||||
if int(batch_notify.number) <= len(notifications) and len(notifications) < int(batch_notify.number) + 1 or \
|
||||
int(batch_notify.duration) <= int((current_time - self.subscriptions_info[sub.resourceID]["levt"]).seconds):
|
||||
aggregated_notification = AggregatedNotification(**{"notification": notifications})
|
||||
|
||||
self._send_notification(aggregated_notification, sub)
|
||||
self.subscriptions_info[sub.resourceID]["levt"] = current_time
|
||||
self.subscriptions_info[sub.resourceID]["not"] = []
|
||||
|
||||
return
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
# rateLimit
|
||||
try:
|
||||
ratelimit = sub.rateLimit
|
||||
|
||||
if ratelimit is not None:
|
||||
notification_resources = self.subscriptions_info[sub.resourceID]["not"]
|
||||
|
||||
for uri in sub.notificationURI:
|
||||
notification_resources.append(resource)
|
||||
|
||||
for i in range(len(notification_resources)):
|
||||
current_time = datetime.datetime.now()
|
||||
|
||||
if int((current_time - self.subscriptions_info[sub.resourceID]["levt"]).seconds) <= int(ratelimit.timeWindow):
|
||||
if self.subscriptions_info[sub.resourceID]["sno"] <= int(ratelimit.maxNrOfNotify):
|
||||
self._send_notification(notification_resources.pop(0), sub)
|
||||
self.subscriptions_info[sub.resourceID]["sno"] += 1
|
||||
else:
|
||||
break
|
||||
else:
|
||||
self.subscriptions_info[sub.resourceID]["levt"] = current_time
|
||||
self.subscriptions_info[sub.resourceID]["sno"] = 0
|
||||
break
|
||||
|
||||
return
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
# Step 3.0 The Originator shall check the notification and reachability
|
||||
# schedules, but the notification schedules may be checked in different
|
||||
# order.
|
||||
@ -419,15 +351,6 @@ class NotificationHandler(Plugin):
|
||||
def _send_notification(self, resource, sub):
|
||||
self.logger.debug("sending notification for resource: %s", resource)
|
||||
|
||||
if isinstance(resource, AggregatedNotification):
|
||||
for uri in sub.notificationURI:
|
||||
self.api.handle_onem2m_request(OneM2MRequest(
|
||||
op=OneM2MOperation.notify,
|
||||
to=uri,
|
||||
pc=resource
|
||||
))
|
||||
return
|
||||
|
||||
for uri in sub.notificationURI:
|
||||
self.api.handle_onem2m_request(OneM2MRequest(
|
||||
op=OneM2MOperation.notify,
|
||||
|
@ -13,7 +13,7 @@ from utils import (get_packages, OpenMTCSdist, OpenMTCBuildPy,
|
||||
|
||||
# name and version
|
||||
SETUP_NAME = "openmtc-all"
|
||||
SETUP_VERSION = "1.2.0"
|
||||
SETUP_VERSION = "1.3.0"
|
||||
SETUP_DESCRIPTION = "The OpenMTC Backend and Gateway (GEvent version)"
|
||||
|
||||
# meta
|
||||
|
@ -7,7 +7,7 @@ from utils import get_packages, OpenMTCSdist
|
||||
# name and version
|
||||
NAME = "sdk"
|
||||
SETUP_NAME = "openmtc-" + NAME
|
||||
SETUP_VERSION = "1.2.0"
|
||||
SETUP_VERSION = "1.3.0"
|
||||
SETUP_DESCRIPTION = "The OpenMTC Python SDK"
|
||||
|
||||
# meta
|
||||
|
Reference in New Issue
Block a user