Skip to content

Instantly share code, notes, and snippets.

@meuble
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meuble/d27ad519d6bb2af81722 to your computer and use it in GitHub Desktop.
Save meuble/d27ad519d6bb2af81722 to your computer and use it in GitHub Desktop.
Fliike API

Fliike API

Presentation

Fliike works with a Carambola2 embeded card (http://www.8devices.com/carambola-2). It's a card mounted with a Qualcomm/Atheros AR9331 microprocesor and a Wifi module. It's shipped with a OpenWRT Linuw distribution.

A Luci HTTP server (http://luci.subsignal.org/) is installed and listen to the 80 port. A built in application answers to this interface via a bundle of commands forming a JSON API.

JSON API

The domain of this API is the IP acquired by the Fliike when connected to the network. It can be different according to whether it is connected to wifi or ethernet. The MAC addresses of these interfaces are provided with the Fliike identification code, in case you want to configure static IP on a DHCP.

The API is available at the following path: cgi-bin/luci/fliike/ctrl

To execute a command, we will use the following API call:

http://{IP}/{path}/{command}

Example :

wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/stop"

Commands

stop

Stop the like crawler.

Answer

{ "status": "OK" }

start

Start the like crawler.

Answer

{ "status": "OK" }

z0

Sets all tiles to their original position.

Answer

{ "status": "OK" }

goto

Move tile 'm' to position 'c'.

Parameters

  • m : Identifier of the tile to move. From right to left, the tile identifiers are 0, 1, 2, 3 and 4
  • c : Position a tile relatively to the origin. If we take "0" as the original position, positions are respectively 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 (dashed), 11 (empty)

Answer

{ "status": "OK" }

Example

wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=4&c=11"

moveorigin

Set the origin of the tile 'm' at a distance 'd' of the current position.

Parameters

  • m : Identifier of the tile to move. From right to left, the tile identifiers are 0, 1, 2, 3 and 4
  • d : Distance from the current position to the desired position. This distance is not precisely defined. It is defined by strange algorithm:
    if (d == 0)
      diff = 0;
    else if (Math.abs(d) >= 3)
      diff = parseInt(d * 85 / -3);
    else
      diff = parseInt(d * 85 / -5);

Example

wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/moveorigin?m=4&d=11"

setorigin

Unknown command.

hole

Unknown command, seams to reset all original positions. Then display 78838 or 7883_.

r

Unknown command, seams to reset all originam positions. Then display 78838.

Sample display controls

To display the word "-1337" we would execute the following commands:

wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=4&c=11";
wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=3&c=1";
wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=2&c=3";
wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=1&c=3";
wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=0&c=7";

Fliike API

Présentation

Le Fliike fonctionne avec une carte Carambola2 (http://www.8devices.com/carambola-2). C'est une carte dotée d'un microprocesseur Qualcomm/Atheros AR9331 et d'un module Wifi. Elle est livrée avec une distrubution Linux OpenWRT.

Le serveur HTTP Luci (http://luci.subsignal.org/) est installé dessus et écoute le port 80. Une application répond à cette interface suivant un certain nombre de commandes via un API JSON.

API JSON

Le domaine de cette api est l'IP acquis par le Fliike lorsqu'il est connecté. Elle peut être différente suivant s'il est connecté en wifi ou en ethernet. Les adresses MAC de ces interfaces sont données avec le code d'identification du Fliike, si on veut configurer des IP statiques sur un DHCP.

L'API est disponible sur le chemin suivant : cgi-bin/luci/fliike/ctrl

Pour exécuter une commande, on fera l'appel à l'API suivant :

http://{IP}/{chemin}/{commande}

Exemple :

wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/stop"

Commandes

stop

Arrête le crawler de like.

Réponse

{ "status": "OK" }

start

Démarre le crawler de like.

Réponse

{ "status": "OK" }

z0

Positionne toutes les case à leur position d'origine.

Réponse

{ "status": "OK" }

goto

Change la case 'm' à la position 'c'.

Paramètres

  • m : Identifiant de la case à déplacer. De la droite vers la gauche, les identifiants des case sont respectivement 0, 1, 2, 3 et 4
  • c : Position de destination par rapport à l'origine. En se basant sur une origine sur l'affichage "0", les positions sont respectivement 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 (les tirets superposés), 11 (case vide)

Réponse

{ "status": "OK" }

Exemple

wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=4&c=11"

moveorigin

Définie l'origine de la case 'm' à une distance 'd' de la position courante.

Paramètres

  • m : Identifiant de la case à déplacer. De la droite vers la gauche, les identifiants des case sont respectivement 0, 1, 2, 3 et 4
  • d : Distance de la position courante à la position voulue. Cette distance c'est pas encore précisement définie. Elle répond à un algo un peu étrange :
    if (d == 0)
      diff = 0;
    else if (Math.abs(d) >= 3)
      diff = parseInt(d * 85 / -3);
    else
      diff = parseInt(d * 85 / -5);

Exemple

wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/moveorigin?m=4&d=11"

setorigin

Fonction inconnue.

hole

Fonction inconnue, semble réinitialiser les positions d'origine. Affiche 78838 ou 7883_.

r

Fonction inconnue, semble réinitialiser les positions d'origine. Affiche 78838

Exemple de contrôle de l'affichage

Pour afficher le mot "-1337" on ferait :

wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=4&c=11";
wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=3&c=1";
wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=2&c=3";
wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=1&c=3";
wget "http://42.42.42.42/cgi-bin/luci/fliike/ctrl/goto?m=0&c=7";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment