Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Numerous always-ignore extensions
###################
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~

*.sass-cache
# Folders to ignore
###################
.hg
.svn
.CVS
# OS or Editor folders
###################
.DS_Store
Icon?
Thumbs.db
ehthumbs.db
nbproject
.cache
.project
.settings
.tmproj
*.esproj
*.sublime-project
*.sublime-workspace
# Dreamweaver added files
###################
_notes
dwsync.xml
# Komodo
###################
*.komodoproject
.komodotools
30 changes: 15 additions & 15 deletions IA5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,51 @@

class IA5
@@map_syms = [
[ '@', '£', '$', '¥', 'è', 'é', 'ù', 'ì', 'ò', 'Ç', '\n', 'Ø', 'ø', '\r', 'Å', 'å' ],
[ 'Δ', '_', 'Φ', 'Γ', 'Λ', 'Ω', 'Π', 'Ψ', 'Σ', 'Θ', 'Ξ', '\e', 'Æ', 'æ', 'ß', 'É' ],
[ '@', '£', '$', '¥', 'è', 'é', 'ù', 'ì', 'ò', 'Ç', '\n', 'Ø', 'ø', '\r', 'Å', 'å' ],
[ 'Δ', '_', 'Φ', 'Γ', 'Λ', 'Ω', 'Π', 'Ψ', 'Σ', 'Θ', 'Ξ', '\e', 'Æ', 'æ', 'ß', 'É' ],
[ " ", '!', '"', "#", '¤', "'", '%', '&', '(', ')', '*', '+', ',', '-', '.', '/' ],
[ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?' ],
[ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?' ],
[ '¡', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' ],
[ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ä', 'Ö', 'Ñ', 'Ü', '§' ],
[ '¿', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o' ],
[ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'ä', 'ö', 'ñ', 'ü', 'à' ]
].flatten

@@map = {}
@@map_syms.each_with_index { |symbol,index| @@map[symbol] = index }
@@inv_map = @@map.invert

@@ext_map = { "|" => 0x40, "^" => 0x14, "€" => 0x65, "{" => 0x28, "}" => 0x29, "[" => 0x3C, "~" => 0x3D, "]" => 0x3E, "\\" => 0x2F }
@@inv_ext_map = @@ext_map.invert
@@ext_syms = []
@@ext_map.each_key { |key| @@ext_syms << key }
@@trie_parser = TrieParser.new [@@map_syms, @@ext_syms].flatten

@@trie_parser = TrieParser.new [@@map_syms, @@ext_syms].flatten

def IA5.is_extended? symbol
(nil != @@ext_map[symbol])
end

def IA5.encode(text)
ia5 = []

symbols = @@trie_parser.parse(text)

symbols.each do |sym|
if IA5.is_extended? sym
ia5 << 0x1B << @@ext_map[sym]
else
ia5 << @@map[sym]
end
end

ia5
end

# expects a byte per ia5 character (do 7bit -> 8bit conversion first)
def IA5.decode(ia5)
text, i = "", 0

while i < ia5.length do
chr = ia5.slice(i)
if chr == 0x1B then
Expand All @@ -60,7 +60,7 @@ def IA5.decode(ia5)
end
i = i + 1
end

text
end
end
6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ It has been tested with Siemens TC35 modems.


The development of this project was sponsored by MimerGroup/MimerMobile,
http://mimergroup.com.
http://mimergroup.com.

Mimergroup delivers a range of services, software and hardware
Mimergroup delivers a range of services, software and hardware
related to SMS messaging. You can enquire about these services
and product by contacting <khh@mimergroup.com>.
and product by contacting <khh@mimergroup.com>.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
Expand Down
14 changes: 7 additions & 7 deletions SMS.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class SMS
attr_accessor :message, :udh, :from, :to, :pdu

def initialize(message = "", from = "", to = "")
@message, @from, @to = message, from, to
@udh = ""
end

def SMS.create_from_pdu(pdu, modemname = "")
sms = SMS.new
sms.message = IA5.decode(pdu.message)
Expand All @@ -23,21 +23,21 @@ def SMS.create_from_pdu(pdu, modemname = "")
else
sms.to = pdu.destination
end

return sms
end

def to_pdu
pdu = PDU.new
pdu.originator = @from
pdu.destination = @to
pdu.message = IA5.encode @message

return pdu
end

def xml
"<sms>" +
"<sms>" +
"<to>" + @to.nil? + "</to>" +
"<from>" + @from + "</from>" +
"<message>" + @message + "</message>" +
Expand Down
6 changes: 3 additions & 3 deletions http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ class HTTPClient
def initialize(baseurl, logger)
@baseurl, @logger = baseurl, logger
end

def send_http_request(sms)
@logger.info "Forwarding message to #{@baseurl}"
response = Net::HTTP.post_form(URI.parse(@baseurl), { "message" => sms.message, "pdu" => sms.pdu, "from" => sms.from, "to" => sms.to, "parts" => sms.pdu.parts.to_s, "partnumber" => sms.pdu.partnumber.to_s })
@logger.info "Response: " + response.body
end

def construct_url(sms)
url = @baseurl
url = @baseurl
url << "?message=" + CGI.escape(sms.message)
url << "&pdu=" + CGI.escape(sms.pdu)
url << "&from=" + CGI.escape(sms.from)
Expand Down
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ if [ ! `whoami` == "root" ]; then
fi

if [ ! -d $INSTDIR ]; then
mkdir $INSTDIR
mkdir $INSTDIR
fi

# copy files
echo "Installing files to $INSTDIR"
echo "Installing files to $INSTDIR"
cp * $INSTDIR

echo "Installing init script (/etc/init.d/modemserver)"
Expand Down
14 changes: 7 additions & 7 deletions log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
class ModemServerLogger < Monitor
def initialize(logfile)
@filename = logfile
open
open
@logger.info "Log #{@filename} startet"
@logger.level = Logger::INFO
end
def open

def open
#@file = File.open(@filename, File::WRONLY | File::APPEND | File::CREAT)
#@logger = Logger.new(@file, 'daily')
@logger = Logger.new(@filename, 'daily')
@logger.level = Logger::INFO
end

def close
@logger.close
@logger.close
end

def shutdown
close
end

# catch method call, synchronize and send to the logger object
def method_missing(m, *args)
@logger.send(m, *args)
@logger.send(m, *args)
puts *args
#@file.flush
end
Expand Down
4 changes: 2 additions & 2 deletions misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

def ia5(str)
len = ((str.length/2) * (8.0/7.0)).round

pos = 0
ia5 = []
rest = 0

0.upto(len-1) do |ia5pos|
shift = ia5pos%8
shift = ia5pos%8
if shift == 7 then
ia5 << rest
rest = 0
Expand Down
30 changes: 15 additions & 15 deletions modem_web_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


# The modem servlet responds to request to send a message:
# It adds the message to the modem communicator threads
# It adds the message to the modem communicator threads
# queue.
class ModemServlet < HTTPServlet::AbstractServlet
attr_accessor :mountpoint
Expand All @@ -14,24 +14,24 @@ def initialize(server, modem_communicator)
super(server)
@modem_communicator, @mountpoint = modem_communicator, @modem_communicator.name
end


def do_GET(req, res)
errors, res.body = [], ""
@logger.info "http query params: " + req.query.inspect + "\n" unless req.query['debug'].nil?

sms = SMS.new(req.query['message'].to_s, @modem_communicator.name, req.query['to'].to_s)

if (sms.message.nil? or sms.message.empty?)
errors << "empty message"
end

if (sms.to.nil? or sms.to.empty?)
errors << "empty to field"
end

# Attempt to add to queue:
begin
begin
@modem_communicator.send_sms(sms) if errors.empty?
rescue Exception => e
@logger.error e.to_s
Expand All @@ -43,16 +43,16 @@ def do_GET(req, res)
else
status = "<status>FAILED</status>\n"
end

error_string = ""
errors.each { |e| error_string << "<error>#{e}</error>\n" }
res.body = "<send-response>\n" + status + error_string + "</send-response>\n"

res['Content-Type'] = "text/html"

raise HTTPStatus::OK
end

alias :do_POST :do_GET # let's accept POST request too.
end

Expand All @@ -61,18 +61,18 @@ def initialize(config, logger)
@config, @logger = config, logger
@s = HTTPServer.new(:Port => @config['http-port'].to_s, :Logger => @logger)
end

def connect(modem_communicator)
mountpoint = "/" + modem_communicator.name
@logger.info "mounting servlet at " + mountpoint
@s.mount mountpoint, ModemServlet, modem_communicator
end

def start
@logger.info "Starting Modem Web Server"
@s.start
end

def shutdown
@s.shutdown
end
Expand Down
Loading