问题
I am new to developing a mobile app with bluetooth connection to peripheral device. I searched that GATT is the relevant profile used for bluetoothLE communication but our client recommended that we use UART service. Now I am confused as to 1. how these two things are related and 2. Do we have to opt for one of these, if so, what are the pros and cons of each. Thanks
回答1:
Legacy Bluetooth provides the serial port profile (SPP) - This is essentially a serial input/output stream over Bluetooth.
Bluetooth Low Energy provides a number of profiles, but the most commonly used is GATT. GATT exposes characteristics/attributes which are a little like variables that you can read from/write to. A read/write is limited to 20 bytes.
Many embedded BLE chipsets provide a "UART emulation" over BLE GATT. Here a pair of attributes are used; one for read and one for write.
The Central device writes bytes to the 'write' attribute and the embedded chip sends them out of a serial port on the chip.
Similarly, data that is written to the chip's serial port and sent to the central via a notification of new data in the 'read' attribute.
You don't say what platform your are developing on, but one important consideration is that use of SPP on iOS requires your hardware to be MFi certified by Apple, while BLE/GATT does not.
来源:https://stackoverflow.com/questions/37981000/gatt-profile-and-uart-service