Giter Site home page Giter Site logo

rad-esp8266's People

Contributors

randuhmm avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cookejames

rad-esp8266's Issues

Make API more RESTful

I've been playing around with this properly now and really loving the work you've been doing.

One thing I've noticed is that a RESTful api would make the code a lot simpler and easier for users to parse. Right now a SSDP response looks like

{ EXT: '',
  'CACHE-CONTROL': 'max-age=1200',
  SERVER: 'Arduino/1.0 UPNP/1.1 RAD-ESP8266/9001',
  USN: 'uuid:38323636-4558-4dda-9188-cda0e608ea67',
  ST: 'urn:rad:device:esp8266:1',
  LOCATION: 'http://192.168.1.20:80/' }

When parsing this you have to "know" the URL schema and append the /features, /commands URL. Also you end up doing a lot of parsing of the delivered JSON in your handlers as you need check in for instance the commands handler for get or set to know which command to make.

Instead I would suggest that you modify the schema slightly commands to address the feature directly eg for switch_1 use:

POST /commands/switch_1`
GET /commands/switch_1

You can then in your features response add the commands response

[
  {
    "feature_name": "switch_1",
    "feature_type": "SwitchBinary",
    "description": ""
    "commands": {
      GET: "http://192.168.1.20:80/commands/switch_1",
      POST: "http://192.168.1.20:80/commands/switch_1"
    }
  }
]

In your SSDP response locations changes to LOCATION: 'http://192.168.1.20:80/features and now whoever is reading the SSDP response can browse your schema dynamically.

I believe your code will also get a lot simpler as you will just need to add extra handlers for the GET/SET commands and would be able to remove a lot of your parsing code.

Simplify the SimpleBinarySwitch Example

I just realized that I am complicating the example by trying to use the GPIO as a drain rather than as a power source. Most users will better understand the connection diagram and code if setting the GPIO to HIGH turns on the LED and setting to LOW turns it off.

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.