I'm trying to create a Gateway which offers a RESTful interface to send/receive messages to Devices which communicate over Bluetooth Low Energy (BLE). Basically it translates GATT to HTTP and vice versa.
The basic architecture looks as follows:
A BLE Dongle is connected to a Linux computer (f.e. Raspberry Pi) a C-Program opens a serial connection to the BLE Dongle to send/receive/process messages. It receives requests from a C++ Application over IPC using a TCP/IP Socket and also uses this socket to forward replies from BLE Devices (f.e. Sensors) to the C++ Application (which acts as a multithreaded server for each connected BLE Dongle).
The C++ Application saves this information (f.e. discovered devices, connected devices and their data) and also implements an interface to control basic Bluetooth Low Energy functions like Discovery,Connect.. etc.
A client can send HTTP Requests (GET/POST) to a Nginx Webserver which uses FastCGI. I would like to parse the requests in this FastCGI Application and then communicate with the C++ Application to execute the commands
f.e. Client opens an URI xyz/discover sending a GET Request. The FastCGI Application parses this requests and calls the Discover function of the C++ Application to start a Bluetooth Low Energy discovery.
My Question is how to best communicate between the C++ Application and the FastCGI C++ Application.
My Ideas:
- The C++ App forks a new child which does exec fcgi-spawn (path to my fcgi app as an argument). Then create two pipes for full-duplex communication between parent and child
- Using named Pipes between both processes
- Is it a good idea to just integrate the FastCGI functionality in my C++ Application? The C++ App runs several Threads: one to accept new TCP connections in case a new Dongle is connected. It starts a Thread for each new Dongle. Could I just create another thread which is responsible for parsing FastCGI Requests?
Since I never really worked with FastCGI and nginx I'm just learning as I go. So I would be grateful for some input. Thanks!