/*host send message*/ tBleStatus ble_host_send(uint8_t type, uint32_t length, uint8_t* value) { tBleStatus ret; uint8_t packet[20]; if(host_notification_enabled == FALSE) { return BLE_WAIT_ENABLE_NOTIFY; } if (length > 18) length = 18; packet[0] = type; packet[1] = length; memcpy(packet + 2, value, length); ret = aci_gatt_write_charac_value(connection_handle, write_handle+1, packet[1]+2, packet); if (ret != BLE_STATUS_SUCCESS) { return BLE_STATUS_ERROR ; } return ret; }
ble_error_t BlueNRGGattClient::write(GattClient::WriteOp_t cmd, Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, size_t length, const uint8_t *value) const { /* avoid compiler warnings about unused variables */ (void)cmd; tBleStatus ret; BlueNRGGattClient *gattc = const_cast<BlueNRGGattClient*>(this); gattc->_currentState = GATT_WRITE_CHAR; // We save the write response params (used by the callback) because // when the aci_gatt_write_charac_value() is used the only event received is the EVT_BLUE_GATT_PROCEDURE_COMPLETE gattc->writeCBParams.connHandle = connHandle; gattc->writeCBParams.writeOp = GattWriteCallbackParams::OP_WRITE_CMD; gattc->writeCBParams.handle = attributeHandle; gattc->writeCBParams.offset = 0; gattc->writeCBParams.len = length; gattc->writeCBParams.data = value; ret = aci_gatt_write_charac_value(connHandle, attributeHandle, length, const_cast<uint8_t *>(value)); //ret = aci_gatt_write_charac_reliable(connHandle, attributeHandle, 0, length, const_cast<uint8_t *>(value)); if (ret == BLE_STATUS_SUCCESS) { return BLE_ERROR_NONE; } switch (ret) { case BLE_STATUS_BUSY: return BLE_STACK_BUSY; default: return BLE_ERROR_INVALID_STATE; } }