GithubHelp home page GithubHelp logo

wolkabout / wolkgatewaymodule-bluetooth Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 586 KB

WolkAbout Gateway module for connecting bluetooth devices to WolkAbout Gateway.

License: Apache License 2.0

CMake 7.75% Shell 1.89% C++ 90.36%
bluetooth bluetooth-low-energy ble gateway iot bluez bluez-dbus raspberry-pi-3

wolkgatewaymodule-bluetooth's Introduction

WolkGatewayModule-Bluetooth

WolkAbout Gateway module for connecting bluetooth devices to WolkAbout Gateway. This module was tested on Raspberry Pi 3 Model B+ running Raspbian. It should work on any bluetooth enabled Linux device as it uses Bluez - the default Linux bluetooth stack. It uses the hci0 bluetooth adapter.

Supported protocol(s):

  • JSON_PROTOCOL

Installing from source

This repository must be cloned from the command line using:

git clone --recurse-submodules https://github.com/Wolkabout/WolkGatewayModule-Bluetooth.git

Prerequisite

Following tools/libraries are required in order to build this project:

  • cmake - version 3.5 or later
  • g++
  • autotools
  • autoconf
  • libtool
  • m4
  • zlib1g-dev
  • libssl-dev
  • libglib2.0-dev
  • bluez - version 5.5

With the exception of bluez the former can be installed on Debian based system from terminal by invoking

sudo apt-get install g++ autotools-dev autoconf libtool m4 zlib1g-dev cmake libssl-dev libglib2.0-dev

To install bluez 5.5 with all it's dependencies you can run the

install_bluez.sh

located in the dependencies folder of this project. After installing bluez it's recommended you reboot your system and check whether it was updated by invoking

bluetoothctl -v

It should display 5.50.

After the dependencies have been built, the Makefile build system is generated by invoking ./configure

Generated build system is located inside out directory

The module and the example are built from out directory by invoking make in terminal

Before running the module, you should check whether your bluetooth daemon is running. You can do so by invoking

systemctl status bluetooth

If it's not running you can start it by invoking

sudo systemctl start bluetooth

The example should be run using the deviceConfiguration.json file. eg.

sudo ./example deviceConfiguration.json

Sudo is necessary in order to access the adapter.

The example will then scan for nearby bluetooth devices, detect if one of the devices that were specified in the .json file by their key is present and if it is it will publish a 1 to the Wolkabout platform. If the device wasn't spotted in the timeframe it will send a 0.

Example Usage

Setting up the Gateway First we need to set up the Gateway our module will connect to. In order to do so visit this repo and follow the instructions.

Setting up our module In the out folder locate the deviceConfiguration.json file. set up host to target the Gateway you set up. eg.

"host":"tcp://localhost:1883"

Creating devices: Devices are created from the deviceConfiguration.json file. In order to create a new device you should define it in the device section of this file. A new device should contain two attributes - name and key. Name is the name of the device to be displayed on the platform and the key is the bluetooth address of the device.

"devices":[
{"name":"device_name1",     //the name under which the device will be displayed on the platform
"key":"xx:xx:xx:xx:xx:xx"   //bluetooth address in xx:xx:xx:xx:xx:xx format. 
},
{"name":"device_name2",
"key":"xx:xx:xx:xx:xx:xx"
}
]

All devices share a common template of one numeric sensor defined in the Configuration.cpp file.

Setting the scan time Scan time is set in the deviceConfiguration.json file by changing the readingsInterval field.

"readingsInterval": 15

wolkgatewaymodule-bluetooth's People

Contributors

djesic avatar lazarbozic94 avatar milandinic avatar milanzlicic avatar nanavuletic avatar svranesevic avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wolkgatewaymodule-bluetooth's Issues

General

Mark installing bluez with sh , because it is crucial depend for this project. Lije you do for dependency call and bluetoothctl -v

General issues

List:

  • menation folders with ``,eg folder_name, this fodler /dependencies
  • also this 'out' directory
  • file name also, this deviceConfiguration.json
  • Usage is totaly wrong, we will verbally
  • remove fw section

Sudo privilege for dependencies

Msg from my terminal, envireoment RPI 3+ with raspbian.
pi@raspberrypi:~/bluetooth $ apt-get install autotools-dev autoconf libtool m4 zlib1g-dev cmake python python-pip && python -m pip install conan
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

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.