Problems running an API server

I'm currently looking into running a local server (with external access) on which the Flukso API is listening.
The main purpose of this is letting various Flukso modules send their data to my own server, bypassing https://api.flukso.net.
This of course kills off one extra dependency from the current situation: Flusko module <-> flukso.net <-> personal server (using the flukso api php class)

With this, I'm running into a few difficulties. I've learned that the server sided API uses an in erland written webmachine API, with a Drupal module on top of that. This is where the fun starts;
- I have no experience with Erland, nor webmachine at all.
- Drupal is not my first choice CMS, so experience with this is software is close to nothing.

I've managed to install erland (latest version from basho), and had one web_machine example running from basho's example.
Starting a webmachine using a git clone of the fls repo always results in an error:

  1. {"init terminating in do_boot",{{case_clause,{error,{"no such file or directory","webmachine.app"}}},[{tmp,ensure_started,1},{tmp,start,0},{init,start_it,1},{init,start_em,1}]}}
  2.  
  3. Crash dump was written to: erl_crash.dump
  4. init terminating in do_boot ()

The written dump file does not really help me much, its about 18000 lines long.

This is pretty much where I got stuck right now. My problem is, there is little to no explanation/tutorial on how to setup an API server, and there are no explanations or descriptions what the xml envelope should look like if i was to build my own API, etc.
Also, although installing the modules on Drupal was pretty straight forward, there is no help available how to actually use them... But this could be due to my noobness of Drupal

So I've got two questions here;
1. Who has managed to run their own server API or can help me build one?
2. Would it be possible to skip the whole webmachine/erland stuff and write the whole thing in PHP so my webserver accepts the data from the flukso modules, and returns the proper handshakes to the device.

I'm hoping i'm not asking too much here :)
Many thanks!

gameentertainment's picture

The problem with that is that there are multiple FLMs on multiple locations. Querying each FLM would require a fixed routed path from server -> internet -> router -> FLM.
This is not possible on all locations. The only fix is let the FLM talk TO an API server, instead of answer when spoken to.

gameentertainment's picture

I have now managed to get passed the previous errors, but now i'm running into new ones.

I've edited the mysql details to match my database and it appears that the start-dev.sh script connects without errors. All good here, but now there's something odd with the table structures.

I've made sure I have all the tables from Drupal, the logger module and the extra my.sql file found in the durpal module folder (for some reason, not all tables are imported when you install the module).
But when I run the starting script, the output also mentions this line:

  1. mysql:564: received prepare/2: alarm_sensor_load (ver 1) <<"SELECT\n           sensor,\n           type,\n           resolution,\n           threshold,\n           state,\n           timestamp\n       FROM\n           alarm_sensor\n       WHERE\n           sensor = ?">>
  2. mysql:564: received prepare/2: alarm_sensor_update (ver 1) <<"UPDATE\n           alarm_sensor\n       SET\n           state = ?,\n           timestamp = ?\n       WHERE\n           sensor = ?">>

Table alarm_sensor was not created nor is present, and adding this table manually using the columns mentioned by the output does not solve the problem.

There is another thing going wrong, with the Drupal module. When accessing the My Account -> sensors tab, an error appears on the page that lm.enabled is missing. Manually adding this column gets rid of the error, but this proves to me that something is still not right with this thing.
Also, trying to add my Serial under the devices tab always results in the same error: Please specify a valid serial number.

dvrslype's picture

have you got any success reporting your energy usage to your own server?