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 / multiple-ipv4-applications.py
Created March 15, 2025 05:11
BACnet/IP application that runs multiple applications on the same host.
"""
Simple example of a BACnet/IP application that runs multiple applications on the same host.
"""
import asyncio
from argparse import Namespace
from bacpypes3.app import Application
async def main() -> None:
@JoelBender
JoelBender / custom-nsap.py
Created September 24, 2024 05:32
Custom Network Service Access Point
"""
This example "intercepts" the NPDU coming up from a bottom layer and stores
the source address into the pduUserData attribute which is passed up through
the layers and reaches the application.
"""
import asyncio
from typing import List, Optional
from bacpypes3.debugging import ModuleLogger, bacpypes_debugging
@JoelBender
JoelBender / lots-of-objects.py
Created September 18, 2024 02:14
Lots of Objects
"""
An example with lots of local objects.
"""
import asyncio
from random import random
from bacpypes3.debugging import ModuleLogger
from bacpypes3.argparse import SimpleArgumentParser
from bacpypes3.ipv4.app import Application
@JoelBender
JoelBender / send-confirmed-event-notifications.json
Created October 22, 2023 03:01
Send confirmed event notification samples
[
{
"process-identifier": 1,
"initiating-device-identifier": "device,999",
"event-object-identifier": "analog-value,1",
"time-stamp": {
"time": "01:02:03"
},
"notification-class": 1,
"priority": 0,
import asyncio
from bacpypes3.debugging import ModuleLogger
from bacpypes3.argparse import SimpleArgumentParser
from bacpypes3.app import Application
from bacpypes3.local.analog import AnalogValueObject
from bacpypes3.local.binary import BinaryValueObject
_debug = 0
@JoelBender
JoelBender / 1_Info.py
Created July 28, 2023 16:51
Streamlit relative import
import sys
import os
import os.path
import streamlit as st
from streamlit.logger import get_logger
# humph
# utils_path = os.path.realpath(os.path.pardir)
# if utils_path not in sys.path:
@JoelBender
JoelBender / data-expecting-reply.py
Created September 23, 2022 01:50
Turning on and off pduExpectingReply to follow through the stack
import sys
from bacpypes.debugging import btox
from bacpypes.pdu import Address, PDU
from bacpypes.pdu import PDU
from bacpypes.apdu import APDU, ReadPropertyRequest
from bacpypes.npdu import NPDU
from bacpypes.analysis import decode_packet
@JoelBender
JoelBender / WhoIsFuzz.py
Created June 15, 2022 06:13
Put in a "fuzz" layer in an application stack
#!/usr/bin/env python
"""
This application presents a 'console' prompt to the user asking for Who-Is
commands which create the related APDUs and sends them through a "fuzz" layer
for additional processing.
"""
from bacpypes.debugging import bacpypes_debugging, ModuleLogger
from bacpypes.consolelogging import ConfigArgumentParser
@JoelBender
JoelBender / read_property_client_only.py
Created April 14, 2022 03:49
Client-only Application
#!/usr/bin/env python
"""
This is a clone of the ReadProperty.py sample application that does not
support the Who-Is and Read-Property services (which are provided by default)
making this essentially a client-only device.
Note that it is not completely stealthy, it will respond with a Reject if
it is sent a Read-Property request.
"""
@JoelBender
JoelBender / config-file-server.json
Created August 24, 2021 04:14
JSON Writable Configuration File
{
"avar": 74.1,
"bvar": "inactive"
}