This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This is an a generic payload parser for LoRaWAN. It will work for any network server. | |
** The code find the "payload" variable, sent by your sensor, and parse it if exists. | |
** The content of payload variable is always an Hexadecimal value. | |
** | |
** Note: Additional variables can be created by the Network Server and sent directly to the bucket. Normally they aren't handled here. | |
** | |
** Testing: | |
** You can do manual tests to the parse by using the Device Emulator. Copy and Paste the following JSON: | |
** [{ "variable": "data", "value": "0109611395" }] | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function to decode Helium's uplink data from RAK7204 device. | |
// Data are in LPP Cayenne format (RUI: RAK Unified Interface) and converted to Ubidots JSON format as expected. | |
// Decoder decodes an array of bytes and uplink_info into an object. | |
// - port contains the LoRaWAN fPort number | |
// - bytes is an array of bytes, e.g. [225, 230, 255, 0] | |
// - uplink_info contains data from the device treated by the Helium router, e.g. { app_eui: <app_eui>, fcnt: <integer>, reported_at: <timestamp> } | |
// The function must return an object, e.g. { "temperature": { "value": <float>, "timestamp": <timestamp>} } | |
function Decoder(bytes, port, uplink_info) { | |
var decoded = {}; | |
var hexString = bin2HexStr(bytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import requests | |
TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID') | |
TWILIO_CLIENT_ID = os.environ.get('TWILIO_CLIENT_ID') | |
TWILIO_CLIENT_SECRET = os.environ.get('TWILIO_CLIENT_SECRET') | |
TWILIO_SMS_URL = 'https://api.twilio.com/2010-04-01/Accounts/' \ | |
+ TWILIO_ACCOUNT_SID + '/Messages.json' | |
TWILIO_ASSIGNED_NUMBER = os.environ.get('TWILIO_ASSIGNED_NUMBER') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import requests | |
FREE_PASS =os.environ.get("FREE_PASS") | |
FREE_ACCOUNT=os.environ.get("FREE_ACCOUNT") | |
def lambda_handler(event, context): | |
sms_request = 'https://smsapi.free-mobile.fr/sendmsg?pass=' + FREE_PASS + '&user=' + FREE_ACCOUNT +'&msg=' + event['Records'][0]['Sns']['Message'] | |
print(event) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import ssl | |
import time | |
import datetime | |
import json | |
import logging, traceback | |
import paho.mqtt.client as mqtt | |
IoT_protocol_name = "x-amzn-mqtt-ca" | |
aws_iot_endpoint = "XXXXXXXXXX-ats.iot.us-west-2.amazonaws.com" # <random>.iot.<region>.amazonaws.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import ssl | |
import time | |
import datetime | |
import logging, traceback | |
import paho.mqtt.client as mqtt | |
IoT_protocol_name = "x-amzn-mqtt-ca" | |
aws_iot_endpoint = "XXXXXX-ats.iot.us-west-2.amazonaws.com" # <random>.iot.<region>.amazonaws.com | |
url = "https://{}".format(aws_iot_endpoint) |