My bluetooth adapter in Settings (on Ubuntu) can detect my AR Drone (MiniSpider) device. But using the simple Bluez code example to detect Bluetooth devices, I'm not able to detect the drone device. My code is exactly the same as the code in the before mentioned link. I can detect a phone using the code (if the phone has made itself visible).
Any idea what could be the problem?
Output from hcitool lescan: it successfully finds the drone bluetooth device.
sudo hcitool lescan
LE Scan ...
A0:14:31:48:8C:EB RS_W082091
A0:14:31:48:8C:EB RS_W082091
A0:14:31:48:8C:EB RS_W082091
The code snippet you are using is for scanning classic Bluetooth devices. This is the equivalent of using hcitool inq from the command line, in which case you'll probably not be able to detect your device.
However, the AR Drone seems to support Bluetooth Low Energy (BLE), and not classic Bluetooth. Therefore, using the inquiry method you were not able to detect it. If you use code that scan for BLE devices, you'll be able to find your device. You can have a look at the source for hcitool.c below:-
https://github.com/aguedes/bluez/blob/master/tools/hcitool.c
And then your starting point would be to use the hcitool lescan code:-
static void cmd_lescan(int dev_id, int argc, char **argv)
{
...
}
Related
I'm developing a C application on C.H.I.P. board (Debian Jessie on it) ; while I was able to scan for classic and BLE devices using the source code of hcitool scan and hcitool lescan that we can find in /tools/hcitool.c of bluez package, I can't pair with devices without interact with the prompt given by hcitool auth XX:XX:XX:XX:XX:XX or rfcomm bind "MY DEVICE" XX:XX:XX:XX:XX:XX. I need to bypass the prompt given by these function without having interaction with it. I tried to find which function call the prompt and it seems to be the IOCTL, but i can't understand how to avoid this step. Can anyone could help me?
I want to use Bluetooth(4.0) on my board to transmit it's Name so any Mobile Application can see it's name and Mobile application initiates the pairing and connection with my Bluetooth.
I have seen some examples of Bluetooth(4.0) scanning nearby devices; For example:- It does scan for Bluetooth Mouser/Keyboard, but in this case Bluetooth(4.0) is in mode where it chooses the device it want to connect while I want it reverse so Any mobile application can see my Bluetooth and gets connect with it and does communication.
How can I put my Bluetooth(4.0) in such mode in Linux? Is there any C library using which I can put Bluetooth(4.0) is the mode where it goes in Bridge mode instead of scanning nearby devices?
You can set the name of your device like this:
hciconfig name "foo"
and check your name with:
hciconfig name
You also have to enable Low Energy advertising for your device to be found by others:
hciconfig leadv
You can configure your device to accept incoming connections like this (lm for link mode):
hciconfig lm MASTER,ACCEPT
This way the kernel will accept a connection, even if there are no listening sockets.
Considering you want to do actual communication, you would need to write a program, accepting the connection and sending/receiving data. Just putting your device in a mode where other devices can connect to it isn't really worth anything (because you can't communicate).
The basic principle is to open up an L2CAP socket, with the Channel ID of 4 (for Low Energy), then do standard bind/listen/accept. I suggest you look at the source code of Bluez and the examples.
I am using my raspberry pi to perform LEScan at fixed intervals and connect to new found BLE devices.
Performing a general scan is easy and can be easily done by using the bluez libraries.
http://people.csail.mit.edu/albert/bluez-intro/x45.html
But i can't figure out how to perform LE scan using Bluetooth programming in C language.
I have to find new BLE devices, connect to them and receive json data from the connected devices.
To write a C program to scan BLE devices you can have a look at BlueZ hcitool sources.
To connect to the BLE device and interact with the GATT protocol you can either use the experimental DBUS Bluez API in Bluez v5.x (recommended to use v5.39+) or use a library like 'gattlib'.
The link you are pointing is for classic bluetooth;for BLE lescan go
through scantest.c in link
https://github.com/carsonmcdonald/bluez-experiments/tree/master/experiments
How can I communicate with an mbed LPC1768 using C without using a terminal emulator like minicom or teraterm?
For example if I send an integer from my C code than that led should be turned on.
How can I do this?
Without reading user manual or datasheet you can't do any thing to your board. So just go through it then follow below link for demo application LPC1768 board
1.NXP LPC1768 ARM Cortex-M3 Red Suite Demo
2.LPC1768 ARM Cortex-M3 CrossWorks Demo
3.mbed
4.At github
If you are using linux or osx check out the following answer:
How do I read data from serial port in Linux using C?
You can check your /dev folder and look for a file that is created when you plug your mBed. The file name would be something like /dev/ttyS0. That file represents the communication port, you can read/write that file to receive/send data over serial port.
If you want a cross platform solution try RxTx library for Java.
You can use this library
what it does, is that it initialize UART port which is connected to the debugger on your board and use it as serial input output. so with any hyper terminal of your choice, you can write code to do something if you send certain string of characters or just use original printf when something happens. and it will be printed on your PC screen.
I have successfully talked to the computer from an Arduino via serial USB port and I had the idea that I could make a keyboard or mouse with the arduino. Say I wanted to translate the computer's mouse 1 pixel to the left. What message would I have to send over the serial line in order to achieve this?
Google is a wonderful thing. "use arduino as mouse" returns 1.7 million hits. The third hit on the list takes you to the Arduino Playground for an example using the new Leonardo board.
Note:
The Leonardo differs from all preceding boards in that the ATmega32u4 has built-in USB communication, eliminating the need for a secondary processor. This allows the Leonardo to appear to a connected computer as a mouse and keyboard, in addition to a virtual (CDC) serial / COM port.
Assuming you don't have that board, here is another site for some other specific boards and yet another that is log for a project including hardware and software for older boards.
Hope this helps (and is a better answer to the question).
You would have to reconfigure the USB interface chip to appear as a USB HID endpoint.