.. _module-pw_web: --------- pw_web --------- Pigweed provides an NPM package with modules to build web UIs for Pigweed devices. Also included is a basic React app that demonstrates using the npm package. Available Modules ============================= Following Pigweed modules are included in the NPM package: - `pw_hdlc `_ - `pw_rpc `_ - `pw_tokenizer `_ - `pw_transfer `_ To help with connecting to WebSerial and listening for serial data, a helper class is also included under ``WebSerial.WebSerialTransport``. Here is an example usage: .. code:: javascript import { WebSerial, pw_hdlc } from 'pigweedjs'; const transport = new WebSerial.WebSerialTransport(); const decoder = new pw_hdlc.Decoder(); // Present device selection prompt to user await transport.connect(); // Listen and decode HDLC frames transport.chunks.subscribe((item) => { const decoded = decoder.process(item); for (const frame of decoded) { if (frame.address === 1) { const decodedLine = new TextDecoder().decode(frame.data); console.log(decodedLine); } } }); Installation ============= You can install ``pigweedjs`` in your web application by: .. code:: bash $ npm install --save pigweedjs Getting Started ================ After installing, you can import modules from ``pigweedjs`` in this way: .. code:: javascript import { pw_rpc, pw_tokenizer } from 'pigweedjs'; Click on each module above to see its usage.