-
Notifications
You must be signed in to change notification settings - Fork 4
How to create a thing
Ulf edited this page Aug 22, 2013
·
17 revisions
We will create a thing which sends mails if it gets a message from a specific driver from a specific node with a specific body. All other messages, which will come this node will be logged with a warning.
Before we can send the email, we have to initialize the driver, because we have to start an external application. This will be done in the init function.
Note: For sending the emails we will use https://github.com/0xAX/gen_smtpc which is a simple mail client.
Ok, let's start
- Create a new module in the app/horst/src directory.
-module(mail_client_driver).
-export([init/1,handle_msg/3]).
init(Config) ->
lager:info("mail_client_driver:init('~p')", [Config]),
application:start(gen_smtpc).
handle_msg([Node ,Sensor, Id, Time, Body], Config, Module_config) ->
Config.- Edit the things.config and add the new driver