Skip to content

Instantly share code, notes, and snippets.

View blindman2k's full-sized avatar

Aron Steg blindman2k

  • Launch Systems Pty Ltd
  • Melbourne, Australia
View GitHub Profile
/* 9 Degrees of Freedom Sensor Tail Firmware
* Uses LSM9DS0 IMU from ST
* http://www.adafruit.com/datasheets/LSM9DS0.pdf
*/
const XM_ADDR = 0x3C; // 8-bit I2C Student Address for Accel / Magnetometer
const G_ADDR = 0xD4; // 8-bit I2C Student Address for Angular Rate Sensor
const READING_INTERVAL = 1; // seconds between readings
/* CLASS AND GLOBAL FUNCTION DEFINITIONS ------------------------------------ */
@blindman2k
blindman2k / README.md
Last active August 29, 2015 14:15
Demonstration of some different ways of authenticating a http request using a static shared key.

Securing Electric Imp agents acting as API providers

There are a myriad of different ways to secure requests to agent URLs. By default, all requests have three simple security features:

  1. the unique URL for each device is randomly generated during the BlinkUp process;
  2. the commands required to activate the agent are unknown to anyone but the developers; and
  3. all requests to https://agent.electricimp.com are SSL encrypted which prevents anyone from sniffing the contents of any request.

For many applications, this encryption plus obfuscation is sufficient security, especially if the requests to the agent are coming from a server or a controlled application. If further security/obfuscation is required we propose a few simple and common methods here. These methods also provide a bonus feature that, if the security is compromised at any point in the future, the parameters can be easily changed to reassert the security.

@blindman2k
blindman2k / README.md
Last active August 29, 2015 14:18
Impeeduino (Arduino/Imp hybrid) audio spectrum display. https://youtu.be/C84TlH6OFyE

This was the result of a fun hackathon project at Electric Imp. I turned a NeoPixel ring and an Impeeduino (Arduino and Imp hybrid) into a basic audio spectrum display. The video can be seen on YouTube.

  1. The arduino code is responsible for reading audio data from the microphone, running a fast fourier transform on the data captured to product a spectrum and then handing it off to the Imp device code via UART.
  2. The agent code is responsible only for assisting with the programming of new Arduino code and could be done with the Arduino IDE directly.
  3. The device code is responsible for reading the spectrum data and displaying the animation on the NeoPixels.

This code is provided without warantee or support because I can't remember much about it.

#require "Rocky.class.nut:1.1.1"
class RockyII extends Rocky {
function _addAccessControl(res) {
res.header("Access-Control-Allow-Origin", "*")
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, PATCH, DELETE");
res.header("Access-Control-Expose-Headers", "X-ImpBase-Version");
}
}
@blindman2k
blindman2k / README.md
Last active August 29, 2015 14:23
SPIFlashLogger class - Uses a provided SPI flash class or the imp003+'s built-in SPI flash class to turn part of the SPI flash into a rotating log (first in, first out) of serialised objects.

SPI Flash Logger class

Introduction

The SPI Flash Logger class manages all or a portion of a SPI flash (either via imp003+'s built-in SPI flash driver or any functionally compatible driver) and turns it into an logger. It will log any serialisable object (table, array, string, blob, integer, float, boolean and null) and when it reaches the end of the available space it will override the oldest data first.

NOR-flash technology

@blindman2k
blindman2k / README.md
Last active August 29, 2015 14:23
SPIFlash - A new SPI flash class designed to be fully compatible with hardware.spiflash (https://electricimp.com/docs/api/hardware/spiflash/)
@blindman2k
blindman2k / spiflashfs.device.nut
Last active January 18, 2016 14:53
Updated SPI Flash File System with 4kb pages and no lookup tables or indices, just data pages with small headers.
/*
The physical space is divided into blocks (64k) and sectors (16k).
Erase (wiping 0's to 1's) is performed at the sector level.
The file system divides the available space into pages which the size of one or more sectors.
At the start of every spage is an header which contains:
- the file's id (two bytes) for identifying and rejoining parts of a file
- the span id (two bytes) for ordering the parts
- an optional filename (with length byte)
- the span's size (how much of the page is used)
// Copyright (c) 2015 Initial State Technologies, Inc.
// This file is licensed under the MIT License
// http://opensource.org/licenses/MIT
class InitialState {
static version = [1,0,0];
_bucketKey = null;
_accessKey = null;
@blindman2k
blindman2k / LICENSE
Last active February 15, 2016 05:00
GoogleMaps Class for Electric Imp
The MIT License (MIT)
Copyright (c) 2015 Electric Imp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The MIT License (MIT)
Copyright (c) 2016 Electric Imp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: