summaryrefslogtreecommitdiff
path: root/examples/device/mtp/src/mtp_fs_example.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-09-27 16:15:04 +0700
committerhathach <[email protected]>2025-09-27 17:08:21 +0700
commitcb21ca1b0cb3221341dca2559109c0bb4dc18e6f (patch)
treeaba4e31d802be53361d16c94150bf4fe110dbb0f /examples/device/mtp/src/mtp_fs_example.c
parentf9d4bc798177e63532cd5a2ef058400d6f0ef5e4 (diff)
implement control request
Diffstat (limited to 'examples/device/mtp/src/mtp_fs_example.c')
-rw-r--r--examples/device/mtp/src/mtp_fs_example.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/examples/device/mtp/src/mtp_fs_example.c b/examples/device/mtp/src/mtp_fs_example.c
index a13acfcdd..9d90f7663 100644
--- a/examples/device/mtp/src/mtp_fs_example.c
+++ b/examples/device/mtp/src/mtp_fs_example.c
@@ -23,7 +23,6 @@
*
*/
-#include "class/mtp/mtp_device_storage.h"
#include "tusb.h"
#include "tinyusb_logo_png.h"
@@ -189,6 +188,40 @@ static inline uint8_t* fs_malloc(size_t size) {
}
//--------------------------------------------------------------------+
+// Control Request callback
+//--------------------------------------------------------------------+
+bool tud_mtp_request_cancel_cb(tud_mtp_request_cb_data_t* cb_data) {
+ mtp_request_reset_cancel_data_t cancel_data;
+ memcpy(&cancel_data, cb_data->buf, sizeof(cancel_data));
+ (void) cancel_data.code;
+ (void ) cancel_data.transaction_id;
+ return true;
+}
+
+// Invoked when received Device Reset request
+// return false to stall the request
+bool tud_mtp_request_device_reset_cb(tud_mtp_request_cb_data_t* cb_data) {
+ (void) cb_data;
+ return true;
+}
+
+// Invoked when received Get Extended Event request. Application fill callback data's buffer for response
+// return negative to stall the request
+int32_t tud_mtp_request_get_extended_event_cb(tud_mtp_request_cb_data_t* cb_data) {
+ (void) cb_data;
+ return false; // not implemented yet
+}
+
+// Invoked when received Get DeviceStatus request. Application fill callback data's buffer for response
+// return negative to stall the request
+int32_t tud_mtp_request_get_device_status_cb(tud_mtp_request_cb_data_t* cb_data) {
+ uint16_t* buf16 = (uint16_t*)(uintptr_t) cb_data->buf;
+ buf16[0] = 4; // length
+ buf16[1] = MTP_RESP_OK; // status
+ return 4;
+}
+
+//--------------------------------------------------------------------+
// Bulk Only Protocol
//--------------------------------------------------------------------+
int32_t tud_mtp_command_received_cb(tud_mtp_cb_data_t* cb_data) {
@@ -531,9 +564,3 @@ int32_t tud_mtp_response_complete_cb(tud_mtp_cb_data_t* cb_data) {
(void) cb_data;
return 0; // nothing to do
}
-
-void tud_mtp_storage_cancel(void) {
-}
-
-void tud_mtp_storage_reset(void) {
-}