* @brief Set USB transfer mode. */
| 127 | * @brief Set USB transfer mode. |
| 128 | */ |
| 129 | API::CommandResponse API::Handlers::USBHandler::setTransferMode(const QString& id, |
| 130 | const QJsonObject& params) |
| 131 | { |
| 132 | if (!params.contains(QStringLiteral("mode"))) { |
| 133 | return CommandResponse::makeError( |
| 134 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: mode")); |
| 135 | } |
| 136 | |
| 137 | const int mode = params.value(QStringLiteral("mode")).toInt(); |
| 138 | if (mode < 0 || mode > 2) { |
| 139 | return CommandResponse::makeError( |
| 140 | id, |
| 141 | ErrorCode::InvalidParam, |
| 142 | QStringLiteral("Invalid mode: %1. Valid values: 0=Bulk, 1=Advanced, 2=Isochronous") |
| 143 | .arg(mode)); |
| 144 | } |
| 145 | |
| 146 | IO::ConnectionManager::instance().usb()->setTransferMode(mode); |
| 147 | |
| 148 | QJsonObject result; |
| 149 | result[QStringLiteral("mode")] = mode; |
| 150 | return CommandResponse::makeSuccess(id, result); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * @brief Select the active IN endpoint. |