Constructs an instance of the FrameMsg class. Initializes a new FrameBle instance and sets up internal data response handling.
The underlying FrameBle instance used for Bluetooth Low Energy communication.
Attaches a handler for print responses from the Frame device. This handler will be called with any text data printed by Lua scripts on the device.
A function to handle the print response string. Defaults to console.log.
Connects to the Frame device and optionally runs the initialization sequence.
Note: Print and Disconnect handlers should be set directly on the FrameBle instance
(e.g., frameMsg.ble.setPrintResponseHandler(...), frameMsg.ble.setDisconnectHandler(...))
or via frameMsg.attachPrintResponseHandler(...) before or after calling connect.
If true, runs the break/reset/break sequence after connecting. Defaults to true.
Options including name and namePrefix for device filtering.
The device ID or name if connection was successful.
Detaches the currently set print response handler. After calling this, print responses from the device will no longer be processed by a custom handler.
Disconnects from the Frame device if currently connected.
A Promise that resolves when disconnection is complete.
Gets the maximum payload size for sending data to the Frame device.
This is a proxy to FrameBle.getMaxPayload().
True if the payload is for a Lua command, false for other data types.
The maximum payload size in bytes.
Checks if the Frame device is currently connected.
True if connected, false otherwise.
Displays a short string of text on the Frame's display. The text is sanitized to escape single quotes and remove newlines.
The text to display. Defaults to an empty string.
A Promise that resolves with the print response from the device if awaitPrint is true (default), otherwise void.
Registers a handler for a subscriber interested in specific message codes from Frame.
The subscriber object/identifier.
Array of message codes the subscriber is interested in.
The function to call with the incoming data (Uint8Array).
Sends a break signal (Ctrl+C) to the Frame device.
This is a proxy to FrameBle.sendBreakSignal().
If true, prints a message to the console indicating the signal was sent. Defaults to false.
A Promise that resolves when the signal has been sent.
Sends raw data to the device.
The Uint8Array payload to send.
Configuration options.
A Promise that resolves with the Uint8Array data response if awaitData is true, or void.
Sends a Lua command string to the Frame device.
This is a proxy to FrameBle.sendLua().
The Lua command string to send.
Configuration options for sending the Lua command.
A Promise that resolves with the print response if awaitPrint is true, otherwise void.
Sends a message (msg_code and payload) to the Frame device.
The message code (an integer identifying the message type).
The Uint8Array payload for the message.
If true, prints the message being sent to the console. Defaults to false.
A Promise that resolves when the message has been sent.
Sends a reset signal to the Frame device.
This is a proxy to FrameBle.sendResetSignal().
If true, prints a message to the console indicating the signal was sent. Defaults to false.
A Promise that resolves when the signal has been sent.
Starts a Frame application on the device by requiring its module name.
The name of the Frame application module (without .lua extension). Defaults to 'frame_app'.
Whether to wait for a print response from the device. Defaults to true.
A Promise that resolves with the print response if awaitPrint is true, otherwise void.
Stops the currently running Frame application by sending a break signal. Optionally, it can also reset the device.
If true, sends a reset signal after the break signal. Defaults to true.
A Promise that resolves when the signals have been sent.
Unregisters all data response handlers associated with a specific subscriber.
The subscriber object/identifier whose handlers should be removed.
Uploads a Frame application (Lua script) to the device.
The content of the Lua application file as a string.
The target filename on the Frame device. Defaults to 'frame_app.lua'.
A Promise that resolves when the file has been uploaded.
FrameMsg class handles communication with the Frame device. It wraps the FrameBle class and provides higher-level methods for uploading standard Lua libraries and Frame applications. It also manages the registration and unregistration of data response handlers for different Rx message types. Subscribers can register their own handlers for specific message codes.