mirror of https://github.com/ARMmbed/mbed-os.git
style fix
parent
b979c4a2c8
commit
cdbead87ea
|
@ -1081,20 +1081,19 @@ ble_error_t GenericGattClient::write(
|
|||
return BLE_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
uint16_t mtu = get_mtu(connection_handle);
|
||||
uint16_t mtu = get_mtu(connection_handle);
|
||||
|
||||
if (cmd == GattClient::GATT_OP_WRITE_CMD) {
|
||||
if (length > (uint16_t)(mtu - WRITE_HEADER_LENGTH)) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
return _pal_client->write_without_response(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
make_const_ArrayView(value, length)
|
||||
);
|
||||
} else if (cmd == GattClient::GATT_OP_SIGNED_WRITE_CMD) {
|
||||
|
||||
if (length > (uint16_t)(mtu - WRITE_HEADER_LENGTH - CMAC_LENGTH - MAC_COUNTER_LENGTH)) {
|
||||
if (cmd == GattClient::GATT_OP_WRITE_CMD) {
|
||||
if (length > (uint16_t) (mtu - WRITE_HEADER_LENGTH)) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
return _pal_client->write_without_response(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
);
|
||||
} else if (cmd == GattClient::GATT_OP_SIGNED_WRITE_CMD) {
|
||||
/*TODO check encryption status */
|
||||
if (length > (uint16_t) (mtu - WRITE_HEADER_LENGTH - CMAC_LENGTH - MAC_COUNTER_LENGTH)) {
|
||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||
}
|
||||
return _pal_client->signed_write_without_response(
|
||||
|
@ -1102,56 +1101,56 @@ ble_error_t GenericGattClient::write(
|
|||
attribute_handle,
|
||||
make_const_ArrayView(value, length)
|
||||
);
|
||||
} else {
|
||||
uint8_t* data = NULL;
|
||||
} else {
|
||||
uint8_t* data = NULL;
|
||||
|
||||
if (length > (uint16_t)(mtu - WRITE_HEADER_LENGTH)) {
|
||||
data = (uint8_t*) malloc(length);
|
||||
if (data == NULL) {
|
||||
return BLE_ERROR_NO_MEM;
|
||||
}
|
||||
memcpy(data, value, length);
|
||||
}
|
||||
if (length > (uint16_t) (mtu - WRITE_HEADER_LENGTH)) {
|
||||
data = (uint8_t*) malloc(length);
|
||||
if (data == NULL) {
|
||||
return BLE_ERROR_NO_MEM;
|
||||
}
|
||||
memcpy(data, value, length);
|
||||
}
|
||||
|
||||
WriteControlBlock* write_pcb = new(std::nothrow) WriteControlBlock(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
data,
|
||||
length
|
||||
);
|
||||
WriteControlBlock* write_pcb = new (std::nothrow) WriteControlBlock(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
data,
|
||||
length
|
||||
);
|
||||
|
||||
if (write_pcb == NULL) {
|
||||
free(data);
|
||||
return BLE_ERROR_NO_MEM;
|
||||
}
|
||||
if (write_pcb == NULL) {
|
||||
free(data);
|
||||
return BLE_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
insert_control_block(write_pcb);
|
||||
insert_control_block(write_pcb);
|
||||
|
||||
ble_error_t err = BLE_ERROR_UNSPECIFIED;
|
||||
if (data) {
|
||||
err = _pal_client->queue_prepare_write(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
make_const_ArrayView(value, mtu - PREPARE_WRITE_HEADER_LENGTH),
|
||||
/* offset */ 0
|
||||
);
|
||||
} else {
|
||||
err = _pal_client->write_attribute(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
make_const_ArrayView(value, length)
|
||||
);
|
||||
}
|
||||
ble_error_t err = BLE_ERROR_UNSPECIFIED;
|
||||
if (data) {
|
||||
err = _pal_client->queue_prepare_write(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
make_const_ArrayView(value, mtu - PREPARE_WRITE_HEADER_LENGTH),
|
||||
/* offset */0
|
||||
);
|
||||
} else {
|
||||
err = _pal_client->write_attribute(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
make_const_ArrayView(value, length)
|
||||
);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
remove_control_block(write_pcb);
|
||||
delete write_pcb;
|
||||
}
|
||||
if (err) {
|
||||
remove_control_block(write_pcb);
|
||||
delete write_pcb;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void GenericGattClient::onServiceDiscoveryTermination(
|
||||
|
|
Loading…
Reference in New Issue