Yes this is possible. As you may already know, there are four roles in Bluetooth Low Energy (BLE):-
- Broadcaster - A devices that just advertises data.
- Peripheral - A device that advertises data but can be connected to by remote devices as well.
- Observer - A device that just scans for data.
- Central - A device that can scan for data as well as connect to them.
When BLE was first introduced, beacons/sensors (e.g. Heart Rate, Thermometer) occupied the first two categories and phones/computers occupied the other two. However, BLE has since evolved and a lot of devices now support all four roles and a device can operate in one or more roles at the same time.
Regarding your question, as Lee Daniel Crocker mentioned, data is data and what you put in adverts is just going to be bytes that the other end has to understand. You can only put 31 bytes of data in an advert report*, which is why connection-oriented data transfer is more efficient.
Regarding the programmability, I would recommend starting with BlueZ commands on both, the device that will advertise and the device that will read the data. You can do this with the Bluetoothctl command as follows:-
On the broadcaster/peripheral
#bluetoothctl
[bluetooth]menu advertise
[bluetooth]advertise data 00 00 00 00
[bluetooth]back
[bluetooth]advertise on
On the observer/central
#bluetoothctl
[bluetooth]scan on
I am using BlueZ version 5.50 and I recommend that you do the same.
Once you can advertise the data and read it from the other end correctly, you can go through the source code and see what you can leverage to your C application. For bluetoothctl functions you want to start with the following two files:-
- bluez-5.50/client/main.c
- bluez-5.50/client/advertising.c
I hope this helps.
(*) As of Bluetooth 5 you can add a lot more data to advert reports, however this a very recent feature and as of this writing very few stacks support it.