# test BLE Scanning software
# jcs 6/8/2014

import blescan
import sys

import bluetooth._bluetooth as bluez

dev_id = 0

#beacon data sava class : made Deuk
class beacons:
	def __init__(self, devName, RSSI, TX):
		self.devName = devName
		self.RSSI = RSSI
		self.TX = TX
	
	def distance(self, RSSI, TX):
		return (10 ** ((float(TX) - float(RSSI))/(10 * 2))) 

try:
	sock = bluez.hci_open_dev(dev_id)
	print ("ble thread started")

except:
	print ("error accessing bluetooth device...")
	sys.exit(1)

blescan.hci_le_set_scan_parameters(sock)
blescan.hci_enable_le_scan(sock)

while True:
	returnedList = blescan.parse_events(sock, 10)
	print ("----------")
	for beacon in returnedList:
		print(beacon)
