Git Product home page Git Product logo

cloudpets-web-bluetooth's Introduction

CloudPets Web Bluetoooth Demo

Blog post: Hacking Unicorns with Web Bluetooth

Live demo: here, works best with Chrome for Android or Chrome OS

The code in this repository uses the new Web Bluetooth feature in Chrome to demonstrate various features of the toy:

  1. Upload audio to the toy
  2. Trigger playback of uploaded audio
  3. Remotely trigger recording functionality
  4. Download recorded audio
  5. Make the heart LED flash

The toy has 5 audio 'slots'. Each slot can store around 40 seconds of audio. The toy itself always records to slot 1.

Important

For the demo to work, you must be within Bluetooth range of the device (around 10m). I shouldn't have to tell you that you must only connect to a CloudPet toy that you own. Connecting to someone else's one is illegal, so don't do that.

Live Demo

There's a cut-down live demo that can upload and play some pre-recorded audio. The demo doesn't have the server-side component to do the encoding and decoding. But it can upload a couple of pre-encoded clips. It can also trigger the recording (and play it back on the toy itself), and control the LED.

Python Server

The audio encoding/decoding functionality is done using a small Python Flask server. It uses ctypes to call into two native ARM libraries taken from the CloudPets APK to compress and decompress the audio. Since the libraries are native Android ARM binaries, the best place to run the server is on an Android device. You'll need to extract the libraries youself from the CloudPets APK and place them into the libs directory. I recommend using the excellent Termux Android app.

Once you've installed Termux run the following commands in its terminal:

apt install python git
pip install flask
git clone https://github.com/pdjstone/cloudpets-web-bluetooth.git
cd cloudpets-web-bluetooth
python cloudpets_server.py

Then open Chrome, and navigate to http://localhost:5000

Bugs and Notes

  • The code uses Chrome's new Web Bluetooth API to communicate with the toy. I've tested the code in Chrome for Android and on a Chromebook. Chrome for Android had a bug that affected the audio download feature. That bug is now fixed in Chrome Canary, and the Beta/main versions should pick it up in due course.
  • The toy uses Bluetooth LE, not classic Bluetooth therefore the it's fairly slow to upload and download the audio (it can take up to 30-40s for longer audio clips)
  • The compression/decompression libraries are compiled for 32-bit ARM. To get them working under Termux, you'll unfortunately to run them on a 32-bit Android device. I tried and failed to get a the 32-bit version of Python installed under Termux on a newer phone. If anyone knows how to make it work, please let me know.

cloudpets-web-bluetooth's People

Contributors

pdjstone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cloudpets-web-bluetooth's Issues

libaries?

Is it still possible to get the libMsAdpcm.so and libAudio32Encode.so libraries now that the cloudpets app is no longer available?
I've managed to get the cloudpets XAPK file but have no idea how to get the libraries after that

def download_audio(filename: str): Invalid Syntax

i am trying to run local server with python2.7 and getting this error.
File "cloudpets_server.py", line 64
def download_audio(filename: str):
SyntaxError: invalid syntax
And it is pointing to the filename: str

Cannot record new audio with phone

Using chrome 81 on Android 10, the web app (not the demo) doesn't record new audio and only sends the test audio to slot 2. Using audio recorded by the teddy results in an error.

Buffer size is < chunkSize, can't send
requestedSize is 0, why here? 
> Bluetooth Device disconnected 

Issues in Web Bluetooth --> Chrome is not finding any bluetooth devices in Android as well as WebChrome in Linux Issues

Dear Friends,
I'm using Web Bluetooth technology,I'm trying to connect an Android 6.0.1(Galaxy J7 prime) with an another Android device 6.0.1(Galaxy J5) in chrome (Version 60.0.311),it doest not scaning any device.
How do I list the nearby or paired Bluetooth devices on Chrome mobile for Android?
I searched Bluetooth device natively,it connected automatically and showed the list. But it does not search any device in Chrome.
I tried many sample Web Bluetooth Project,it's not scanning any devices on chrome browser as well as Android chrome browser. Give some working sample project.

This is for sample example ( https://dineshvasan.github.io/test/)
i have written for connecting bluetooth device for printing the text but it is not working. kindly check it whether i have made mistake in that code . kindly give me working solution for web bluetooth using service worker. i have referred all the website but it not working properly.

As well as i have enabled flag of enable-experimental-web-platform-features in chrome (chrome://flags/#enable-experimental-web-platform-features).

As well as i have attached log file and print picture device

As per my requirement to access the web bluetooth print the text using service worker.
Kindly do the Needful
Printer Name : Epson
Printer Model : Epson TM-P20

Operating System : Ubuntu 16.04

i am searching on my mobile in chrome android os version 6.01 this is that site given below (https://googlechrome.github.io/samples/web-bluetooth/device-info.html?allDevices=true ) even not finding another mobile device in Android chrome browser what that exact problem ...

`
20170821_153048

20170821_153102
`

I have shared log file.kindly find the attachment .

Kindly give me working sample of web bluetooth

btmon.btsnoop.tar.gz

CSRF

The exploit is vulnerable to Cross-site Request Forgery (CSRF). This is a common issue with Flask websites and can be fixed by using flask-wtf. While there aren't many interesting things an attacker can do using CSRF against this application (send an arbitrary file to ffmpeg with the hope of code execution), it seems worthwhile to fix it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.