mirror of https://github.com/ARMmbed/mbed-os.git
Various fixes regarding typos, dead code and consistency.
parent
453045ab74
commit
969c63040e
|
@ -532,7 +532,6 @@ void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
|
||||||
long_write_request_t* req = findLongWriteRequest(conn_handle);
|
long_write_request_t* req = findLongWriteRequest(conn_handle);
|
||||||
if (!req) {
|
if (!req) {
|
||||||
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_invalid_reply);
|
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_invalid_reply);
|
||||||
releaseLongWriteRequest(conn_handle);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,15 +539,7 @@ void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
|
||||||
if (req->length == 0) {
|
if (req->length == 0) {
|
||||||
req->attr_handle = input_req.handle;
|
req->attr_handle = input_req.handle;
|
||||||
req->offset = input_req.offset;
|
req->offset = input_req.offset;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// it is disalowed to write backward
|
|
||||||
if (input_req.offset < req->offset) {
|
|
||||||
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_invalid_offset_reply);
|
|
||||||
releaseLongWriteRequest(conn_handle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// it should be the subsequent write
|
// it should be the subsequent write
|
||||||
if ((req->offset + req->length) != input_req.offset) {
|
if ((req->offset + req->length) != input_req.offset) {
|
||||||
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_invalid_offset_reply);
|
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_invalid_offset_reply);
|
||||||
|
@ -562,6 +553,7 @@ void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
|
||||||
releaseLongWriteRequest(conn_handle);
|
releaseLongWriteRequest(conn_handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// start the copy of what is in input
|
// start the copy of what is in input
|
||||||
memcpy(req->data + req->length, input_req.data, input_req.len);
|
memcpy(req->data + req->length, input_req.data, input_req.len);
|
||||||
|
@ -595,7 +587,6 @@ void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
|
||||||
long_write_request_t* req = findLongWriteRequest(conn_handle);
|
long_write_request_t* req = findLongWriteRequest(conn_handle);
|
||||||
if (!req) {
|
if (!req) {
|
||||||
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_invalid_reply);
|
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_invalid_reply);
|
||||||
releaseLongWriteRequest(conn_handle);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +606,7 @@ void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
|
||||||
// just leave here.
|
// just leave here.
|
||||||
if (write_authorization != AUTH_CALLBACK_REPLY_SUCCESS) {
|
if (write_authorization != AUTH_CALLBACK_REPLY_SUCCESS) {
|
||||||
// report the status of the operation in any cases
|
// report the status of the operation in any cases
|
||||||
sd_ble_gatts_rw_authorize_reply(gattsEventP->conn_handle, &write_auth_invalid_reply);
|
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_invalid_reply);
|
||||||
releaseLongWriteRequest(conn_handle);
|
releaseLongWriteRequest(conn_handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -633,7 +624,7 @@ void nRF5xGattServer::hwCallback(ble_evt_t *p_ble_evt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sd_ble_gatts_rw_authorize_reply(gattsEventP->conn_handle, &write_auth_succes_reply);
|
sd_ble_gatts_rw_authorize_reply(conn_handle, &write_auth_succes_reply);
|
||||||
|
|
||||||
GattWriteCallbackParams writeParams = {
|
GattWriteCallbackParams writeParams = {
|
||||||
.connHandle = conn_handle,
|
.connHandle = conn_handle,
|
||||||
|
@ -751,7 +742,7 @@ uint16_t nRF5xGattServer::getBiggestCharacteristicSize() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
nRF5xGattServer::long_write_request_t* nRF5xGattServer::allocateLongWriteRequest(uint16_t connection_handle) {
|
nRF5xGattServer::long_write_request_t* nRF5xGattServer::allocateLongWriteRequest(uint16_t connection_handle) {
|
||||||
for (size_t i = 0; i < TOTAL_CONCURENT_LONG_WRITE_REQUEST; ++i) {
|
for (size_t i = 0; i < TOTAL_CONCURRENT_LONG_WRITE_REQUESTS; ++i) {
|
||||||
long_write_request_t& req = long_write_requests[i];
|
long_write_request_t& req = long_write_requests[i];
|
||||||
if (req.data == NULL) {
|
if (req.data == NULL) {
|
||||||
uint16_t block_size = getBiggestCharacteristicSize();
|
uint16_t block_size = getBiggestCharacteristicSize();
|
||||||
|
@ -780,7 +771,7 @@ bool nRF5xGattServer::releaseLongWriteRequest(uint16_t connection_handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nRF5xGattServer::long_write_request_t* nRF5xGattServer::findLongWriteRequest(uint16_t connection_handle) {
|
nRF5xGattServer::long_write_request_t* nRF5xGattServer::findLongWriteRequest(uint16_t connection_handle) {
|
||||||
for (size_t i = 0; i < TOTAL_CONCURENT_LONG_WRITE_REQUEST; ++i) {
|
for (size_t i = 0; i < TOTAL_CONCURRENT_LONG_WRITE_REQUESTS; ++i) {
|
||||||
long_write_request_t& req = long_write_requests[i];
|
long_write_request_t& req = long_write_requests[i];
|
||||||
if (req.data != NULL && req.conn_handle == connection_handle) {
|
if (req.data != NULL && req.conn_handle == connection_handle) {
|
||||||
return &req;
|
return &req;
|
||||||
|
@ -791,7 +782,7 @@ nRF5xGattServer::long_write_request_t* nRF5xGattServer::findLongWriteRequest(uin
|
||||||
}
|
}
|
||||||
|
|
||||||
void nRF5xGattServer::releaseAllWriteRequests() {
|
void nRF5xGattServer::releaseAllWriteRequests() {
|
||||||
for (size_t i = 0; i < TOTAL_CONCURENT_LONG_WRITE_REQUEST; ++i) {
|
for (size_t i = 0; i < TOTAL_CONCURRENT_LONG_WRITE_REQUESTS; ++i) {
|
||||||
long_write_request_t& req = long_write_requests[i];
|
long_write_request_t& req = long_write_requests[i];
|
||||||
if (req.data != NULL) {
|
if (req.data != NULL) {
|
||||||
free(req.data);
|
free(req.data);
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
private:
|
private:
|
||||||
const static unsigned BLE_TOTAL_CHARACTERISTICS = 20;
|
const static unsigned BLE_TOTAL_CHARACTERISTICS = 20;
|
||||||
const static unsigned BLE_TOTAL_DESCRIPTORS = 8;
|
const static unsigned BLE_TOTAL_DESCRIPTORS = 8;
|
||||||
const static unsigned TOTAL_CONCURENT_LONG_WRITE_REQUEST = 3;
|
const static unsigned TOTAL_CONCURRENT_LONG_WRITE_REQUESTS = 3;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct long_write_request_t {
|
struct long_write_request_t {
|
||||||
|
@ -124,7 +124,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a long write request from a characteristic handle
|
* Find a long write request from a characteristic handle
|
||||||
* @param connection_handle The connection handle associated with the reauest.
|
* @param connection_handle The connection handle associated with the request.
|
||||||
* @return a pointer to the request if found otherwise NULL.
|
* @return a pointer to the request if found otherwise NULL.
|
||||||
*/
|
*/
|
||||||
long_write_request_t* findLongWriteRequest(uint16_t connection_handle);
|
long_write_request_t* findLongWriteRequest(uint16_t connection_handle);
|
||||||
|
@ -140,7 +140,7 @@ private:
|
||||||
GattAttribute *p_descriptors[BLE_TOTAL_DESCRIPTORS];
|
GattAttribute *p_descriptors[BLE_TOTAL_DESCRIPTORS];
|
||||||
uint8_t descriptorCount;
|
uint8_t descriptorCount;
|
||||||
uint16_t nrfDescriptorHandles[BLE_TOTAL_DESCRIPTORS];
|
uint16_t nrfDescriptorHandles[BLE_TOTAL_DESCRIPTORS];
|
||||||
long_write_request_t long_write_requests[TOTAL_CONCURENT_LONG_WRITE_REQUEST];
|
long_write_request_t long_write_requests[TOTAL_CONCURRENT_LONG_WRITE_REQUESTS];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allow instantiation from nRF5xn when required.
|
* Allow instantiation from nRF5xn when required.
|
||||||
|
|
Loading…
Reference in New Issue