Shreyas KishoreAnanay Arora
Published © GPL3+

MetroBand

MetroBand is a wearable that makes Metro commute far easier and smarter.

IntermediateShowcase (no instructions)Over 4 days687
MetroBand

Things used in this project

Hardware components

RFID Module
Tessel RFID Module
×1
RF antenna
×1

Software apps and online services

ARTIK Cloud for IoT
Samsung ARTIK Cloud for IoT

Story

Read more

Code

Transmitting data from the MetroBand to the ARTIK Cloud

Python
import artikcloud
from artikcloud.rest import ApiException
import sys, getopt
import time, random, json
from pprint import pprint


def main(argv):

	DEFAULT_CONFIG_PATH = 'config.json'
  idnum = 100035  #unique band id
  destination_code = 73  #station code of the destination station
	with open(DEFAULT_CONFIG_PATH, 'r') as config_file:
		config = json.load(config_file)['metroBeaconSensor']
	print(config)
	
	artikcloud.configuration = artikcloud.Configuration();
	artikcloud.configuration.access_token = config['deviceToken']
  
	api_instance = artikcloud.MessagesApi()

	device_message = {}

	device_message['band_id'] = idnum
	device_message['dest'] = destination_code

	device_sdid = config['deviceId']

	ts = time.time()

	data = artikcloud.Message(device_message, device_sdid, ts)

	try:
	    pprint(artikcloud.configuration.auth_settings())

	    api_response = api_instance.send_message(data)
	    pprint(api_response)
	except ApiException as e:
	    print "Exception when calling MessagesApi->send_message: %s\n" % e


if __name__ == "__main__":
   main(sys.argv[1:])

Receive data from ARTIK Cloud

Python
import artikcloud
from artikcloud.rest import ApiException
import sys, getopt
import time, random, json
from pprint import pprint

def main(argv):

	DEFAULT_CONFIG_PATH = 'config.json'

	with open(DEFAULT_CONFIG_PATH, 'r') as config_file:
		config = json.load(config_file)['metroBeaconSensor']
	print(config)

	artikcloud.configuration = artikcloud.Configuration();
	artikcloud.configuration.access_token = config['deviceToken']

	api_instance = artikcloud.MessagesApi()

	sdids = config['band_id'] 
	try:
	    pprint(artikcloud.configuration.auth_settings())
	    api_response = api_instance.get_last_normalized_messages(sdids=sdids)
	    pprint(api_response)
	except ApiException as e:
	    print "Exception when calling MessagesApi->get_last_normalized_messages: %s\n" % e


if __name__ == "__main__":
   main(sys.argv[1:])

MetroBand Repository

Credits

Shreyas Kishore

Shreyas Kishore

2 projects • 4 followers
Ananay Arora

Ananay Arora

1 project • 0 followers

Comments