Skip to content

Commit 14c8800

Browse files
committed
current work. very basic ble in kivy using some of the gattlib interface.
1 parent 7a6f7fc commit 14c8800

14 files changed

+87
-4
lines changed

buildozer.spec

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[app]
2-
title = App
3-
package.name = test
4-
package.domain = xloem.github.com3
2+
title = Kivy Gattlib Demo
3+
package.name = kivygattlibdemo
4+
package.domain = xloem.github.com
55
source.dir = .
66
source.include_exts = py,png,jpg,kv,atlas
77
version = 0.1.7
8-
requirements = kivy,python3
8+
requirements = kivy,python3,gattlib-py
99
orientation = portrait
1010
osx.python_version = 3
1111
osx.kivy_version = 1.9.1
@@ -19,6 +19,7 @@ ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
1919
ios.ios_deploy_branch = 1.7.0
2020
#p4a.fork = xloem
2121
p4a.branch = develop
22+
p4a.local_recipes = recipes
2223

2324
[buildozer]
2425
log_level = 2

main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from kivy.app import App
44
from kivy.uix.label import Label
55

6+
print('Debug')
7+
68
import gattlib.adapter
79
import gattlib.device
810

recipes/gattlib-py/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from pythonforandroid.recipe import PythonRecipe, IncludedFilesBehaviour
2+
from pythonforandroid.toolchain import shprint, info
3+
from pythonforandroid.util import current_directory
4+
from pythonforandroid import logger
5+
import sh
6+
from glob import glob
7+
from os.path import join
8+
import os
9+
10+
class GattlibRecipe(IncludedFilesBehaviour, PythonRecipe):
11+
version = None
12+
url = None
13+
name = 'gattlib-py'
14+
site_packages_name = 'gattlib'
15+
16+
src_filename = 'src'
17+
18+
depends = ['pyjnius']
19+
call_hostpython_via_targetpython = False
20+
21+
def should_build(self, arch):
22+
return True # always rebuild?
23+
24+
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
25+
env = super().get_recipe_env(arch, with_flags_in_cc)
26+
# to find jnius and identify p4a
27+
env['PYJNIUS_PACKAGES'] = self.ctx.get_site_packages_dir()
28+
return env
29+
30+
def postbuild_arch(self, arch):
31+
super().postbuild_arch(arch)
32+
33+
info('Copying java files to dist_dir')
34+
35+
#destdir = join(self.ctx.bootstrap.dist_dir, 'src', 'main', 'java')
36+
#destdir = join(self.ctx.bootstrap.distribution.dist_dir, 'src', 'main', 'java')
37+
destdir = self.ctx.javaclass_dir
38+
#os.makedirs(destdir, exist_ok=True)
39+
40+
for path in glob(join(self.get_build_dir(arch.arch), 'gattlib', '*.java')):
41+
shprint(sh.cp, '-a', path, destdir)
42+
43+
recipe = GattlibRecipe()

recipes/gattlib-py/src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`gattlib-py` is a wrapper for `gattlib` library.

recipes/gattlib-py/src/TODO.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Add advertisement data
2+
3+
- Add C function to list BLE adapters
4+
- Add indication support

recipes/gattlib-py/src/gattlib/__init__.py

Whitespace-only changes.

recipes/gattlib-py/src/setup.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
import sys
3+
from setuptools import setup, find_packages
4+
import subprocess
5+
6+
# Retrieve version from GIT
7+
git_version_command = subprocess.Popen(['git', 'describe', '--abbrev=7', '--dirty', '--always', '--tags'],
8+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
9+
stdout, stderr = git_version_command.communicate()
10+
git_version = stdout.decode('utf-8').strip()
11+
12+
# Value from travis-ci
13+
if 'TRAVIS_TAG' in os.environ:
14+
git_version = os.environ['TRAVIS_TAG']
15+
elif 'TRAVIS_BUILD_ID' in os.environ:
16+
git_version = os.environ['TRAVIS_BUILD_ID'] + '-' + git_version
17+
18+
with open("README.md", "r") as fh:
19+
long_description = fh.read()
20+
21+
setup(
22+
name='gattlib-py',
23+
version=git_version,
24+
author="Olivier Martin",
25+
author_email="[email protected]",
26+
description="Python wrapper for gattlib library",
27+
long_description=long_description,
28+
long_description_content_type="text/markdown",
29+
url="https://github.com/labapart/gattlib/gattlib-py",
30+
packages=find_packages(),
31+
install_requires=['setuptools'],
32+
)

0 commit comments

Comments
 (0)