Skip to content

Instantly share code, notes, and snippets.

View maxgibbons's full-sized avatar

Max Gibbons maxgibbons

View GitHub Profile
@maxgibbons
maxgibbons / rest2m2x.py_addition
Last active August 24, 2016 19:26
rest2m2x.py Additional Parser
# ---------------------------------------------------------------------------------------------------
# Temp/Humidity (ARDUINO Serial)
# This bit calls the new parser and also parses the serial payload into segments for M2X. It grabs the serial
# string from an arduino and parses it into chunks delineated by the '_' character. Then it formats/sanitizes
# the separate strings into numeric characters for M2X ingest.
# Each segment can be called by using text[0] (first segment) text[1] (second segment) and so on.
# NOTE: You can set the M2X stream data type to numeric with this parser.
# ---------------------------------------------------------------------------------------------------
elif dev_info['parser'] == 'serial_m2x': # Referencing the appropriate parser over in /parsers.py
print '\nBegin parsing ULSDU at %s with: serial_m2x, sdu_id %s \nnodeId %s rx_timestamp %s payload
@maxgibbons
maxgibbons / parsers.py_addition
Created August 24, 2016 18:57
Parsers.py Additon
#------------------------------------------------------------------------------
# Temp/Humidity Arduino
# APP_INTF7 Application UART A_UART_RX J207 pin 7
# Sample of a serial-based Arduino-to-rACM setup. Add additional sensor inputs
# under 'expectedSensors'. Since we're sending all sensor data to rACM as a single
# serial string all sensorIds are '6' and sensorType is '0xFFF'. sensorName should
# correspond with your M2X stream names.
#------------------------------------------------------------------------------
def parser_serial_m2x(raw_hex):
expectedSensors = [{'sensorId': 6, 'sensorType':0xFFF, 'sensorName':'humidity',\
@maxgibbons
maxgibbons / createDevices.py_segment
Created August 24, 2016 18:43
createDevices.py Device Add
devices = [
{'desc':'Arduino-rACM', // whatever you feel like
'nodeId':'0x3451f', // add your Node ID here
'parser':'serial_m2x', // let's reference the parser we'll create
'm2x_device_id': 'z547acf8d450fc94863a5b7b498b6135', // grab from M2X
'm2x_primary_key':'n0b9b4d39c1bb86e733f37b62c666128', // same
'alarm_email_enabled':0,
'alarm_email_list':[]},
@maxgibbons
maxgibbons / rACM_configure_serial
Created August 23, 2016 23:34
rACM Configure for Serial Passthrough
python host_app_ctrl.py -d /dev/tty.usbserial-FTFMFMP8 SET_FIELD_CONFIG /Users/mgibbons/Desktop/rACM/rACM_Config_Files/host_app_field_cfg_serialPort.txt
@maxgibbons
maxgibbons / rACM_get_device_status_output
Created August 23, 2016 23:32
rACM Get Device Status Output
username$ python host_app_ctrl.py -d /dev/tty.usbserial-FTFMFMP8 GET_DEVICE_STATUS
Device ID = 00000001 (0x00000001)
Node ID = 0x0003451F
Node Type = UNODE
Comm System = COMM_SYS_2.X
Device state = DEPLOYED
Application Profile = UNSECURED_POWERED
POR Host UART State = TEST_OVERRIDE
Alarm Hysteresis = 300 (sec)
UART Timeout = 8 (sec)
@maxgibbons
maxgibbons / rACM_get_device_status_command
Created August 23, 2016 23:32
Get rACM Device Status Command
python host_app_ctrl.py -d /dev/tty.usbserial-FTFMFMP8 GET_DEVICE_STATUS
@maxgibbons
maxgibbons / get_serial_id
Created August 23, 2016 23:29
Get Serial Device ID
username$ ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port
/dev/tty.Brain-WirelessiAP
/dev/tty.SuperBrain-WirelessiAP
/dev/tty.usbmodem141321
/dev/tty.usbserial-FTFMFMP8
@maxgibbons
maxgibbons / temp_humid.ino
Last active August 23, 2016 23:28
Arduino Temp + Humidity to rACM
#include // My Yun's serial ports were all used up (one for USB, the other for the bridge)
#include // So we can talk to the DHT11
// Let's learn how to read temp/humidity
SoftwareSerial port2(10, 11); // Define which digital pins we'll use for serial and give them a name
// Imperial Measurement FTW
double Fahrenheit(double celsius)
{