Skip to content

Instantly share code, notes, and snippets.

View sjlongland's full-sized avatar

Stuart Longland sjlongland

View GitHub Profile
@sjlongland
sjlongland / radio.c
Created November 9, 2017 00:38
OpenThread radio.c with CC2592 calibration
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@sjlongland
sjlongland / portable_endian.h
Last active April 24, 2024 11:32 — forked from panzi/portable_endian.h
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, and Mac OS X. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put "port…
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
@sjlongland
sjlongland / log output
Created November 24, 2017 07:53
OpenThread with TI CC2538 getting stuck in transmit
DEBG]-PLAT----: State=OT_RADIO_STATE_SLEEP
[INFO]-PLAT----: PANID=FFFF
[INFO]-PLAT----: ExtAddr=225A619EFDB3976D
[INFO]-PLAT----: ShortAddr=FFFE
[DEBG]-PLAT----: Clear ShortAddr entries
[DEBG]-PLAT----: Clear ExtAddr entries
[DEBG]-MAC-----: SrcAddrMatch - Cleared all entries
[INFO]-PLAT----: Initialized
[DEBG]-PLAT----: State=OT_RADIO_STATE_SLEEP
[INFO]-PLAT----: PANID=FFFF
@sjlongland
sjlongland / Changes
Created November 24, 2017 08:50
Attempt at fixing problem
stuartl@vk4msl-ws ~/vrt/projects/widesky/hub/hal $ diff -u third_party/openthread/examples/platforms/cc2538/radio.c src/radio.c
--- third_party/openthread/examples/platforms/cc2538/radio.c 2017-08-01 12:48:31.466864595 +1000
+++ src/radio.c 2017-11-24 18:44:30.736663406 +1000
@@ -73,23 +73,20 @@
uint8_t mTxPowerReg;
} TxPowerTable;
-// The transmit power table, the values are from SmartRF Studio 2.4.0
+// The transmit power table, the values are from application note 130
static const TxPowerTable sTxPowerTable[] =
@sjlongland
sjlongland / gist:192f74feb04cbce7c5929c91021f2cfa
Created November 24, 2017 09:02
OpenThread CC2538 TX issue, possible fix
stuartl@vk4msl-ws ~/vrt/projects/widesky/hub/hal $ diff -u third_party/openthread/examples/platforms/cc2538/radio.c src/radio.c
--- third_party/openthread/examples/platforms/cc2538/radio.c 2017-08-01 12:48:31.466864595 +1000
+++ src/radio.c 2017-11-24 18:56:04.074493486 +1000
@@ -73,23 +73,20 @@
uint8_t mTxPowerReg;
} TxPowerTable;
-// The transmit power table, the values are from SmartRF Studio 2.4.0
+// The transmit power table, the values are from application note 130
static const TxPowerTable sTxPowerTable[] =
@sjlongland
sjlongland / radio.c mods
Created November 27, 2017 08:29
OpenThread CC2538 radio module bug investigation
stuartl@vk4msl-ws ~/vrt/projects/widesky/hub/hal $ diff -u third_party/openthread/examples/platforms/cc2538/radio.c src/radio.c
--- third_party/openthread/examples/platforms/cc2538/radio.c 2017-08-01 12:48:31.466864595 +1000
+++ src/radio.c 2017-11-27 15:09:30.067050133 +1000
@@ -73,23 +73,20 @@
uint8_t mTxPowerReg;
} TxPowerTable;
-// The transmit power table, the values are from SmartRF Studio 2.4.0
+// The transmit power table, the values are from application note 130
static const TxPowerTable sTxPowerTable[] =
@sjlongland
sjlongland / log
Created November 28, 2017 00:43
Attempt at overflow handling in readFrame…
[DEBG]-PLAT----: State=OT_RADIO_STATE_SLEEP
[INFO]-PLAT----: PANID=FFFF
[INFO]-PLAT----: ExtAddr=FE334F746B3E6F1E
[INFO]-PLAT----: ShortAddr=FFFE
[DEBG]-PLAT----: Clear ShortAddr entries
[DEBG]-PLAT----: Clear ExtAddr entries
[DEBG]-MAC-----: SrcAddrMatch - Cleared all entries
[INFO]-PLAT----: Initialized
[DEBG]-PLAT----: State=OT_RADIO_STATE_SLEEP
[INFO]-PLAT----: PANID=FFFF
@sjlongland
sjlongland / haystack2dot.py
Last active June 26, 2018 03:46
Visualising Project Haystack graphs using pyhaystack and graphviz
#!/usr/bin/env python
# Dump a Project Haystack tree to a graphviz `dot` file.
# Example usage:
# python haystack2dot.py --client-type widesky --client-uri http://localhost:8084 \
# --client-username user@example.com --client-password password \
# --client-id aaaaaaaa --client-secret bbbbbbbb \
# --filter 'equipRef==@vrtsofteng.db1_ac1 and (point or modbusBlock or modbusReserved)' \
# --filter 'device2Ref==@vrtsofteng.db1_ac1' \
# --filter 'device2Ref==@vrtsofteng.vrtems_gw' \
@sjlongland
sjlongland / connection.py
Last active December 17, 2017 23:31
Integrating bacpypes into tornado
# MeterMaster Data Access Layer
# (C) 2017 VRT Systems
#
# The following Software is the proprietary property of VRT Systems.
# Unauthorised disclosure or use of this Software is forbidden to the extent
# permitted by law.
#
# vim: set ts=4 sts=4 et tw=78 sw=4:
from threading import Event, Semaphore, Thread
@sjlongland
sjlongland / README.md
Created December 21, 2017 05:43
syslogd implementation for OpenThread

RFC 5424 compatible syslog implementation for OpenThread.

This requires:

  • a filesystem of some kind, with stubs for newlib's file I/O functions… we're using SPIFFS with a SPI EEPROM, but there are lots of options.
  • a real-time clock with an implementation of gettimeofday… we use a NXP PCF8523 I²C RTC to synchronise a software counter

If sending of a message fails (because buffers are full) and the message severity is high enough,