BLE-Stack APIs
3.00.01
|
All these command have some parameters. The parameters can be found/set using the indicated Parameter structure. All Parameter/Structures should be little-endian format (LSB first). For UUID parameters, dealing with UUID
NP -> AP (N/A)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x87 |
SNP_NPI_ASYNC_CMD_TYPE | SNP_CHAR_READ_IND |
AP -> NP (SNP_readCharCnf)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x87 |
SNP_NPI_ASYNC_CMD_TYPE | SNP_CHAR_READ_CNF |
The SNP_CHAR_READ_IND Event is sent by the SNP when a remote GATT client wants to read a characteristic value managed by the AP.
The AP must answer with SNP_readCharCnf / SNP_CHAR_READ_CNF within 30 seconds. If there's no response, an ATT Timeout will occur and the BLE connection will be lost.
A characteristic value can be up to 512 Bytes long. However, not more than ATT_MTU_SIZE can be read at once by a ATT operation.
If the characteristic size is bigger than ATT_MTU_SIZE, the remote GATT client will send several SNP_CHAR_READ_IND, until it reads the complete value. There is several different ways for the GATT client to fully read a characteristic; one way is that each read request sent by the GATT client is translated in a SNP_CHAR_READ_IND with snpCharReadInd_t.
The snpCharReadInd_t::offset represents the start of the data to read, the snpCharReadInd_t::maxSize represents maximum size of the characteristic.
The AP needs to reply with the SNP_readCharCnf command which contains the data payload. The AP will indicate the offset the data were read from, the size of the data, and the data with snpCharReadCnf_t.
The default ATT_MTU_SIZE is set to 27. If MTU Size is changed (negotiated between GATT server and GATT client), then a SNP_EVENT_IND with SNP_ATT_MTU_EVT event will be send by the NP to the AP The AP cannot initiate this change.
SNP_CHAR_READ_IND (from SNP) | SNP_CHAR_READ_CNF (from AP)
NP -> AP
snpCharReadInd_t
Size | Description |
---|---|
2 Byte | Connection Handle |
2 Byte | Attribute Handle |
2 Byte | Offset in Bytes |
2 Byte | Max Size |
snpCharReadInd_t for SNP_CHAR_READ_IND
snpCharReadCnf_t for SNP_CHAR_READ_CNF
NP -> AP (N/A)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x88 |
SNP_NPI_ASYNC_CMD_TYPE | SNP_CHAR_WRITE_IND |
AP -> NP (SNP_readCharCnf)
CMD 0 | CMD 1 |
---|---|
0x55 | 0x88 |
SNP_NPI_ASYNC_CMD_TYPE | SNP_CHAR_WRITE_CNF |
The SNP_CHAR_WRITE_IND Event is sent by the SNP when a remote GATT client wants to write a characteristic value managed by the AP.
The AP needs to answer with a SNP_CHAR_WRITE_CNF / SNP_writeCharCnf within 30 seconds.
The GATT client may request a partial write, hence the usage of the offset where the write should begin relative to the beginning of the characteristic value (the offset is a number of Bytes). The characteristic value length is application specific. Neither the SNP or the AP SNP library know the length of the characteristic value.
If the GATT client starts to write a characteristic value with offset 0, the entire value will be written. If the GATT client starts to write a characteristic value with an offset different than 0, a partial write will occur.
It is the responsibility of the application to know the length of each characteristic value.
The snpCharWriteInd_t::rspNeeded field set to 1 indicates that the AP must send SNP_CHAR_WRITE_CNF / SNP_writeCharCnf within 30 seconds. If this field is set to 0, the SNP_charWrite_rsp is not needed. This can happen if a ATT_WRITE_CMD operation has been used by the remote GATT client. If a confirmation is send anyway, it will be ignored by the NP.
The application can also have their own permission mechanism and rules. In this case it is the responsibility of the application to deny the writing of the value by return a error status with SNP_CHAR_WRITE_CNF / SNP_writeCharCnf.
SNP_CHAR_WRITE_IND (from SNP) | SNP_CHAR_WRITE_CNF (from AP)
NP -> AP
snpCharWriteInd_t
Size | Description |
---|---|
2 Byte | Connection Handle |
2 Byte | Attribute Handle |
1 Byte | Response Needed? Options for Response Needed Field |
2 Byte | Offset in Bytes |
X Byte | Data to be Written |
snpCharWriteInd_t for SNP_CHAR_WRITE_IND
snpCharWriteCnf_t for SNP_CHAR_WRITE_CNF