Skip to content

Instantly share code, notes, and snippets.

View JoelBender's full-sized avatar
🎯
Focusing

Joel Bender JoelBender

🎯
Focusing
View GitHub Profile
@JoelBender
JoelBender / COVClientApp.py
Last active December 7, 2020 17:45
This non-threaded BACpypes COV client application maintains a "context" for subscriptions.
#!/usr/bin/env python
"""
Configured with a subscription context object which is passed to the
application, it sends a SubscribeCOVRequest and listens for confirmed or
unconfirmed COV notifications, lines them up with the context, and passes the
APDU to the context to print out.
Making multiple subscription contexts and keeping them active based on their
lifetime is left as an exercise for the reader.
#!/usr/bin/env python
"""
This application presents a 'console' prompt to the user asking for read commands
which create ReadPropertyRequest PDUs, then lines up the coorresponding ReadPropertyACK
and prints the value.
"""
import sys
@JoelBender
JoelBender / read_state_machine.py
Created June 26, 2018 18:32
This application creates an application layer state machine which sends a Read Property Request and then quits after the ack is received.
#!/usr/bin/env python
"""
This application creates an application layer state machine which sends
a Read Property Request and then quits after the ack is received.
The state_machine module is almost identical to the one in the tests directory
with the exception that the TrafficLog class has been removed as well as
its reliance on the time_machine module.
"""
@JoelBender
JoelBender / trend_log.py
Created June 30, 2018 04:48
This is a sample of what I'm considering for backing up a `LocalTrendLogObject` implementation and using for testing. While this is in-memory, it doesn't seem like a huge stretch to make a database backing store that has the same API.
#!/usr/bin/python
"""
"""
import sys
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.primitivedata import Boolean, Unsigned, Integer, Real, BitString, Enumerated, Date, Time
from bacpypes.basetypes import ErrorType, StatusFlags, LogStatus, LogRecord, LogRecordLogDatum, DateTime
@JoelBender
JoelBender / EventNotifications.py
Created June 30, 2018 18:32
This is an **untested** application to save/restore a notification class recipient list and replace it with the local device. It also dumps out the event notifications it receives.
#!/usr/bin/env python
"""
This application presents a 'console' prompt to the user asking to save and
restore a recipient list from a notification class object, or re-write one to
the local device. It also listens and acknowledges incoming event notifications.
"""
import os
import sys
@JoelBender
JoelBender / who_is_and_more.py
Created July 18, 2018 03:14
This application generates a Who-Is request at startup and collects the I-Am responses into a list for more processing.
#!/usr/bin/env python
"""
This application generates a Who-Is request at startup and collects the I-Am
responses into a list for more processing.
"""
import sys
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
@JoelBender
JoelBender / FlaskReadProperty.py
Created September 13, 2018 17:47
Flask based web server that reads values based on `MultipleReadProperty.py` sample. Not for production use.
#!/usr/bin/env python
"""
A web server based on flask that reads properties from objects and returns an
HTML page of the results.
"""
from flask import Flask
from jinja2 import Template
from threading import Thread
@JoelBender
JoelBender / gist:c1c5c0dcd67a56f89869f48790d59927
Created January 31, 2019 02:52
aioamqp connection lost non-feature
"""
RPC server, aioamqp implementation of RPC examples from RabbitMQ tutorial
"""
import asyncio
import logging
import signal
import aioamqp
from aioamqp.protocol import AmqpProtocol
# -*- coding: utf-8 -*-
import sys
from io import BytesIO
from rdflib import Graph
from pyshacl.validate import Validator
data = b"""
@prefix bakery: <http://bakery.com/ns#> .
@JoelBender
JoelBender / who_is_and_device_info.py
Created September 10, 2019 13:43
Who-Is and Device Information
#!/usr/bin/env python
"""
This application generates a Who-Is request at startup and collects the I-Am
responses into a list, then reads various properties of the device objects,
then outputs the content as a JSON document.
"""
import sys
import json