1*0c4cc577SMatthias Ringwald#!/usr/bin/env python3 2*0c4cc577SMatthias Ringwald 3*0c4cc577SMatthias Ringwaldfrom btstack import btstack_server, btstack_client 4*0c4cc577SMatthias Ringwald 5*0c4cc577SMatthias Ringwalddef packet_handler(packet): 6*0c4cc577SMatthias Ringwald print("received packet") 7*0c4cc577SMatthias Ringwald print(packet) 8*0c4cc577SMatthias Ringwald 9*0c4cc577SMatthias Ringwald# Conrtrol for BTstack Server 10*0c4cc577SMatthias Ringwaldbtstack_server = btstack_server.BTstackServer() 11*0c4cc577SMatthias Ringwald 12*0c4cc577SMatthias Ringwald# start BTstack Server from .dll 13*0c4cc577SMatthias Ringwaldbtstack_server.load() 14*0c4cc577SMatthias Ringwald# btstack_server.set_storage_path("/tmp") 15*0c4cc577SMatthias Ringwaldbtstack_server.run_tcp() 16*0c4cc577SMatthias Ringwald 17*0c4cc577SMatthias Ringwald 18*0c4cc577SMatthias Ringwald# Client for BTstack Server 19*0c4cc577SMatthias Ringwaldbtstack_client = btstack_client.BTstackClient() 20*0c4cc577SMatthias Ringwald 21*0c4cc577SMatthias Ringwald# connect to slient, register for HCI packets and power up 22*0c4cc577SMatthias Ringwaldbtstack_client.connect() 23*0c4cc577SMatthias Ringwaldbtstack_client.register_packet_handler(packet_handler) 24*0c4cc577SMatthias Ringwaldbtstack_client.btstack_set_power_mode(1) 25*0c4cc577SMatthias Ringwaldbtstack_client.run() 26