We usually use the bash command line to configure the BBGw Bluetooth, so that it can be connected to other Bluetooth devices (if you do not know how to use the bash command line configuration, click here to view the tutorial). But today, we will try to use the python-flask framework on the BBGw to build a small server, and to generate a page to configure the Bluetooth. Hope you can get inspiration from this simple tutorial, we look forward to your excellent works！
Please connect your BBGw to wifi first , and switch to the root account.
$apt-get install python-virtualenv
If it fail to install,please ‘apt-get update’ first and retry.
Create your environment under absolute path directory /home/debian/bin
$ cd /home/debian/bin
$ mkdir myproject
$ cd myproject
$ mkdir templates
$ virtualenv venv
Active your ‘venv’environment ,and install the following python package
$ . venv/bin/activate
$ pip install Flask
$ pip install pexpect
$ pip install flask-socketio
Copy app.py and bluetoothtest.py to absolute path directory /home/debian/bin/myproject (from your u disk or nfs server),and copy index.html to absolute path directory /home/debian/bin/myproject/templates
Mount your u disk or nfs server which contains the following file
$ cp app.py /home/debian/bin/myproject
$ cp bluetoothtest.py /home/debian/bin/myproject
$ cp index.html /home/debian/bin/myproject/templates
Visit 192.168.x.x:5000. 192.168.x.x means your BBGw’s IP,you can view it with bash command ‘ifconfig’. Also you computer needs to be in this local area network .
Enter your device’s bluetooth mac address(such as your bluetooth earphone) ,click ‘pair’.Wait about 10 seconds.
Then you will receive the result.