Skip to content

Commit

Permalink
Added LICENSE and README
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenkingston committed Sep 11, 2020
1 parent 3f1dc76 commit d2e9073
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2020, Stephen Kingston
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# WebMTP
This is a proof-of-concept implementation of the MTP protocol over WebUSB. Works with all [browsers which support WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/USB)

## Setup

### Windows

Replace default MTP driver with WinUSB driver.

- Download [Zadig](https://zadig.akeo.ie/).
- Open Zadig and select `Options → List All Devices`.
- Select your MTP device from list of devices and install WinUSB driver by clicking `Replace Driver`

![](media/install_winusb_driver.png)

### Linux

Requires `udev` rule to be installed

Find Vendor ID and Product ID using `lsusb`

```bash
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 22b8:2e82 Motorola Device
```
Add a file `/etc/udev/rules.d/webmtp.rules` with the below content. Use your phone's Vendor ID & Product ID.
```
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", ATTRS{idProduct}=="2e82", ACTION=="add", MODE="0666"
```
Reload `udev` rules
```bash
$ sudo udevadm control --reload-rules
```
## Supported Operations
- Reading list of storages and files.
- Downloading & uploading files.
- Deleting files.

## Known limitations
- Works with root folder only
- Renaming files not supporte
- Not tested with large files

___
### Stephen Kingston © 2020
7 changes: 7 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright (C) 2020 Stephen Kingston
*
* SPDX-License-Identifier: BSD-2-Clause
*
*/

const inputElement = document.getElementById("fileInput");
const progressBar = document.getElementById("progress-bar");
const transferPopup = document.getElementById("transferPopup");
Expand Down
Binary file added media/install_winusb_driver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions mtp/mtp_classes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright (C) 2020 Stephen Kingston
*
* SPDX-License-Identifier: BSD-2-Clause
*
*/

/* Container Type */
const CONTAINER_TYPE_UNDEFINED = 0x0000;
const MTP_CONTAINER_TYPE_COMMAND = 0x0001;
Expand Down
7 changes: 7 additions & 0 deletions mtp/mtp_operations.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright (C) 2020 Stephen Kingston
*
* SPDX-License-Identifier: BSD-2-Clause
*
*/

/* This library file contains high-level functions derived from mtp_classes.mtp */
let device = null;

Expand Down

0 comments on commit d2e9073

Please sign in to comment.