# digo-vtc-digital-sdk

> ```bash npm i digo-vtc-digital-sdk@latest ```

Latest version **1.1.4** (published 2023-10-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install digo-vtc-digital-sdk
pnpm add digo-vtc-digital-sdk
yarn add digo-vtc-digital-sdk
bun add digo-vtc-digital-sdk
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2023-10-25 |
| First published | 2023-10-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 27.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | digotech |

## Links

- npm: https://www.npmjs.com/package/digo-vtc-digital-sdk
- npm.io page: https://npm.io/package/digo-vtc-digital-sdk

## Dependencies (1)

- [mqtt](https://npm.io/package/mqtt.md) ^4.3.7

## Recent versions

- 1.1.4 (latest) — 2023-10-25
- 1.1.3 — 2023-10-25
- 1.1.2 — 2023-10-23
- 1.1.1 — 2023-10-23
- 1.1.0 — 2023-10-23

## README

# Docs @digo-sdk/digo-mqtt

#Install bản mới nhất

```bash
npm i digo-vtc-digital-sdk@latest
```

## Usage

```jsx
import React, { Component } from "react";

import { UseMqtt } from "use-mqtt-demo";

const Example = () => {
  // giá trị UseMqtt nhận là giá trị timeout 1 request nhận response từ thiết bị về
  // key: giá trị bên digo cung cấp là trường bắt buộc truyền vào
  // timestamp: giá trị tính bằng miligiay, không truyền giá trị mặc định là 5000
 const { connectStatus} = UseMqtt(key,timestamp);
  return <div>{connectStatus}</div>;
};
```

# Variable

```jsx
// Đây là thông tin mỗi nhận được mỗi khi thiết bị gửi response

type loudspeakersItem = {key:string, status?:boolean,error?:boolean}
payloadData:{request_id:number|string, mac:ClusterId,method:string, value:{cluster_power?:boolean,loudspeakers?:[loudspeakersItem]}},

// Đây là hàm để connect mqtt
// key : digo cung cấp
onConnect: ()=>void,

// Đây là hàm để disconnect mqtt mặc định gọi khi component unmount
onDisconnect:()=>void,

// đây là trạng thái để xem đã sẵn sàng để sub hay chưa
// True: connectStatus==='Connected' và lấy thành công danh sách thiết bị
isReady:boolean,

// Đây là hàm để gửi gói tin xuống thiết bị và chạy khi isReady = true
type publish = (id: any, payload: any, callback: Function,) => [request_id],
onPublish: publish,

// đây là hàm đăng kí nhận gói tin từ thiết bị gửi về và chạy khi isReady = true
type sub = (id: any, payload: any, callback: Function,) => void,
onSub:sub,

// đây là hàm hủy nhận gói tin từ các kênh đã đăng kí
type unSub = (id: any) => void,
onUnSub: unSub,

// Đây là trạng thái xem quá trình connect mqtt
connectStatus = "Connect"|"Connecting"|"Connected"|"Connect failed"|"Reconnecting",


// đây là trạng thái trong quá trình gửi gói tin
isLoading:boolean,

// đây là danh sách các gói tin đã gửi không có phản hồi từ thiết bị
// request_id được gen khi gọi hàm mqttPublish
listPubLishFailed: [request_id],

// đây là danh sách các gói tin đã gửi được lưu theo mã
listPublish: [request_id],


// đây là hàm giúp lấy lại status của thiết bị
getStatusOfCluster: (deviceId)=>[request_id],

// đây là hàm giúp bật tắt thiết bị
// value : true-bật, false-tắt
onOffCluster: (deviceId, value:boolean)=>[request_id]

```

---
_Source: https://npm.io/package/digo-vtc-digital-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
