GATT service/characteristic structure for BLE application - bluetooth-lowenergy

I’m building an application in which a smartphone needs to communicate with a peripheral over Bluetooth Low Energy but I’m having a hard time coming up with the right GATT service/characteristic structure for this communication. The phone and peripheral need to communicate with each other over a “custom protocol” containing multiple send/receive messages. What I mean with this is that he phone will send something to the peripheral (step 1 of the protocol), which will respond to this by sending a message to the phone (step 2 of the protocol), which will respond to this by sending the next message to the peripheral (step 3 of the protocol), etc. until the protocol completes (after let’s say 10 steps).
Should I make a new attribute for every step of the protocol I want to execute, i.e. have the phone write to an attribute “protocol1” and have the peripheral notify the phone with an attribute “protocol2” after which the phone writes “protocol3”, etc. Or should I use only 2 attributes for this: one for the phone to write to (TX), and another one for the phone to read (RX) through notifications? It seems that BLE (instead of Bluetooth 3.0) wasn’t really made for this kind of RX/TX communication, or am I wrong?

Two Characteristics, one for TX and one for RX should be enough.
Use Characteristic Write for TX and Characteristic Indication for RX.

Related

Can I auto pairing and connect 2 BLE devices?

If I develop 2 BLE devices(not phone, not android), can I program them to auto pairing and connect?
Let's say, BLE A advertise BLE B, B authenticate A, B request connect to A, A and B connected, B is a master of A, A and B exchange data, A and B disconnect. The whole process without any human touch, is it possible?
If yes, how fast can it be from advertise to connected?
Yes you can, but for BLE there is no need for pairing, just connect or even send and read advertising data without connecting.
Set one device up as beacon or server.
The other device as scanner or client.
Finding a server or advertising device can be up to a few seconds, depending upon how many devices are in reach,
and the signal strength.
A connection can be established on average by 500 ms.
Advertising intervals depend on the devices used and how much data is send, but can be as short as 40 ms.
These numbers are based on my experience only, using a few android phones, my laptop, some esp32 boards and some HM10 devices.

How to spoof individual BLE packets

I'm doing a security analysis project on an IoT device that uses an unencrypted BLE connection (with ATT protocol) and I want to spoof an individual BLE packet with the source address of an already connected device. Is there some tool or API that would allow me to do this easily? I've already tried gatttool and spooftooph but they seem to be connection based and don't allow you to send out single packets with modified fields (as far as I could tell).
You will need some hardware where you can access the radio peripheral directly. What you basically need to do is to find or write a ble sniffer firmware, with the modification that it at a given moment sends a packet on the connection it is currently listening to. But note that the signal strength must be stronger than the original device's signal so it doesn't interfere.
The only open source project I'm aware of is Ubertooth. You will also be able to do this with an nRF52 but then you need to write your own sniffer firmware since Nordic Semiconductor's is closed source.
I can't comment on Emils reply yet, < 50 rep:
Nordic Semis nRF Sniffer v2 needs only the nRF52DK and wireshark to work as a general BLE sniffer. At 40$ it's not that expensive. I know for a fact they will release a new dongle soon that will sell for ~10-15 bucks if you can wait a a month or two.

BLE ability, secure connection and unpack data

I have a use case, and i want to use BLE to accomplish the use case, i don't know if BLE support my use case and the way to do that.
Sensor Tag- is small device that works on coin battery and contains BLE.
Use-case: I want to connect the Sensor Tag to smartphone and unpack data.
1- The connection must be just to my smartphone app, i don't want any other app's to connect to the Sensor Tag and unpack data.
2- Each packet of data must be ACK, the smartphone get packet 1 and send it to the server, the server return ACK to the smartphone, the smartphone send ACK to the Sensor Tag, then the Sensor Tag will sends packet 2...
3- In order to force the Sensor Tag not send data in airplanes, the Sensor Tag must just listen at first, if he heard something from my android app, then he will sends connection request.
First questions: did the BLE support my use case? All, some(which ones), none?
Second question: How can i establish the use case?
Thanks.

Bluetooth Low Energy Profile/Service Selection

My requirement is as follows:
I need to send Proximity Sensor (Reed Switches/Magnetic Sensor) reading (On/Off) from two Input Pins to a central PC.
I need to use coin cell. So basically the app should be in sleep mode and once there is any interrupt on any of these two pins it should wake up to send its state to the central PC.
I have DA18450 chip and development board (murata ZY type) with me.
Dialog Semiconductor 18450
Murata Bluetooth Smart Development Board
I am a beginner to bluetooth technology and started reading about it just a week back.
Could someone guide me about the most apt Profile/Service suitable for my application?
If you want the device to actually sleep then it'd probably be best for it to just transmit data via advertising packets when the device awakens. Otherwise you have to maintain a connection which requires staying awake at some level. However, advertising packets are broadcast and the device can't know if anything received those packets (you could have it broadcast several times for a fixed period of time or have it constantly broadcast while the proximity alert is valid). Also, on the receiving end, with no connection there's no way of knowing the transmitting device is even there when nothing is being transmitted.
The advertising packets have a section for limited information and that's where you'd transmit data if you don't want to establish a connection.

Can a peripheral can be connected to multiple centrals?

From this book it says
A peripheral can be connected to multiple centrals.
can any BLE module do this? More specifically can bluegiga 112 do it? If not what are the BLE modules that can work as a peripheral connected to multiple devices?
The same book also states
Once the connection is established, the peripheral stops advertising and the two devices can begin exchanging data in both directions
so if the peripheral stops advertising how will it accept more connections as mentioned above? How will other scanners detect this peripheral?
Tim Tisdall is correct. That solution works for specification 4.1, but not for 4.0. As you mentioned above, you cannot establish a connection with a device that is not discoverable, and since it stops advertising upon connection establishment, it is impossible to have a peripheral connected to multiple centrals.
Any peripheral BLE device can "broadcast" it's attributes/characteristic values in GATT profile. So, any central device interested in the value can potentially "connect" to the BLE peripheral to get that broadcast message. So, that's what i believe is a use case for "A peripheral can be connected to multiple centrals."
I don't think the peripheral stops advertising it's presence just because it's connected to a certain central device. Any device can still see it's presence when it does a scan.

Resources