Giter Site home page Giter Site logo

m4rcus.hatchbaby.rest's Introduction

Hatch Baby Rest BLE API (.NET)

This .NET API allows programmatic control over the basic functions of the Hatch Baby Rest Smart Night Light, Sound Machine and OK-to-Wake, including control of Power, Color, Volume and Audio Track.

Requirements

  • .NET Framework v4.6.1+
  • Windows 10 Creators Update (OS Version 15063 or later) - to support non-pairing Bluetooth LE communication
  • Windows 10 Compatible Bluetooth LE hardware (tested on Intel Dual Band Wireless-AC 7260 with integrated Bluetooth)

Installation

Install-Package m4rcus.HatchBaby.Rest

Usage

Examples in C#:

using m4rcus.HatchBaby.Rest;

Discovering devices

foreach (var rest in RestDevice.Discover().Result)
{
    using (rest) // dispose of the device when done with "using" or .Dispose()
    {
        // save rest.Name and rest.BluetoothAddress
        // for later use
        await rest.SetPower(true);
        await rest.SetVolume(60);
        await rest.SetAudioTrack(AudioTrack.TRACK_STREAM);
    }
}

Using devices via saved bluetooth address

// connect directly without discovery if address is known, ex "CBBABE52631F"
var bluetoothAddress = ulong.Parse("CBBABE52631F", System.Globalization.NumberStyles.HexNumber);
using (var rest = new RestDevice("MyHatchRest", bluetoothAddress))
{
    Console.WriteLine(rest.Data.Color);
    await rest.SetColor(Colors.Red);
    await Task.Delay(5000);
    await rest.SetPower(false);
}

Viewing debug output on console

static void Main(string[] args)
{
    // output debugging info to console
    Trace.Listeners.Add(new ConsoleTraceListener());
}

See the sample console app for more examples.

Contributing

This library currently supports Power, Color, Volume and Audio Track. For other functionality (events, time), PRs are welcome!

m4rcus.hatchbaby.rest's People

Contributors

marcus-l avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.