npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hakkei/webdfu

v0.2.0

Published

Driver for working with DFU in a browser over Web USB

Downloads

4

Readme

WebDFU

References

  • https://github.com/Flipper-Zero/webdfu/ (2021)
  • https://github.com/devanlai/webdfu (2017)

NPM package CI in main branch

  • Reading and writing the current device firmware by DFU 1.1
  • Switching from the runtime configuration to the DFU bootloader (DFU detach)

Install

npm i @hakkei/webdfu

Usage

Full example in: webdfu/demo

Demo: https://dfu.hakkei.wiki

WebDFU

Properties

  • events: An instance of NanoEvents that can be used to listen for different events, such as init, connect, and disconnect.
  • interfaces: An array of WebDFUSettings objects representing the DFU interfaces present on the device.
  • properties: An object containing the properties of the DFU functional descriptor, if present.
  • connected: A boolean indicating whether the class is currently connected to a device.
  • currentInterfaceSettings: The settings of the currently selected DFU interface.

Methods

constructor(device: USBDevice, settings?: WebDFUOptions, log?: WebDFULog)

Creates a new instance of the WebDFU class.

get type(): number

Returns the type of DFU interface, either WebDFUType.DFU or WebDFUType.SDFUse

async init(): Promise<void>

Initializes the class by finding the DFU interfaces present on the device.

async connect(interfaceIndex: number): Promise<void>

Connects to the specified DFU interface on the device. Throws an error if the interface is not found or if there is an error connecting.

async close(): Promise<void>

Closes the connection to the device and emits a disconnect event.

read(xferSize: number, maxSize: number): WebDFUProcessRead

Reads data from the device with a specified transfer size and maximum size. Returns a WebDFUProcessRead object that can be used to listen for events such as end and error.

write(xfer_size: number, data: ArrayBuffer, manifestationTolerant: boolean): WebDFUProcessWrite

Writes data to the device with a specified transfer size and a boolean indicating whether the write should be manifestation tolerant. Returns a WebDFUProcessWrite object that can be used to listen for events such as end and error.

private async getDFUDescriptorProperties(): Promise<WebDFUProperties | null>

Attempts to read the DFU functional descriptor from the device. Returns an object containing the properties of the descriptor, or null if the descriptor is not present.

private async findDfuInterfaces(): Promise<WebDFUSettings[]>

Searches for DFU interfaces on the device and returns an array of WebDFUSettings objects.

private async fixInterfaceNames(interfaces: WebDFUSettings[]): Promise<void>

Forces the interface names of the device if specified by the settings.

private async readStringDescriptor(index: number, langID = 0)

Reads the string descriptor with the specified index and language ID from the device. Returns the descriptor as an array of 16-bit words if langID is 0, otherwise returns the descriptor as a string.

private async readDeviceDescriptor(): Promise<DataView>

Reads the device descriptor from the device. Returns a DataView object.

private async readInterfaceNames()

Reads the interface names from the device and returns an object that maps the interface index to the corresponding interface name.