establish bluetooth piconet connection between server and two clients using c on linux platform? - c

I want to establish Bluetooth network where one server can communicate to two clients (ie piconet) using C programm on linux platform, rfcomm based communication.
Can any one please share your guidance or sample source code if have.
I newbie to the bluetooth technology, have not found any useful info or code from internet source so far. so please.
Thank you
Basu

Linux runs open source BlueZ Bluetooth Stack, which works quite well (unless you need Bluetooth Low Energy). You can check out this tutorial: http://people.csail.mit.edu/albert/bluez-intro/c404.html
PS. Mind the GPL license when using #include like in those examples.
Edit:
As for creating piconet specifically, I'm afraid I don't have any snippets. However, after quick search, I would look into using bluez library to open not one but many RFCOMM sockets. So you can listen to and accept multiple connections.

Related

Using WDK to make a driver for a bluetooth gamepad

I am trying to make a Windows driver for a bluetooth gamepad, I know exactly what data the gamepad sends via bluetooth, but I have no clue where to start with this project, I have searched far and wide for more information about how to recieve data through bluetooth with WDK, but I have yet to a good source of documentation or a good example. Everything has to be coded in C, I have already setup the basic driver and tested it on the device, all i need now is functionality.
So my questions are:
How do you connect to the right bluetooth device
How do you send/recieve bluetooth data using WDK
How do you emulate a HID gamepad device after parsing the bluetooth data
Any links to documentation, examples or possibly books would be much appreciated.

connection between windows and Linux sockets in c

I am using the socket module in python to send commands to my raspberry pi to turn GPIO pins on and of.
I am switching to C, where I will use winsock.h and winsock2.h to create the server on my PC and sys/socket.h to create a client on the raspberry pi.
Is it possible to establish a connection between these two different libraries?
I only want to create a socket, bind, send and recv. No other operations.
I recommend you to check this documentation, there are some examples for a Windows Server / Client connection:
https://learn.microsoft.com/en-us/windows/win32/winsock/getting-started-with-winsock
For Linux you need to do some adaptations as you might know or you have already implemented, I did the same for 2 desktop applications to send data from a Linux PC (client) to a Windows PC (server). As mentioned in the comments it doesn't matter the devices while they are in the same network and follow the TCP/IP protocol.
I was able to do this even connected through a VPN. Unfortunatelly I can not share the code. But I developed this communication based on the documentation from the link above.
I hope it helps. Actually if you want to use Python in the raspberry Pi there is also a python built-in package that you could use: https://docs.python.org/3/library/socket.html
And you can use the code from the link above in Windows. It should be straighforward.

develop BLE peripheral using C on intel edison

I am trying to develop a bluetooth LE peripheral in intel-edison, by using C library. The device should be able to :
advertise (GAP)
accept connection (GAP)
support custom GATT service, simply read/write value of characteristic.
I try to use HCI and bluez to implement this. bluez-experiments, intel-edison-playground, which demonstrate how to advertise and scan, can be compiled and run on edison. BLE advertising and scanning do work.
But I have hard time to figure out how to accept connection and support GATT service. I try to search on goolge about the HCI document but have no luck. Can someone provide a snippet of code (c or pseudo or a description)?
Thank you so much!
Andrew
If you download the bluez source you'll find documentation on the hci protocol in /doc/mgmt-api.txt. I'm not using the hci interface myself, and I'm not sure if the developers intend for implementors to use this interface to implement peripherals, so I'm not sure how well this will work.
I went with the DBus API approach for my project, which is outlined in /doc/gatt-api.txt and /doc/advertising-api.txt. This approach involves writing a program which creates DBus objects which support specific org.bluez DBus interfaces (GattService1 which contains GattCharacteristic1 and GattDescriptor1) and the ObjectManager interface to expose everything to bluez. You then use LEAdvertisment1 to define what is advertised and register the advertisement using the LEAdvertisingManger1 interface on the adapter.
I used Qt to simplify the DBus communication parts.
The DBus API for BLE on bluez is still in heavy development, and not all features are supported (I still haven't found a way to start and stop advertising, for example). 5.31 contains a lot of added supported and some critical bug fixes for descriptors, but requires a newer kernel.

lwIP telnet example?

I'm doing some experiments with lwIP on a small, embedded device. There are some examples that come with lwIP but they do not help me. What I want to implement is a server (using wlIP) that accepts a connection, reads several commands, sends several answers to the connected client and closes only when the connection is interrupted or a special close-command is sent.
So somehow similar to a telnet-server.
Is there an example for lwIP available that demonstrates this behaviour?
Thanks!
I know this is an old question - but I found it when looking for something similar!
If you look in the lwip contrib directory (http://download.savannah.gnu.org/releases/lwip/) there are some example applications - including a tcp (and udp) echo server.
You don't say what device you are using or whether or not you are using an RTOS, so it is hard to provide example code. However, if you are not using an RTOS I would highly recommend you start! My experience of using the lwip raw api (without an rtos) is that it is difficult to read data from the outside world (e.g. using interrupts) without things falling over.
HTH,
Alex

Windows C socket programming for UDP client

I am trying to lookup some example programs for windows socket. Particularly, I am interested in writing a client in C (in visual studio) which communicates to the server using UDP. I din't find any concrete material. I tried some examples but got some linking errors. Is there any library available. Please let me know.
Thanks in advance.
The Apache Portable Runtime supports sockets, and it is cross platform.
I've found a simple library, which provides implementation of networking, but it is for C++. (C++ Socket Class for Windows). You can look at it's implementation of working with sockets, or just use it (there are examples of simple client and server).

Resources