Giter Site home page Giter Site logo

elkm1api's Introduction

ElkM1API - A simple API to wrap the ASCII protocol

ElkM1API is a wrapper for the many functions that the Elk ASCII protocol that allows it to request information in a familiar environment, with everything wrapped down to simple calls.

It's designed to be accesable using SWIG, which allows it to be deployed to anywhere that supports C++11 compiled libraries and a target language. (Java with JNI, C#, Android with NDK, iPhone).

Setup

To use this project, you will (currently) need SWIG for Windows to be installed to C:/Data/swigwin, and Microsoft Visual Studio 2013.

Usage

When you click "Rebuild" on the ElkM1API project, it deletes the SWIG generated wrappers and regenerates them, as well as the swig_wrap_csharp.cpp file (as it's only currently set up to wrap to C#). Delete the 'csharp' directory in one of the example projects and alt-click the generated 'csharp' folder to link it in and experiment with it. Altering the Properties>Pre-Build Steps should make generating it for Java or other windows platforms quite simple. As it's all STL C++11, pulling the C++ files into a Makefile and generating for Android or Linux should 'just work', but please open an issue if you encounter any issues compiling for those platforms. (CMake would be a more ideal make system, but for this case we stuck to more familiar tools)

Structure

The API takes whatever command you give it and generates an ASCII packet, passing it to the underlying connection you and it. These connections are bi-directional per language, so it's possible (and quite easy) to implement the transport in the native language, rather than relying on a hopefully decent socket implementation in C++. (an example of this is in ElkM1DesktopApp/M1ConnectionWrappers.cs)

For the most part, everything is kept synchronous by blocking for each call and synchronizing when the 'Monitor' thread returns. For some calls, such as getArmStatus(), there is also a callback available to let you react whenever you recieve a packet of that kind, which happens whenever the arming status of the system changes (regardless of if you asked for it or not). The list of functions which have callback equivelents is not currently exhaustive, so if you need more feel free to add them. (should take a couple lines of code max, but it wasn't certain from the outset which calls would be useful as callbacks)

There also exists some smart convienience functions, such as getConfiguredZones/Keypads/Areas (which try to deduce which of the possible devices are actually in use, and returns an array of indexes) and collectNames (which uses the above functions to asynchronously, but deterministically, collect the names to work around the slow ASCII protocol name retrieval method, and then fills undefined names with "").

elkm1api's People

Contributors

feilen avatar kellycelk avatar stubbs28 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elkm1api's Issues

Needs more asynchronous calls

A lot of information coming out of the M1 comes whether you request it or not, and while there are some examples of callback calls, it's almost completely synchronous at the moment.

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.