Skip to content

Instantly share code, notes, and snippets.

View davidgyoung's full-sized avatar

David G. Young davidgyoung

View GitHub Profile
// To compile this program, you need to install:
// sudo apt-get install libbluetooth-dev
// Then you can compile it with:
// cc scanner.c -lbluetooth -o scanner
// You can then run it with:
// ./scanner
// Copyright (c) 2021 David G. Young
// Copyright (c) 2015 Damian Kołakowski. All rights reserved.
// License: BSD 3. See: https://github.com/davidgyoung/ble-scanner
@davidgyoung
davidgyoung / gist:111d9b295a6df3a0c0acc1faaedf435f
Created September 11, 2018 21:15
How to make Android app transmit as a beacon
package com.davidgyoungtech.instantapptransmitter.feature;
import android.bluetooth.le.AdvertiseCallback;
import android.bluetooth.le.AdvertiseSettings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import org.altbeacon.beacon.Beacon;
import org.altbeacon.beacon.BeaconParser;
@davidgyoung
davidgyoung / merge-aar
Created December 14, 2016 21:25
shell script for merging two aar files
#!/bin/sh
MY_AAR_NAME="my-library" # Set this to whatever your aar looks like, e.g. my-library.aar
rm -rf build/outputs/aar/$MY_AAR_NAME
AAR_FILE=`ls build/outputs/aar/$MY_AAR_NAME*.aar | grep -v debug | head -1`
OS_AAR_FILE=`ls ./android-beacon-library/build/outputs/aar/*.aar | grep -v debug | head -1`
OS_AAR_TAR_GZ_FILE=`ls ./android-beacon-library/build/outputs/aar/*.gz | grep -v debug | head -1`
cp $OS_AAR_TAR_GZ_FILE build/outputs/aar/
cp $OS_AAR_FILE build/outputs/aar/
TARGZ_FILE=`echo "$AAR_FILE" | sed -e 's/aar/tar.gz/g'`
mkdir build/outputs/aar/$MY_AAR_NAME
@davidgyoung
davidgyoung / gist:21acbd3f3e555c29f125
Created July 5, 2015 20:21
Android Beacon Library Robolectric Plugin 1.0 build error
Davids-MacBook-Pro:android-beacon-library dyoung$ git status
On branch gelldur-master
nothing to commit, working directory clean
Davids-MacBook-Pro:android-beacon-library dyoung$ ./gradlew test
[buildinfo] Properties file path was not found! (Relevant only for builds running on a CI Server)
:preCompileDebugUnitTestJava
:compileDebugUnitTestJava
/Users/dyoung/workspace/android-beacon-library/src/test/java/org/altbeacon/beacon/AltBeaconParserTest.java:3: error: package org.junit does not exist
import static org.junit.Assert.assertEquals;
^
// Two classes:
// IBeaconSimulator
// SimulatedBeacon
IBeaconSimulator *CLBeaconSimulator [[IBeaconSimulator alloc] initWithLocationManger: locationManager];
[iBeaconSimulator addVisibleIBeacon: [[SimulatedBeacon] alloc] initWithUUID: @"2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6" major: 1 minor: 1 accuracy: 2.0]];
// an alternative to the above for more complex testing. This could alternatively set a delegate method
[iBeaconSimulator visibleIBeaconBlock: ^{
NSMutableArray *visibleIBeacons = [[NSMutableArray alloc] init];
echo 'running test script in /home/pi/test. may reboot' | wall
echo "starting run" >> /home/pi/test.log
for i in {1..10}; do
date >> /home/pi/test.log
/home/pi/usb_modeswitch_v_1_1_3 -I -W -D -s 20 -u -1 -v 12d1 -p 1446 -V 12d1 -P 1436 -c /home/pi/sakis3g-HEAD-4ee19e0/dependencies/usb-modeswitch-data/usb_modeswitch.d/12d1:1446
ls /dev/ttyU* >> /home/pi/test.log
ls /dev/ttyU* && ( echo "worked" >> /home/pi/test.log; sync; reboot; exit )
done
echo "failed" >> /home/pi/test.log
sync
pi@fpi-115 ~ $ sudo /basilisk/current/script/startup
Startup of beacon
Beacon software startup 172 seconds after boot
Server sync complete
/basilisk/current/lib/script_helper.rb:172:in `>': comparison of Time with nil failed (ArgumentError)
from /basilisk/current/lib/script_helper.rb:172:in `get_last_basilisk_run_time'
from /basilisk/current/lib/script_helper.rb:158:in `correct_time_from_logs'
from /basilisk/current/script/startup:25:in `<main>'