esp-idf-provisioning-web 0.0.1 → 0.0.2

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
@@ -13,7 +13,7 @@ A TypeScript SDK for provisioning ESP32 devices from web browsers using the ESP-
13
13
  - [x] Scan APs
14
14
  - [x] Provision device status monitoring
15
15
  - [ ] Reset and re-provisioning
16
- - [ ] Custom endpoints
16
+ - [x] Custom endpoints
17
17
 
18
18
  ## Browser Compatibility
19
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esp-idf-provisioning-web",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "ESP-IDF WiFi Provisioning SDK for web browsers",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
package/src/ESPDevice.ts CHANGED
@@ -141,6 +141,28 @@ export class ESPDevice implements ESPDeviceInterface {
141
141
  }
142
142
  }
143
143
 
144
+ /**
145
+ * Send custom data to device
146
+ * @param path - Data endpoint path
147
+ * @param data - Data to send
148
+ * @returns Response data from device
149
+ */
150
+ async sendData(path: string, data: Uint8Array): Promise<Uint8Array> {
151
+ if (!this.transportImpl || !this.securityImpl) {
152
+ throw new Error('Device not connected');
153
+ }
154
+
155
+ // Encrypt data if security is established
156
+ const encryptedData = await this.securityImpl.encrypt(data);
157
+ console.debug('Send encrypted data length:', encryptedData.length);
158
+
159
+ // Send encrypted data
160
+ const encryptedResponse = await this.transportImpl.sendData(path, encryptedData);
161
+
162
+ // Decrypt response
163
+ return await this.securityImpl.decrypt(encryptedResponse);
164
+ }
165
+
144
166
  /**
145
167
  * Disconnect from device
146
168
  */
@@ -206,26 +228,4 @@ export class ESPDevice implements ESPDeviceInterface {
206
228
  }
207
229
  await this.transportImpl.connect();
208
230
  }
209
-
210
- /**
211
- * Send custom data to device
212
- * @param path - Data endpoint path
213
- * @param data - Data to send
214
- * @returns Response data from device
215
- */
216
- private async sendData(path: string, data: Uint8Array): Promise<Uint8Array> {
217
- if (!this.transportImpl || !this.securityImpl) {
218
- throw new Error('Device not connected');
219
- }
220
-
221
- // Encrypt data if security is established
222
- const encryptedData = await this.securityImpl.encrypt(data);
223
- console.debug('Send encrypted data length:', encryptedData.length);
224
-
225
- // Send encrypted data
226
- const encryptedResponse = await this.transportImpl.sendData(path, encryptedData);
227
-
228
- // Decrypt response
229
- return await this.securityImpl.decrypt(encryptedResponse);
230
- }
231
231
  }
package/src/types.ts CHANGED
@@ -76,11 +76,13 @@ export interface ESPDeviceInterface {
76
76
 
77
77
  scanWifiList(): Promise<ESPWifiAp[]>;
78
78
 
79
- disconnect(): void;
80
-
81
79
  provision(ssid: string, passphrase: string): Promise<void>;
82
80
 
83
81
  fetchWifiStatus(): Promise<ESPWifiStatus>;
84
82
 
83
+ sendData(path: string, data: Uint8Array): Promise<Uint8Array>;
84
+
85
+ disconnect(): void;
86
+
85
87
  getDevice(): BluetoothDevice | URL;
86
88
  }