Skip to content

Instantly share code, notes, and snippets.

View dominicgs's full-sized avatar

Dominic Spill dominicgs

View GitHub Profile
@dominicgs
dominicgs / set_bdaddr.sh
Created July 26, 2013 04:48
A script to change the address of a CSR Bluetooth dongle using bccmd. Example: # set_bdaddr.sh hci1 01 02 03 04 05 06
#!/bin/bash
#hci1 01:02:03:04:05:06
#bccmd -d hci1 psset bdaddr 04 00 06 05 03 00 02 01
CMD="bccmd -d $1 psset bdaddr $(($5)) 00 $(($7)) $(($6)) $(($4)) 00 $(($3)) $(($2))"
echo $CMD
$CMD
@dominicgs
dominicgs / piconet.py
Created March 3, 2016 22:10
Bluetooth hopping pattern implementation
#!/usr/bin/env python
# Copyright 2016 Dominic Spill, Michael Ossmann, Will Code
BT_NUM_CHANNELS = 79
class Piconet(object):
def __init__(self, address):
self.address = address
self.sequence = []
@dominicgs
dominicgs / wcid_test.py
Last active July 18, 2017 21:47
A simple script to test the WCIDs that I've been adding to our USB projects (https://github.com/pbatard/libwdi/wiki/WCID-Devices)
#!/usr/bin/env python3
from __future__ import print_function
import usb
import argparse
import sys
from usb.control import get_descriptor
def print_feature_descriptor(feat_desc):
@dominicgs
dominicgs / OSHPark_colour_mod.py
Created June 29, 2017 23:41
Remap OSH Park PCB preview images to other soldermask and silkscreen colours
#!/usr/bin/env python3
import argparse
import struct
from PIL import Image
if __name__ == "__main__":
colour_map = {
(193, 177, 203) : (193, 177, 203),# silkscreen
(197, 183, 208) : (197, 183, 208), # silkscreen + copper
/*
* Copyright 2016 Dominic Spill <dominicgs@gmail.com>
*
* This file is part of HackRF.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
#/usr/bin/env python3
import csv
class Pin(object):
def __init__(self, name, number):
self.name = name
if self.name.startswith('P'):
x = self.name.split('_')
self.port = x[0].strip('P')
Multiplexed digital pins
P0_0 L3 K3 G2 32 [2] N; I/O GPIO0[0] — General purpose digital input/output pin.
PU I/O SSP1_MISO — Master In Slave Out for SSP1.
I ENET_RXD1 — Ethernet receive data 1 (RMII/MII interface).
I/O SGPIO0 — General purpose digital input/output pin.
- R — Function reserved.
- R — Function reserved.
I/O I2S0_TX_WS — Transmit Word Select. It is driven by the master and received by the slave. Corresponds to the signal WS in the I 2 S-bus specification.
@dominicgs
dominicgs / shuffle.py
Created May 24, 2016 00:29
Perfect card shuffling example
#!/usr/bin/env python
decks = [range(1, 53)]
def shuffle(deck):
a = deck[:len(deck)/2]
b = deck[len(deck)/2:]
c = zip(a, b)
return c
@dominicgs
dominicgs / btle_crcgen.c
Created September 2, 2013 13:39
Script for generating and testing a look up table for the BTLE CRC
#include <stdio.h>
#include <stdint.h>
#define u8 uint8_t
#define u32 uint32_t
u32 btle_calc_crc(u32 crc_init, u8 *data, int len) {
u32 state = crc_init;
@dominicgs
dominicgs / .gitconfig
Last active December 18, 2015 09:49
My git config file - obviously the original has my name and email address in it.
[user]
email = email@example.com
name = John Doe
[color]
diff = auto
status = auto
branch = auto
interactive = auto
grep = auto