Giter VIP home page Giter VIP logo

alpacaserveresp32's Introduction

AlpacaServerESP32

This is a library for adding Ascom Alpaca capabilites to your ESP32 arduino project. The motivation for making this was to have a compact, easily adaptable library for interfacing with Alpaca.

Auto discovery by Ascom is working, and more than one device can be connected to the server. As of now, only focuser is implemented, but adding other classes is very simple and I'll do so in the future.

Be sure to check out Ascom API documentation to be sure you handle values and parameters correctly, and return error responses as needed.

A webpage for configuring the server be found at /setup , and a setup page for each connected device will be dynamically created and presented as tabs. Saving to flash memory is supported, with settings being loaded at boot. Your class should implement aReadJson and aWriteJson to load and save settings to and from the web-interface and the flash memory.

For debugging set AlpacaServer.debug = true, after you have called Serial.begin();

This repository should be linked in the specific instance of Alpaca Driver, adding un platformio.ini a line within libdevs section (See below "Minimum setup")

To use, simply let your class inherit the relevant AlpacaDevice-derived class (e.g. AscomFocuser), and make sure to implement all pure virtual methods: aGet* should call _alpacaServer->respond(value, , ) aGet* should call _alpacaServer->respond(nullptr, , ) after reading parameters using _alpacaServer->getParam("")

Working Alpaca drivers can be found here: https://github.com/agnunez/AlpacaSafetyMonitor https://github.com/elenhinan/YetAnotherFocuser

Minimum setup:

platform.io

lib_deps=
   https://github.com/agnunez/AlpacaServerESP32.git

myFocuser.h

#include <AlpacaFocuser.h>

class MyFocuser : AlpacaFocuser
{
  [...]
  // alpaca getters
  void aGetAbsolute()             { _alpacaServer->respond(1); }
  void aGetIsMoving()             { _alpacaServer->respond(_isRunning()); }
  void aGetMaxIncrement()         { _alpacaServer->respond(_pos_max); }
  void aGetMaxStep()              { _alpacaServer->respond(_pos_max); }
  void aGetPosition()             { _alpacaServer->respond(_getCurrentPosition()); }
  void aGetStepSize()             { _alpacaServer->respond(_micrometerperstep); }
  void aGetTempComp()             { _alpacaServer->respond(_temp_comp); }
  void aGetTempCompAvailable()    { _alpacaServer->respond(1); }
  void aGetTemperature()          { _alpacaServer->respond(_temp_meas); }

  // alpaca setters
  void aPutTempComp()             { _alpacaServer->getParam("TempComp", _temp_comp); _alpacaServer->respond(nullptr); }
  void aPutHalt()                 { stop(); _alpacaServer->respond(nullptr); }
  void aPutMove()                 { _alpacaServer->getParam("Position", _pos_target); _alpacaServer->respond(nullptr); }
  [...]
}

main.h

#include <AscomServer.h>

#define ALPACA_UDP_PORT 32227
#define ALPACA_TCP_PORT 80

main.cpp

AlpacaServer alpacaServer("ExampleServer");
MyFocuser myFocuserA();
MyFocuser myFocuserB();

void setup()
{
  // make sure wifi is up and running before starting server
  [...]
  alpacaServer.begin(ALPACA_UDP_PORT, ALPACA_TCP_PORT);
  alpacaServer.addDevice(&myFocuserA);
  alpacaServer.addDevice(&myFocuserB);
}

void loop()
{
   [...]
   alpacaServer.update()
}

alpacaserveresp32's People

Contributors

agnunez avatar elenhinan avatar

Stargazers

Cliff 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.