good excuse to use elixir ?

283 views
Skip to first unread message

Jorg Heymans

unread,
Jul 6, 2015, 3:31:40 AM7/6/15
to elixir-l...@googlegroups.com
Hi,

I am looking for an excuse to start using elixir, and was hoping to make use of it for a small pet project :
  1. poll a mailbox for messages (smtp)
  2. when a mail arrives read its the contents and send it as SMS to a preconfigured number of recipients , using an attached gsm modem
  3. all this running on a raspberry pi

I am looking at the awesome-elixir list on github to see what is available, looks as if the serial port access might be difficult. Any advice from the more seasoned devs here as to what components i should leverage ?

Thanks,
Jorg

Ed W

unread,
Jul 6, 2015, 9:24:01 AM7/6/15
to elixir-l...@googlegroups.com
I don't meet the "seasoned" criteria, but an observation about Elixir would be that any native extensions compiled into Erlang can crash the whole VM.  Hence it becomes common practice to setup external dependencies as "nodes", somewhat in the way you can spin up multiple VMs, each of which will be another "node".  So in various ways you can build something which talks to the serial port and also back to the VM.

There are many levels you could slice that layer. For example you could have a low level module which literally spits serial port characters back and forward and then all the logic sits in the VM.  Or you could have some high level daemon which completely controls the GSM modem and accepts external commands to send and receive sms messages at a high level.

There are I think two Erlang libraries for serial access. I thought they were listed in awesome elixir actually? However, I see various opinions on whether they are useful or not?

It doesn't look too tricky to work up a sample port to do this (if there isn't something already).  I would tend towards a port rather than a native NIF though - I use serial to usb adaptors here quite a bit under Linux and various kernels have "interesting bugs" when plugging and unplugging and you can definitely get the serial device into an inconsistent state...

Ed W
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/0effef88-a70e-4d30-aa28-fa902d91156e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ed W

unread,
Jul 6, 2015, 9:59:50 AM7/6/15
to elixir-l...@googlegroups.com
On 06/07/2015 08:31, Jorg Heymans wrote:
>
> I am looking at the awesome-elixir list on github to see what is
> available, looks as if the serial port access might be difficult. Any
> advice from the more seasoned devs here as to what components i should
> leverage ?
>

Not tested, but this looks interesting:
https://github.com/tomszilagyi/gen_serial

Ed W

Scott Ribe

unread,
Jul 6, 2015, 10:18:54 AM7/6/15
to elixir-l...@googlegroups.com, Jorg Heymans
On Jul 6, 2015, at 1:31 AM, Jorg Heymans <jorg.h...@gmail.com> wrote:
>
> • when a mail arrives read its the contents and send it as SMS to a preconfigured number of recipients , using an attached gsm modem

Any particular reason you have to use a GSM mode, rather than sending through the carriers' email -> SMS gateways? (Of course that does require you to know recipients' carriers...)

--
Scott Ribe
scott...@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice





Paulo Almeida

unread,
Jul 6, 2015, 6:42:05 PM7/6/15
to elixir-l...@googlegroups.com
Hi,

For gsm on raspberry I've used Gammu before and it's python binding (http://wammu.eu/python-gammu/), called from Elixir using erlport (http://erlport.org/docs/python.html).

But if the Pi is already connected to the Internet to check emails, you may also consider using an SMS gateway services like Nexmo, Plivo or Twilio, which provide an HTTP API. You can use HTTPoison (https://hex.pm/packages/httpoison) to build your API client. Easier to use, gives you the option to handle delivery reports and can be cheaper than sending via GSM modem in some cases.

Paulo

Jorg Heymans

unread,
Jul 7, 2015, 2:31:18 AM7/7/15
to elixir-l...@googlegroups.com
Thanks for all the replies !

Indeed as suggested going via an sms gateway would definitely be the easier option as it's just a simple http call. But doing the math it seemed more expensive for low volume (couple of hundred messages a month tops). 

okay so i am going to start with the easy part, mailbox polling. Depending on the confidence boost i get from that i will see if i feel to tackle the serial port connectivity or not :-)

Jorg 

Ed W

unread,
Jul 7, 2015, 7:26:03 AM7/7/15
to elixir-l...@googlegroups.com
On 07/07/2015 07:31, Jorg Heymans wrote:
> Thanks for all the replies !
>
> Indeed as suggested going via an sms gateway would definitely be the
> easier option as it's just a simple http call. But doing the math it
> seemed more expensive for low volume (couple of hundred messages a
> month tops).
>
> okay so i am going to start with the easy part, mailbox polling.
> Depending on the confidence boost i get from that i will see if i feel
> to tackle the serial port connectivity or not :-)
>
> Jorg

Talking SMS to a modem is pretty trivial. Worst case just write a simple
daemon in perl/ruby (there is a neat Port integration with ruby) and
then turn it into a simple port. There are some interesting corner cases
if you turn on unsolicited responses and a message comes in while you
are sending (most 3G modems have multiple serial ports so you can
monitor on one and send on the other).

But basically if you don't need instant notification, its pretty trivial
to hook up the sms side. Worst case you can write your own little
daemon that reads files/http api in and drops the replies as messages
into some directory. Not that efficient but surely good enough (I think
Jamu might have an option to work this way?)

Good luck

Ed W

Scott Ribe

unread,
Jul 7, 2015, 9:13:15 AM7/7/15
to elixir-l...@googlegroups.com, Jorg Heymans
On Jul 7, 2015, at 12:31 AM, Jorg Heymans <jorg.h...@gmail.com> wrote:
>
> Indeed as suggested going via an sms gateway would definitely be the easier option as it's just a simple http call. But doing the math it seemed more expensive for low volume (couple of hundred messages a month tops).

The carriers' email gateways are free to use.

Ed W

unread,
Jul 7, 2015, 9:43:23 AM7/7/15
to elixir-l...@googlegroups.com
On 07/07/2015 14:13, Scott Ribe wrote:
> On Jul 7, 2015, at 12:31 AM, Jorg Heymans <jorg.h...@gmail.com> wrote:
>> Indeed as suggested going via an sms gateway would definitely be the easier option as it's just a simple http call. But doing the math it seemed more expensive for low volume (couple of hundred messages a month tops).
> The carriers' email gateways are free to use.
>

I guess we will get off-topic if we aren't careful, but when I have
researched this in the past it seems email to sms gateways are only
available for a small number of US providers? For example I don't know
of any for the UK, nor any/many for european gateways?

In europe SMS is free or close to free if you stay "in country". Out of
country it's generally low cost.

So setting up a 3G USB datacard is quite an economical way to buzz a few
hundred SMS out, probably $10-15 equiv per month. I think the 3G sticks
will have reliability concerns once you hit tens of thousands of
messages a month (not to mention hidden "fair usage" suddenly becoming
apparent), but at that point we are into big enough volume to look at
outsourcing options.

Anyway, point was I'm not aware of any email to SMS gateways in UK and
vanishingly few in Europe?

Ed W

Scott Ribe

unread,
Jul 7, 2015, 10:10:54 AM7/7/15
to elixir-l...@googlegroups.com, Ed W
On Jul 7, 2015, at 7:43 AM, Ed W <li...@wildgooses.com> wrote:
>
> I guess we will get off-topic if we aren't careful, but when I have researched this in the past it seems email to sms gateways are only available for a small number of US providers? For example I don't know of any for the UK, nor any/many for european gateways?

OK, all the major carriers in the US have them, and I was not aware that it's so different in UK & Europe.
Reply all
Reply to author
Forward
0 new messages