# node-mavlink-heartbeat

> MavLink heartbeat services

Latest version **0.0.1-alpha.1** (published 2023-04-26) · LGPL license · 0 weekly downloads

## Install

```sh
npm install node-mavlink-heartbeat
pnpm add node-mavlink-heartbeat
yarn add node-mavlink-heartbeat
bun add node-mavlink-heartbeat
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1-alpha.1 |
| Published | 2023-04-26 |
| First published | 2023-04-26 |
| Weekly downloads | 0 |
| License | LGPL |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 21.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Matthias Hryniszak |
| Maintainers | padcom |
| Keywords | mavlink |

## Links

- npm: https://www.npmjs.com/package/node-mavlink-heartbeat
- Repository: https://github.com/padcom/node-mavlink-heartbeat
- Homepage: https://github.com/padcom/node-mavlink-heartbeat#readme
- Issues: https://github.com/padcom/node-mavlink-heartbeat/issues
- Funding: https://www.patreon.com/padcom
- npm.io page: https://npm.io/package/node-mavlink-heartbeat

## Dependencies (2)

- [node-mavlink](https://npm.io/package/node-mavlink.md) ^2.0.5
- [node-mavlink-utils](https://npm.io/package/node-mavlink-utils.md) ^0.0.1-alpha.0

## Recent versions

- 0.0.1-alpha.1 (latest) — 2023-04-26
- 0.0.1-alpha.0 (alpha) — 2023-04-26

## README

# Heartbeat scheduler and receiver for node-mavlink

Sending and receiving heartbeats is really a basic thing. It shouldn't have to be written per project.
This is why the `node-mavlink-heartbeat` package has been created. In a simple and effective way it allows the developer to concentrate on what is important and not what is just noise.

## Installation

To install the package issue the following command:

```bash
$ npm install --save node-mavlink-heartbeat
```

## Usage

There are 2 birds that you'll be able to kill with one stone, so to speak. That's because the same instance of `Heartbeat` can serve as both the receiver, sender and scheduler of sending heartbeat packets.

For a comprehensive example please see `examples/simple.ts`

```typescript
const port = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200 })
const heartbeat = new Heartbeat(port)
heartbeat.on('heartbeat', ({ packet, heartbeat }: HeartbeatData) => {
  // do something with the packet
  console.log(packet.debug())
  // or with the typed heartbeat packet
  console.log(heartbeat.baseMode)
})

port
  .pipe(new MavLinkPacketSplitter())
  .pipe(new MavLinkPacketParser())
  .pipe(heartbeat)
  .resume()

// Wait for the drone to give us a sign it's alive
// That way we know for sure the connection is ready.
await heartbeat.waitForOne()

// send a single heartbeat
await heartbeat.send()
// start sending heartbeats
heartbeat.start()
// stop sending heartbeats
heartbeat.stop()
```

Happy coding!

---
_Source: https://npm.io/package/node-mavlink-heartbeat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
