Paired development
Pair one MMPKG with one GMP as a single application when the phone needs a business page and the glasses need custom logic.
Run the existing Display Control Lab first#
Run the unified build once from the complete toolkit root. The script handles changes on both the glasses and Web sides automatically; you do not need to specify the two Display Control Lab example directories separately.
This example sends a limited set of control commands from a Web page. The GMP calls Host display-control APIs and returns status to the phone.
- In Studio, select Display Control Lab for both the phone and glasses, and check both selections.
- Adjust a value in the phone preview and confirm that a status reply arrives. The simulator does not reproduce the physical optical effect.
- After scanning on the phone, verify display control on the physical glasses. Check button-based recovery and the exit path after turning off the display.
macOS / Linux
./build.pyWindows PowerShell
py build.pyWhat to change when copying a paired example#
| File | What to change |
|---|---|
| PhoneSDK/examples/display-control-lab/manifest.json | Your Web id/name/version; deviceRequirements targeting the GMP's id/protocol; and device.messaging declarations for request and response channels. |
| GlassSDK/examples/display_control_lab/manifest.json | Your glasses id/name/numeric version; provides.protocols matching the Web requirements. |
| PhoneSDK/examples/display-control-lab/display-control-protocol.js | Command IDs, channels, field layouts, and result decoding. |
| GlassSDK/examples/display_control_lab/ | Check the corresponding command parsing, Host calls, and reply code. Do not change only one side. |
The messaging path#
Web sends a request with gm.plugin.sendMessage(channel, Uint8Array). The GMP handles GM_PLUGIN_EVENT_BT_MESSAGE in on_event and replies with host->bt_send(channel, data, length). Web receives the reply through gm.plugin.onMessage(listener).
- A channel is a uint16 application-defined ID, not an IP port. Both request and response channels must appear in device.messaging.scope.channels.
- Display Control Lab uses 17475 / 17476. Declaring only the request channel causes requests to be sent without receiving replies.
- Version formats can differ: Web uses semantic versions, while glasses examples use numeric versions. Identical version numbers are not a pairing requirement.
- Use request IDs, timeouts, and error results to avoid waiting indefinitely. Start with the example protocol; do not send low-level installation-protocol messages yourself.
Add acknowledgments and disconnection handling#
Display Control Lab uses requestId to match commands with status returned by the glasses and queries again after reconnection. Preserve this logic when copying the project. A successful send only means the message was submitted to the transport layer; you must also check the glasses' business result.
Why Studio reports a pairing mismatch#
| Web deviceRequirements field | Meaning | How to fix it |
|---|---|---|
| requiredPluginId | Select the glasses plugin with this ID. An identical display name cannot substitute for an ID match. | Check GMP manifest.id and update the requirements when copying a paired project. |
| preferredPluginId | Provides a preference for automatic selection. All other mandatory conditions still apply. | With multiple candidates, check the actual selection rather than just the recommended name. |
| minPluginVersion | Sets a minimum target glasses-plugin version when requiredPluginId is specified. | Build a GMP that meets the requirement. Do not copy the Web version string into the glasses' numeric version field. |
| protocols | The target GMP's provides.protocols must satisfy every protocol ID and minimum version. | Keep protocol implementations consistent with their declarations. Do not just delete a declaration to hide an error. |
Reference files in the toolkit#
- GlassSDK/docs/PROTOCOL_COMPATIBILITY.md
- PhoneSDK/examples/display-control-lab/README.md
- GlassSDK/examples/display_control_lab/manifest.json