@pepperdash/mobile-control-react-app-core 1.24.0-feat-essentials-v3.4 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,39 +1,109 @@
1
1
  # Mobile Control React App Core Library
2
2
 
3
- This library uses vite for React.
3
+ This library provides the necessary building blocks for developing React apps for [PepperDash Mobile Control](https://github.com/PepperDash/epi-essentials-mobile-control) systems. It is built with Vite and includes:
4
4
 
5
- The purpose of this library is to provide the necessary building blocks to make developing React apps for Mobile Control easier and more efficient.
6
-
7
- Primarily, it provides a series of React hooks that handle API interaction with corresponding messengers in the [Essentials Mobile Control Plugin](https://github.com/PepperDash/epi-essentials-mobile-control) (or other Essentials plugins) as well as typescript interfaces for the device state objects that each messenger uses.
8
-
9
- In addition, it also provides some core React components that can be consumed by a React App and deal with the particulars of running an HTML5 app on a touch device and allow interaction between button events to achieve press/hold/release functionality commonly necessary for things like ramping volume controls or sending IR commands.
10
-
11
- At the core of this library is a React Context that is intended to generate a websocket client that handles all the messaging to and from the Mobile Control Plugin. Along with that context, Redux is used to handle maintining the state for the room and all devices relevant to the current session. Redux selectors are provided for accessing common data in the store by room or device.
5
+ - **React hooks** Handle API interaction with corresponding messengers in the Essentials Mobile Control Plugin (or other Essentials plugins)
6
+ - **TypeScript interfaces** — Typed device state objects for each messenger
7
+ - **Core React components** Handle touch device interaction, including press/hold/release functionality needed for things like volume ramping and IR commands
8
+ - **WebSocket context** — Generates and manages a WebSocket client for all messaging between the app and the Mobile Control Plugin
9
+ - **Redux store** Maintains room and device state for the current session, with selectors for accessing data by room or device
12
10
 
13
11
  ## How Mobile Control Works
14
12
 
15
- Mobile control uses a websocket to allow JSON formatted messages to be passed between the client app, running in React, and the Essentials Control System application.
16
-
17
- When the client initially connects to the control system, it makes an HTTP call to join a particular room. The response to that call provides the React app with the necessary information to connect to the websocket server. The server can either be running directly on the Crestron control system processor or it can also be running on the Mobile Control Edge Server, which then acts as a message relay to the control system.
18
-
19
- Once a websocket connection is established, the React app must then request the room state and configuration which it will subsequently use to determine which device states it needs to request from the control system.
20
-
21
- Supplied in this library is a hook (useGetAllDeviceStateFromRoomConfiguration) that takes a RoomConfiguration object and will then iterate the devices for that room and request their current full status. This hook should be called at the root level of the React App.
13
+ Mobile Control uses a WebSocket to pass JSON messages between a React client and the Essentials control system application. The connection flow is:
22
14
 
23
- From that point forward, room and device state messages from the control system will be partial objects and will get overlayed onto the room/device state object in the store.
15
+ 1. The client makes an HTTP call to join a room on the control system
16
+ 2. The response provides the information needed to open a WebSocket connection
17
+ 3. The WebSocket server can run directly on the Crestron processor or on the Mobile Control Edge Server (which relays messages to the processor)
18
+ 4. Once connected, the app requests the room state and configuration
19
+ 5. The app uses that configuration to determine which device states to request — the `useGetAllDeviceStateFromRoomConfiguration` hook handles this automatically and should be called at the root level of your app
20
+ 6. From that point on, room and device state updates arrive as partial objects and are merged into the Redux store
24
21
 
25
22
  ## How this Library is Intended to be Used
26
23
 
27
- The intent is to use the various hooks provided in this library to easily link up to buttons and other elements on an HTML5 UI in a React App to handle the heavy lifting of integrating with the Mobile Control API. This library will provide hooks for the messengers in the Mobile Control plugin, but you will also be able to write hooks in the React App for custom API that can integrate directly with a messenger defined in any Essentials room or device plugin. This allows consistency with the core communication that most systems will rely on, while also providing easy customization and extensibility for more esoteric or application specific needs that may not see wide use and justify inclusion in this library.
24
+ Use the provided hooks to link buttons and UI elements to the Mobile Control API without managing the communication layer directly:
28
25
 
29
- # How to Set up Your Development Environment
30
-
31
- Run `npm install` to install the required dependencies.
32
-
33
- Load an instance of an Essentials v2.x program as well as the Essentials Mobile Control plugin v4.x to a Crestron program slot. Consult the Mobile Control plugin for direct server plugin configuration instructions.
26
+ - **Core hooks** (provided here) Cover the standard messengers in the Mobile Control Plugin and handle the common needs of most systems
27
+ - **Custom hooks** (written in your app) — Can integrate directly with any messenger defined in an Essentials room or device plugin, enabling extensibility for application-specific or esoteric needs without requiring changes to this library
34
28
 
35
- Copy the `/public/_local-config/_config.default.json` to a file called `/public/_local-config/_config.local.json` and modify the `apiPath` value to point to the IP address of your test processor as well as the correct port. This file should *not* be added to the git repository because it applies only to your local test environment.
36
-
37
- Run the app with `npm run dev` which will start the development server. The vite development server will then print it's local URL (eg: http://localhost:5173/mc/app). Open this URL in a browser. Initially you will just get a message saying that the client is disconnected. You will need to supply a token in the url as a search param that will associate your client with a particular client instance on the Mobile Control server. To get a token, run the `mobileinfo:[programSlot]` console command on the Crestron processor and copy the token value associated with the client instance you want your development client to connect to and paste it into the url as the token value (eg: http://localhost:5173/mc/app?token=[some-token-value]).
29
+ # How to Set up Your Development Environment
38
30
 
39
- Your development client instance should now connect to the websocket server running on the Crestron program.
31
+ ### Prerequisites
32
+
33
+ - Essentials v2.x program loaded to a Crestron program slot
34
+ - Essentials Mobile Control Plugin v4.x configured in that program (consult the plugin docs for server configuration)
35
+
36
+ ### Steps
37
+
38
+ 1. Install dependencies:
39
+ ```bash
40
+ npm install
41
+ ```
42
+
43
+ 2. Create a local config file by copying the default:
44
+ ```
45
+ /public/_local-config/_config.default.json → /public/_local-config/_config.local.json
46
+ ```
47
+ Update the `apiPath` value to the IP address and port of your test processor. **Do not commit this file** — it is gitignored.
48
+
49
+ Example `_config.local.json`:
50
+ ```json
51
+ {
52
+ "apiPath": "http://192.168.1.22:50010/mc/api",
53
+ "gatewayAppPath": "",
54
+ "enableDev": false,
55
+ "logoPath": "logo/PDT-logo-no-tag_blue-pdt-on-transp_1000px.png",
56
+ "loginMode": "room-list",
57
+ "iconSet": "GOOGLE",
58
+ "modes": {
59
+ "room-list": {
60
+ "listPageText": "Please select your room",
61
+ "loginHelpText": "Please select your room from the list, then enter the code shown on the display in the room. (Configurable message)",
62
+ "passcodePageText": "Please enter the code shown on this room's display"
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ 3. Start the development server:
69
+ ```bash
70
+ npm run dev
71
+ ```
72
+
73
+ 4. Open the printed local URL in a browser (e.g. `http://localhost:5173/mc/app`). You will see a disconnected message until a token is provided.
74
+
75
+ 5. Get a connection token from the Crestron processor by running the console command:
76
+ ```
77
+ mobileinfo:[programSlot]
78
+ ```
79
+ Example output:
80
+ ```
81
+ mobileadduiclient:1 room1 1234567890abcdefghijk
82
+ mobileinfo
83
+
84
+ Mobile Control Edge Server API Information:
85
+ Not Enabled in Config.
86
+
87
+ Mobile Control Direct Server Infromation:
88
+ User App URL: http://10.11.50.177:50001/mc/app?token=[insert_client_token]
89
+ Server port: 50001
90
+
91
+ UI Client Info:
92
+ Tokens Defined: 1
93
+ Clients Connected: 0
94
+
95
+ Client 1:
96
+ Room Key: room1
97
+ Token: f0f19b7e-606a-4f91-875e-7847e28bc709
98
+ Client URL: http://10.11.50.177:50001/mc/app?token=f0f19b7e-606a-4f91-875e-7847e28bc709
99
+ Connected: False
100
+ Duration: Not Connected
101
+ ```
102
+ Copy the token value for the client instance you want to connect to.
103
+
104
+ 6. Append the token to the URL and reload:
105
+ ```
106
+ http://localhost:5173/mc/app?token=[your-token-value]
107
+ ```
108
+
109
+ Your development client will now connect to the WebSocket server running on the Crestron program.