Choose where the web page lives

… visits
Parent Previous Next

You can keep a small page in the PIC, or keep the HTML on the PC so it is easier to edit. The same value and command APIs serve both choices.

Start with the supplied HTML

The RNDIS folder includes Built In Pages and External Page, with HTML pages matching the test firmware. Copy the page for the example you are using, get that pair working, then change the layout. The folder guide explains when an HTML edit needs a new firmware build.

Built-in and custom firmware pages

Page layout menu offering Built-in page, Custom pages (page 1 at /), Built-in / + named pages, and External HTML (data only).

Choose where your browser page will live. Use Built-in page for the first test; choose a custom layout when you are ready to import your own HTML. Use this picture to find the controls; generate your own code and memory settings. Do not copy the pictured allocation figures.

Page layout

What the browser can open

Built-in page — mode 0

/ displays the supplied page. No page table is needed. Named output fields are displayed automatically.

Custom pages (page 1 at /) — mode 1

/ and page 1's named URL display page 1. Other enabled pages have their own named URLs.

Built-in / + named pages — mode 2

/ keeps the supplied page; each custom page has a named URL.

External HTML (data only) — mode 3

The PIC stores no HTML. / returns 404; /status and enabled /write remain available.

Import your page into the PIC

To put your own page inside the firmware:

Network tab with a three-page calculator project, Custom pages layout, page 1 named main, and imported home.html shown in the HTML preview.

An imported page appears in the preview. Here page 1 is named main and opens at both /main and /. Copy the updated Integration output so the page tables and their sizes stay together. Use this picture to find the controls; generate your own code and memory settings. Do not copy the pictured allocation figures.

  1. Create a self-contained UTF-8 HTML file. Include CSS and JavaScript inside it. The library does not automatically serve separate image, stylesheet or script files. Use relative data requests such as fetch('/status').
  2. Choose mode 1 or 2 and Firmware pages from 1 through 8.
  3. Select each active page, enter its URL name and import that page's HTML. For example, name a page measurements to open http://192.168.7.1/measurements.
  4. Use 1–24 ASCII letters/digits/dots/underscores/hyphens, starting with a letter or digit. Enter no leading slash. status and write are reserved. Names differing only by case are not allowed as separate pages.
  5. Check each page's size and total flash usage. The maximum per page is 16384 bytes including its HTTP headers. Eight maximum-sized pages are not guaranteed to fit your PIC. Reducing the page count keeps inactive imports in the saved project but excludes them from generated firmware.
  6. Copy Integration, which already includes the settings and page tables. Alternatively, copy the generated settings before the library include and paste the complete Web Include BASIC block after Include "USB_Device.inc", outside procedures. It may be placed before startup or at the bottom of the main listing after your main loop and procedure definitions. Keep its GoTo USB_WebPagesEnd and ending label so execution cannot enter the table bytes. Paste the tables only once.
  7. Recompile and program the PIC whenever a firmware page changes.

Web Include contains generated CData tables in modes 1 and 2, not HTML to paste directly into BASIC. No companion page include or Export Files step is required. Keep the original HTML separately so you can edit and reimport it later. After changing or reimporting a page, regenerate both the configuration definitions and Web Include tables together so the page contents and byte counts agree.


Named page URLs are exact and case-sensitive. A page named measurements is not /Measurements, /measurements/ or /measurements?x=1. A simple link between firmware pages is <a href="/settings">Settings</a> when a page named settings has been imported.

Keep an editable HTML page on the PC

Keep the HTML file on the PC if you want to edit the page without programming the PIC again. Keep the same published field names and command meanings, or update the firmware to match.

  1. Choose External HTML (data only) and leave Allowed page origin as null for a file opened directly on the PC.
  2. Configure outgoing values and input slots normally, then program the generated firmware.
  3. Open Web Include. In this mode it contains HTML, not BASIC tables. Copy it to a UTF-8 .html file and open that file in the browser. You can instead import your own external HTML; the tool retains its contents unchanged. The optional external import limit is 5 MiB, independent of PIC flash.
  4. Make requests to the full PIC address, for example http://192.168.7.1/status. Relative /status points at the page's own location and is wrong for a local file. For the number-and-answer example, set DEVICE = "http://192.168.7.1".
  5. Allow local-network access if your browser requests it. Browser or managed-PC policies can still block direct local-file access; this flow is not guaranteed in every browser. Check the browser console if requests fail.

The external mode supplies CORS response headers so the browser can read responses from the PIC. Its required write header also causes a browser preflight request, which this mode handles. null permits local-file/opaque origins; it does not identify one particular HTML filename.


If your page is already hosted elsewhere, set Allowed page origin to its exact origin, such as https://example.com or http://example.com:8080: scheme, host and optional port, without a path. Do not enter *. HTTPS pages contacting an HTTP-only device may face additional browser restrictions. Changing this setting cannot override those restrictions.


CORS and X-USB-Write are browser-access controls, not user authentication. The device has no password or HTTPS service. Keep this interface local unless you deliberately provide a separate, suitably protected way to reach it.

See also

Created with the Personal Edition of HelpNDoc: Maximize Your Productivity with a Help Authoring Tool