Exemplo n.º 1
0
if __name__ == '__main__':
    # Create option parser
    usage = "usage: %prog [options] arg"
    parser = argparse.ArgumentParser()
    parser.add_argument("--output",
                        dest="output_format",
                        default="json",
                        help="set output format: csv, json")

    args = parser.parse_args()

    # Create a BT server
    uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"
    service_name = "BTServer"
    server = BTServer(uuid, service_name)

    # Create the server thread and run it
    server_thread = Thread(target=asyncore.loop, name="BT Server Thread")
    server_thread.daemon = True
    server_thread.start()

    # epochtime = datetime.now().strftime('%Y-%m-%d %H:%M:%S') #(int)(time())

    neo = Gpio()

    gpiopins = [8, 9, 10, 11]
    gpio = Gpio()

    pinnum = [0, 0, 0, 0]
Exemplo n.º 2
0
                        help="set output format: csv, json")
    parser.add_argument("--database",
                        dest="database_name",
                        default="air_pollution_data.db",
                        help="specify database file")
    parser.add_argument("--baud-rate",
                        dest="baud_rate",
                        default="115200",
                        help="specify Bluetooth baud rate in bps")

    args = parser.parse_args()

    # Create a BT server
    uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"
    bt_service_name = "Air Pollution Sensor"
    bt_server = BTServer(uuid, bt_service_name)

    # Create BT server thread and run it
    bt_server_thread = Thread(target=asyncore.loop, name="BT Server Thread")
    bt_server_thread.daemon = True
    bt_server_thread.start()

    # Create sensor server thread and run it
    sensor_server = SensorServer(database_name=args.database_name)
    sensor_server.daemon = True
    sensor_server.start()

    # Create database connection and retrieve its cursor
    try:
        db_conn = sqlite3.connect(args.database_name)
        db_cur = db_conn.cursor()
Exemplo n.º 3
0
    parser = argparse.ArgumentParser()
    parser.add_argument("--output",
                        dest="output_format",
                        default="csv",
                        help="set output format: csv, json")
    parser.add_argument("--database",
                        dest="database_name",
                        default="air_pollution_data.db",
                        help="specify database file")

    args = parser.parse_args()

    # Create a BT server
    uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"
    bt_service_name = "Air Pollution Sensor"
    bt_server = BTServer(uuid, bt_service_name)

    # Create the server thread and run it
    bt_server_thread = Thread(target=asyncore.loop,
                              name="Gossip BT Server Thread")
    bt_server_thread.daemon = True
    bt_server_thread.start()

    sensor_server = SensorServer(database_name=args.database_name)
    sensor_server.daemon = True
    sensor_server.start()

    try:
        db_conn = sqlite3.connect(args.database_name)
        db_cur = db_conn.cursor()
    except Exception as e:
Exemplo n.º 4
0
 def __init__(self):
     self.router = Router()
     self.btserver = BTServer(self.router)
     self.btserver.listen()
     self.server = http_server(self.router)
Exemplo n.º 5
0
#!/usr/bin/python

from socketdelegate import SocketConnection
from btserver import BTServer
from btserver import BTClient

if __name__ == "__main__":
	connection = SocketConnection("0.0.0.0", 6600)
	print(connection.read())

	btserver = BTServer()
	btserver.listen()

	btserver.advertiseServices()

	while True:
		btclient = btserver.acceptClient()

		while True:
			readData = btclient.read()
			print("Read from bluetooth %s" % readData)
			connection.send(readData)
			response = connection.read()
			print("Read from network: %s" % response)
			btclient.send(response)