Skip to content

Instantly share code, notes, and snippets.

View towynlin's full-sized avatar

Zachary Crockett towynlin

View GitHub Profile
@towynlin
towynlin / 2021-03-12-ble-trace-logs-time-overrun-error.txt
Last active March 13, 2021 01:08
STM32WB55 BLE Trace Log in which twice occurs HCI_HARDWARE_ERROR_EVENT event_time_overrun
[tl_mbox.c][OutputDbgTrace][830] sys evt: 0xFF
[tl_mbox.c][OutputDbgTrace][831] subevtcode: 0x9200
[tl_mbox.c][OutputDbgTrace][834] payload: 00
[tl_mbox.c][OutputDbgTrace][839]
[tl_mbox.c][OutputDbgTrace][785] sys cmd: 0xFC68
[tl_mbox.c][OutputDbgTrace][789] payload: 98 DE 02 08 E4 01 03 20 E0 01 03 20 22 04 04
[tl_mbox.c][OutputDbgTrace][792]
@towynlin
towynlin / set-pebble-time.py
Created July 5, 2019 07:29
I just wanted to set the time on my pebble, but there's no more app on the play store. So, after some fun searching, reading, learning, trial, and error...
import sys
import time
from libpebble2.communication import PebbleConnection
from libpebble2.communication.transports.serial import SerialTransport
from libpebble2.protocol.base import PebblePacket
from libpebble2.protocol.base.types import *
from libpebble2.protocol.system import *
pebble = PebbleConnection(SerialTransport(sys.argv[1])) # argument like /dev/cu.Pebble...
pebble.connect()
@towynlin
towynlin / multicast-demo.ino
Created November 30, 2016 07:39
Multicast demo between several Photons on the same local network
const int multicastPort = 23232;
const IPAddress multicastAddress(233,252,1,64);
UDP udp;
char buf[100];
void setup() {
udp.begin(multicastPort);
udp.joinMulticast(multicastAddress);
}
@towynlin
towynlin / spark-aes-encryption-demo.ino
Created July 31, 2014 00:07
Demo Spark Core firmware using AES-128-CBC
void sixteenRandomBytes(unsigned char buf[16]) {
for (int i = 0; i < 16; i++) {
buf[i] = rand() & 0xff;
}
}
// PKCS #7 padding
// Do this before encrypting to get the message
// up to a multiple of 16 bytes.
size_t pad(unsigned char *buf, size_t messageLength) {
@towynlin
towynlin / ip_and_mac_vars.ino
Created April 18, 2014 07:10
Exposing the IP and MAC address of a Spark Core using Spark.variable()
char ipString[16];
char macString[18];
void setup() {
Spark.variable("ip", ipString, STRING);
Spark.variable("mac", macString, STRING);
byte mac[6];
Network.macAddress(mac);
sniprintf(macString, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
@towynlin
towynlin / application.cpp
Created January 20, 2014 03:38
Spark firmware for setting RGB LED color using the Spark Tinker mobile app's analogWrite on pins A4, A5, and A6.
// Default to pinkish
int redValue = 255;
int greenValue = 33;
int blueValue = 121;
int countdown;
void showColor() {
RGB.control(true);
RGB.color(redValue, greenValue, blueValue);
@towynlin
towynlin / spark_core_id_listener
Created December 16, 2013 23:34
ruby listener for Spark Core multicast presence announcement
require 'socket'
require 'ipaddr'
MULTICAST_ADDR = '224.0.1.187'
PORT = 5683
ip = IPAddr.new(MULTICAST_ADDR).hton + IPAddr.new('0.0.0.0').hton
sock = UDPSocket.new
sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
@towynlin
towynlin / rc-car.c
Created May 28, 2013 03:31
Spark embedded application code (like Arduino/Wiring code) to drive an RC car with the Spark API.
#include <stdlib.h>
// Motor shield instructions (set control mode jumpers to PWM mode)
// http://www.dfrobot.com/wiki/index.php?title=Arduino_Motor_Shield_(L298N)_(SKU:DRI0009)
#define LEFT A7 // Motor Shield E1, Arduino D6
#define RIGHT D1 // Motor Shield E2, Arduino D5
void setup()
{
@towynlin
towynlin / _debug-info.md
Last active December 14, 2015 23:49
wireshark failed to build on 10.8.3

HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install wireshark

==> Downloading http://www.wireshark.org/download/src/wireshark-1.8.6.tar.bz2
Already downloaded: /Library/Caches/Homebrew/wireshark-1.8.6.tar.bz2
tar xf /Library/Caches/Homebrew/wireshark-1.8.6.tar.bz2
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/wireshark/1.8.6 --without-python --disable-wireshark
./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/wireshark/1.8.6 --without-python --disable-wireshark
checking build system type... i386-apple-darwin12.3.0
checking host system type... i386-apple-darwin12.3.0
@towynlin
towynlin / a-b.diff
Last active September 30, 2015 02:50
Getting Particle Devices to have Identical Firmware
1482c1482
< 0005c90: 0b50 686f 746f 6e2d 4342 4558 ffff ffff .Photon-CBEX....
---
> 0005c90: 0b50 686f 746f 6e2d 4433 3235 ffff ffff .Photon-D325....
1499,1537c1499,1537
< 0005da0: 025f 0201 0002 8181 00c2 b20a 811d 8590 ._..............
< 0005db0: e3da cdc5 3295 4159 76e2 4b56 6a49 4489 ....2.AYv.KVjID.
< 0005dc0: 1c70 3fb1 5690 bf14 a3be 80b8 cd2b dcfd .p?.V........+..
< 0005dd0: d36d 8b65 382a baec c664 a7ea d47c 6e01 .m.e8*...d...|n.
< 0005de0: 205e 7816 af6b 8d3a 4ea9 59cc ca96 e932 ^x..k.:N.Y....2