Coder Social home page Coder Social logo

stevensalazarm / termux-api-bluetooth Goto Github PK

View Code? Open in Web Editor NEW
63.0 4.0 7.0 378 KB

Extension of the Termux-API-package repository to allow usage of bluetooth

License: MIT License

Makefile 0.52% C 12.06% Shell 87.42%
termux termux-api bluetooth bluetooth-low-energy ble android

termux-api-bluetooth's Introduction

termux-api-package

Termux package containing scripts to call exposed API methods in the Termux:API app. The idea behind this package is to introduce bluetooth commands in the official termux-api-package in order to call methods of a modified version of Termux:API, you can find two java classes BluetoothAPI and BluetoothLowEnergyAPI (this one under the branch dev-ble) in Termux-app-bluetooth. The repository just mentioned is a modified version of an old version of the Termux project (Termux-app-bluetooth is not official).

In order to allow bluetooth function calls I modified the shell Termux-API repository, two possible shell calls were added in scripts directory: termux-bluetooth-scaninfo and termux-bluetooth-connect (ignore termux-enable-buttons).

The command termux-bluetooth-scaninfo is used to call the functions startDiscovery and cancelDiscovery from the BluetoothAdapter java class.

The command termux-bluetooth-connect is used to call a function that has an empty implemetation (for now), you can decide what it should do by introducing your code in the function onReceiveBluetoothConnect.

A BluetoothAPI class was added in Termux:API android-java repository. Futhermore, TermuxApiReceiver class was modified in order to make the application call the functions to scan and connect.

The implementation of connect is still missing and you can also modify the behaviour of scaninfo by writing your own java code in BluetoothAPI.

In addition to the BluetoothAPI class it was introduced also another class BluetoothLowEnergyAPI. This class is under the dev-ble branch and it hasnt been merged to master due to the lack of bluetooth low enegery devices for testing.

Usage

Build and generate the APK

  1. Clone the project in termux-app-bluetooth
  2. Generate your own apk from the code
  3. Install the apk generated
  4. Open the application and wait for the termux console to be installed (it downloads the binary of termux-api-package available here)
  5. Open Termux console by clicking on the button (check screenshots directory)
  6. Type termux-bluetooth-scaninfo and give the permissions
  7. Type termux-bluetooth-scaninfo again to start to scan bluetooth devices
  8. Type termux-bluetooth-scaninfo again to stop the scanning (remember to stop the scanning otherwise a broadcast receiver will stay alive) and print the results.

Usage from APK released here

  1. Download termux-app-bluetooth.apk
  2. Install the apk generated (you may need to disable PlayProtect)
  3. Open the application and wait for the termux console to be installed (it downloads the binary of termux-api-package available here)
  4. Open Termux console by clicking on the button (check screenshots directory)
  5. Type termux-bluetooth-scaninfo and give the permissions
  6. Type termux-bluetooth-scaninfo again to start to scan bluetooth devices
  7. Type termux-bluetooth-scaninfo again to stop the scanning (remember to stop the scanning otherwise a broadcast receiver will stay alive) and print the results.

Usage example

At the moment it shows only devices name but you can add more info to be printed.

Possible Problem

If you are getting message below probably you used a command inside termux console that required to update or install a package.

E: This installation run will require temporarily removing the essential package libandroid-support:aarch64 due to a Conflicts/Pre-Depends loop. This is often bad, but if you really want to do it, activate the APT::Force-LoopBreak option.
E: Internal Error, Could not early remove libandroid-support:aarch64 (2)

The reason of the problem can be found in Termux-Package issue 4129.

Hmm, there happens following:

  • Few months ago iconv() implementation was moved from libandroid-support to libiconv. But since old libandroid-support provides libiconv.so symlink used by essential utilities (like coreutils), package libiconv can't be installed.
  • Now busybox was replaced by separate packages which makes coreutils to be required for installation. So here a conflict loop starts to happen.

Thus, since the apk in Termux-app-bluetooth is based on the version 0.64 of the Termux project you must install a more recent version of it.

However, after September when I get some free time, I will try to work on a new version of Termux-app-bluetooth that supports update or installation of packages.

Contact

If you have any question (or problem) feel free to post it in Issues section or contact me at [email protected]

termux-api-bluetooth's People

Contributors

stevensalazarm 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  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  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

termux-api-bluetooth's Issues

How to build and generate the APK?

Hi StevenSalazarM,
I really enjoy this Termux-api-bluetooth project. Thank you very much.
However I don't know how to emerge this project to the newest termux apk (ver. 0.102).
I tried to copy termux-api.c to /data/data/com.termux/files/usr/libexec/, copy termux-bluetooth-connect and termux-bluetooth-scaninfo to /data/data/com.termux/files/usr/bin/. This doesn't work.

Can you teach me how to finish it? Many thanks.

bluetooth playback events

There is currently no way to react to events generated by hardware buttons on connected bluetooth devices, is there? For example, detect play/start/stop events from bluetooth headphones?

Thank you.

Usage?

Not really an issue, but I'm clueless about using it :)
I unzipped a compiled release in Termux and tried to launch "locally" the termux-api with arguments (of course it was not intended to be used like that, but at least I tried...).
Can you point me to the right direction - how to include these in the termux-api apk or other method to include your changes to the program on the Android phone application?
I was waiting for a way to connect to bluetooth devices from Termux for a long time, apparently it is not a priority for the developers for now...
Thanks,
Constantin

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.