Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moteus/lua-lluv-gsmmodem
Control GSM modem connected to serial port using AT commands
https://github.com/moteus/lua-lluv-gsmmodem
gsm lua sms
Last synced: 3 months ago
JSON representation
Control GSM modem connected to serial port using AT commands
- Host: GitHub
- URL: https://github.com/moteus/lua-lluv-gsmmodem
- Owner: moteus
- License: mit
- Created: 2015-05-08T12:48:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-25T08:05:06.000Z (over 7 years ago)
- Last Synced: 2024-10-05T06:41:09.256Z (3 months ago)
- Topics: gsm, lua, sms
- Language: Lua
- Homepage:
- Size: 158 KB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lua-lluv-gsmmodem
[![Licence](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
[![Build Status](https://travis-ci.org/moteus/lua-lluv-gsmmodem.svg?branch=master)](https://travis-ci.org/moteus/lua-lluv-gsmmodem)
[![Coverage Status](https://coveralls.io/repos/moteus/lua-lluv-gsmmodem/badge.svg)](https://coveralls.io/r/moteus/lua-lluv-gsmmodem)### Usage
* Open and configure
```Lua
local device = GsmModem.new('COM3', {
baud = '_9600';
data_bits = '_8';
parity = 'NONE';
stop_bits = '_1';
flow_control = 'OFF';
rts = 'ON';
})
device:open(function(self, err, info)
if err then
print('Fail open port:', err)
return self:close()
end
print('Connected to port:', info)
-- Now we should configure modem to allow GsmModem class works properly
-- (e.g. sms pdu mode, notify mode for sms and calls)
-- Ofcourse you can use it as-is with out configure.
self:configure(function(self, err, cmd)
if err then
print('Configure error:', err, ' Command:', cmd)
return self:close()
end
print('Configure done')
-------------------------------------------
-- Here you can start do your work
-------------------------------------------
end)
end)
```* Send SMS
```Lua
device:send_sms('+7777777', 'Hello world', function(self, err, ref)
print('SMS Send result:', err or 'OK', 'Message reference:', ref or '')
end)
```* Send SMS and wait report
```Lua
device:send_sms('+7777777', 'Hello world', {waitReport = 'final'}, function(self, err, ref, response)
if err or not response.success then
print('SMS Send fail:', err or response.info, 'Message reference:', ref or '')
else
print('SMS Send pass', 'Message reference:', ref or '')
end
end)
```* Send USSD
```Lua
device:send_ussd('*100#', function(self, err, msg)
print('USSD Result:', err, msg and msg:status(), msg and msg:text())
end)
```* Recv SMS
```Lua
device:on('sms::recv', function(self, event, sms)
print("SMS from:", sms:number(), "Text:", sms:text())
end)
```* Proceed SMS delivery report
```Lua
device:on('report::recv', function(self, event, sms)
local success, status = sms:delivery_status()
print("SMS reference:", sms:reference(), "Number:", sms:number(), "Success:", success, "Status:", status.info)
end)
```* Read SMS
```Lua
-- read and delete first SMS from SIM card
device:read_sms(1, {memory = 'SM', delete = true}, function(self, err, sms)
print("SMS from:", sms:number(), "Text:", sms:text())
end)-- read all unreaded sms from phone memory
device:each_sms(GsmModem.REC_UNREAD, {memory='ME'}, function(self, err, idx, sms)
if err and not index then
-- e.g. invalid memory
return print("List SMS error:", err)
endif err then
-- Some times device can return invalid sms on list (CMGL), but you can
-- try read sms directly (CMGR) (e.g. device:read_sms(idx ...)
-- This is works on my WaveCom SIM300
return print("Read SMS #" .. idx .. " error:", err)
endprint("#" .. idx, "SMS from:", sms:number(), "Text:", sms:text())
end)
```