How to do bluetooth pair between raspberry pi and phone from script? - bluetooth

I want to connect my phone to asterisk, who installed on the rbpi3 with chan_mobile.
I want to do web-interface for connect.
First step its scan for phones - its simple. Many hundreds path.
Second step - pairing intit. For send request from rbpi to phone (or revert, nevermind)
I have trouble with this step.
Old bluez (<5) have simple-agent and i can do pair with shell command:
bluetooth-agent --adapter hciX _pin_ mac_for_pair
Actual bluez(5.47 on this moment) dont have analog.
Only interactive bluetoothctl console.
I'll try to search libs for node js, python, but i dont see method of pair request init(or accept, if init from phone).
Can you help me? In fact, I need any path suitable for use in a script in which I want to pass the adapter and the target.

bluez has DBus API's to perform operations you need. See doc/ directory from bluez source. Go through doc/adapter-api.txt, doc/device-api.txt and doc/agent-api.txt files. These document files gives you fair understanding on scanning for bluetooth devices, running agent for authentication and pairing with your phone.
You can get sample codes for the DBus API's in the test directory of bluez source. See test/test-discovery and test/test-agent code to understand how to start a bluetooth scan using bluez DBus API. All the sample codes in test directory are in python and some scripts can be directly used in your application.
The bluetooth-agent you mentioned is an agent for authentication that is available with older bluez versions. You can create your own agent; see test/simple-agent python script in bluez source directory.

I already have a C function in this post , you could just easily convert it into a script or just compile the C code and call it from the script.

Related

How to run "clear" commands using Napalm on IOSXR device

As you might all know Napalm uses 2 drivers for interacting with IOSXR devices, namely: iosxr_netconf and iosxr (uses iosxr's native xml agent). I'm using the iosxr driver.
In one part of our project, I need to run a "clear" command to clear the qos counters on one of the device's interfaces. However, I see that Napalm errors out because the underlying XML agent on iosxr does not support commands that start with "clear". What would be the best way to overcome this hurdle?
Thanks.
I tried running the clear command but I received an error.

Writing Gatt Server Application in Bluez

We want to write a custom Gatt Server Application for Bluez where we want to give some useful features. For example:
Start Gatt Server
Register/Unregister custom Service
Add/Remove custom Characteristics/Descriptor
Set/Get Value of Characteristics/Descriptor
Disconnect Client / Close Gatt Server etc.
Bluez don't have these features in command line tool but they have several APIs (functions) to do that, we need to call those internal functions.
In according to that we wrote an application in "bluez5.28/attrib/" directory from where we called several internal functions from files of
"bluez5.28/attrib/", "bluez5.28/profiles/" and "bluez5.28/src/" directories and tried to build it with bluez Makefile.
Since bluez have automated generated make file from automake it is quiet hard to make any change in that Makefile. But when we tried it showed lots of errors
regarding dependencies and libraries e.g. undefined references, no such files of directories, etc.
Is their any easier way to use bluez functions to make a GattServer Application ?
Thanks in advance for your valuable answers.....
bluez gatt dbus apis are now complete as of version 5.29. You may consider using those if going via the dbus rather than directly through library calls is acceptable for you.
correlate pg:1950 in bluetooth spec4.0 APPENDIX: EXAMPLE ATTRIBUTE SERVER
ATTRIBUTES with gatt-example.c in plugins in bluez5.28

communicate with my raspberry PI, through my webserver

I want to communicate with my raspberry pi, through my webserver.
I want to use a web interface on my server, with which I can control an LED on my PI.
Can I use "node js" for this? or does anyone have a good idea or examples?
regards
You can indeed use just about any web server to communicate with the pi and thereby control its GPIO pins.
I wrote a web server specifically to interface with the pi's GPIO capabilities complete with utilities and examples if you want to try it out. It's a very lightweight native-code (C++) web server that you can use to control your LEDs (or what have you) with about 5 mins of setup:
OliWeb on GitHub
You can install it using git with:
sudo git clone https://github.com/m2ware/OliWeb.git
You could also install just about any other web server out there (Nginx, Node.JS, take your pick) and set up CGIs to call command-line utilities to drive the LED pins. Gordon's WiringPi utilities are easy to use and install - installation and usage instructions are below.
Gordon's WiringPi Utility
Each web server will have its own particulars in terms of invoking command line interfaces via CGI. If you're interested in NodeJS specifically, this describes how to invoke command-line functionality from Node:
How to invoke external scripts programs from node js
I know it is a little bit late, although for those who may be still interested I've recently developed a school project which does exactly this job.
I've used WebSocket and GPIO handling.
Here's the repo for the client: https://github.com/jkomyno/material-led-controller/
Here's the one for the server (you gotta put this on your RPI):

Asterisk: Zombie channels when initiating call bridging through AMI

I am working on a web dialer interface in order to make phone calls through the browser. I am using sipml5 on the frontend and I have an asterisk/freepbx server for the backend. Everything has been going smoothly so far, but there is still one piece of functionality that I am missing. I cannot seem to bridge together two currently existing calls.
I have been using this library to send AMI commands to asterisk from the webserver.
When I try to use the AMI bridge command, the asterisk logs show my channels as being zombies and drops the call on both lines.
Following is a pastebin of the asterisk verbose/debug logs when i attempt to execute the command.
http://pastebin.com/ErmnT31w
I am an asterisk newb so I may not be thinking of this the right way.
Any suggestions on how to bridge calls via a web dialer using webrtc?
Thanks for your time
You have use single channel, one leg call out, other leg to operator
You HAVE NOT use TWO channel.
So there are no any need in bridge if it developed correct way.

Bluetooth for ARM embedded linux

I'm struggling now for a few days to setup bluetooth services on an ARM embedded device running Linux. I'm using a bluetooth dongle connected via USB.
Let's start with the beginning. I had to compile myself all the required packages, and that means expat, dbus, zlib, libffi, glib, bluez-3.36-libs and bluez-3.36-utils (yeah 3.36, I know they're old but so is my cross-compiler), libopenobex-1.3, obexd-0.3, obexftp. Then I put the binaries and libs on the device. Also, bluetooth is enabled in kernel.
I'm able to activate the bluetooth using hciconfig hci0 up command, I can perform scan using hcitool scan, I can even ping with l2ping previously discovered devices.
What I want is to be able to transfer files between that ARM device and another bluetooth device using ftp protocol and here my problems begin.
Are these the only tools that I need?
After putting everything on the device, I turn on bluetooth using hciconfig hci0 up, then I start dbus daemon using dbus-launch and after these I try to start obexd. When I run dbus-launch, it prints the values for DBUS_SESSION_BUS_ADDRESS and some pid and next when I try to start obexd it asks me to set the DBUS_SESSION_BUS_ADDRESS. Is this normal because I read that you have to set this only for test purposes? What is the default (real) dbus session bus address? How should I properly configure dbus?
I tend to think that the problem is in the pairing process, when the two bluetooth devices are trying to authenticate. How can I do this from command line as this is all that I have (no GUI)?
Could you please present me the detailed step to follow in order to achieve my goal. I tried to learn more about them from the Internet and also I tried to find these steps online but I could not find what I need.
Could you please explain me the difference between obexd, obexd-client, obexd-server, obex-data-server, obexftp? Are they meant to be used together or they offer the same functionalities? I could not clarify this from their man pages.
I know this is a really long post with a lot of questions, but I don't have experience with bluetooth and I'm under time pressure to solve this. Any help would be kindly appreciated.
Many questions you raised, but will try to answer them :
Thatz pretty much everything you will need.
Why are you starting session bus ? Will not starting system bus help and hcid uses system bus( as far as i know ). You need to execute the cross-compiled obexd ( or any other utility) with correct parameters.
you can use simple-agent ( it is in tools dir in 3.36 release if i am not wrong ). In a non-gui mode ( simple-agent --default [ follower by your pincode ] ) will work.
Basically you will need to find a device ( do scan ), authenticate ( pair ) and then proceed with file transfer which will involve obex level request / response ( to put in simple words).
As much i know, initially obexftp / obex-push were the only standalone utilities that worked on top of openobex for file transfer. Obex-data-serer was developed as part of GSOC competition, which got included in major distros. obexd is the slimmer version of obex-data-server specifically designed for embedded usage and is closely integrated with hcid ( and bluetoothd later). Please use only one of the utilities and not all at same time.

Resources