meshtastic/docs/development/js/http-api.mdx

40 lines
965 B
Plaintext
Raw Normal View History

2021-04-01 17:34:44 -07:00
---
id: http-api
title: HTTP API
sidebar_label: HTTP API
---
:::info
2022-11-04 10:06:45 -07:00
Methods and types for using the device [HTTP API](/docs/development/device/http-api) are exported
2021-04-01 17:34:44 -07:00
:::
```typescript
import {
Client,
Types,
Protobuf,
2023-01-19 05:01:57 -08:00
SettingsManager
2023-12-26 04:17:57 -08:00
} from "@meshtastic/js";
2021-04-01 17:34:44 -07:00
/**
* Connection method
*/
const client = new Client();
SettingsManager.setDebugMode(Protobuf.LogLevelEnum.DEBUG);
const connection = client.createHTTPConnection();
2023-01-19 05:01:57 -08:00
connection.connect("192.168.x.x");
2021-04-01 17:34:44 -07:00
const restartDevice: Promise<void> = connection.restartDevice();
2022-03-08 23:51:46 -08:00
const getStatistics: Promise<void | Types.WebSPIFFSResponse> =
connection.getStatistics();
const getNetworks: Promise<void | Types.WebNetworkResponse> =
connection.getNetworks();
const getSPIFFS: Promise<void | Types.WebSPIFFSResponse> =
connection.getSPIFFS();
const deleteSPIFFS: Promise<void | Types.WebSPIFFSResponse> =
connection.deleteSPIFFS();
2021-04-01 17:34:44 -07:00
const blinkLED: Promise<void | any> = connection.blinkLED();
```