huawei_e3131 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/huawei_e3131.rb +121 -0
- metadata +110 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32058e8460af5070abbd1621375c27b3e28c60fec86c7db11ba198eea8a8ea5d
|
4
|
+
data.tar.gz: 73e147775e5c17170bf2973ca5ff6b0beccba409b4bbb7a0618fef87439b05dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c76c3a135d7ad890b86b0ed28cb3a60c654521601170585ff949ff48039870b867374ef0e1ec14bbf7bcfae088290533ad48c06a8501b8832b77a38b310cfe36
|
7
|
+
data.tar.gz: 44c2b947854878232a77d8d78800f55eee4a0c4bf7c488db98837469874e4dad01032b70ddfef400b87a56758c70b41599a546e74801076d8affbe4e461b01cc
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/lib/huawei_e3131.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: huawei_e3131.rb
|
4
|
+
|
5
|
+
require 'rexle'
|
6
|
+
require 'rest_client'
|
7
|
+
|
8
|
+
|
9
|
+
# HOWTO: Switching the Huawei E3131 to network controller mode
|
10
|
+
#
|
11
|
+
# 1. Plug in the Huawei E3131 dongle
|
12
|
+
# 2. `sudo apt-get install sg3-utils`
|
13
|
+
# 3. `sudo /usr/bin/sg_raw /dev/sr0 11 06 20 00 00 00 00 00 01 00`
|
14
|
+
#
|
15
|
+
# 4. edit /etc/network/interfaces and add the following:
|
16
|
+
#
|
17
|
+
# allow-hotplug eth1
|
18
|
+
# iface eth1 inet dhcp
|
19
|
+
#
|
20
|
+
# 5. observe IP address 192.168.1.1 is now reachable from eth1
|
21
|
+
#
|
22
|
+
# credit: [Huawei E3131 on Wheezy](https://www.raspberrypi.org/forums/viewtopic.php?p=210958)
|
23
|
+
|
24
|
+
class HuaweiE3131
|
25
|
+
|
26
|
+
def initialize(host='192.168.1.1', callback: nil)
|
27
|
+
@host, @callback = host, callback
|
28
|
+
end
|
29
|
+
|
30
|
+
def check_notifications()
|
31
|
+
|
32
|
+
query 'monitoring/check-notifications'
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
alias notifications check_notifications
|
37
|
+
|
38
|
+
def connection_status()
|
39
|
+
|
40
|
+
query 'monitoring/status'
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
alias status connection_status
|
45
|
+
|
46
|
+
def messages()
|
47
|
+
|
48
|
+
response = RestClient.post "http://#{@host}/api/sms/sms-list",
|
49
|
+
"<request><PageIndex>1</PageIndex><ReadCount>20</ReadCount>" +
|
50
|
+
"<BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending>" +
|
51
|
+
"<UnreadPreferred>0</UnreadPreferred></request>",
|
52
|
+
:content_type => "text/xml"
|
53
|
+
|
54
|
+
Rexle.new(response.body).root.xpath('Messages/Message').map do |message|
|
55
|
+
|
56
|
+
message.xpath('./*').inject({}) do |r,x|
|
57
|
+
x.text ? r.merge(x.name => x) : r
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def sms_count()
|
65
|
+
|
66
|
+
query 'sms/sms-count'
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
alias count sms_count
|
71
|
+
|
72
|
+
# continuously check for new messages
|
73
|
+
#
|
74
|
+
def start()
|
75
|
+
|
76
|
+
unread = notifications()['UnreadMessage'].to_i
|
77
|
+
|
78
|
+
@thread = Thread.new do
|
79
|
+
loop do
|
80
|
+
|
81
|
+
unread_messages = notifications()['UnreadMessage'].to_i
|
82
|
+
|
83
|
+
if unread_messages > unread then
|
84
|
+
|
85
|
+
@callback.call if @callback
|
86
|
+
unread = unread_messages
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
sleep 3
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
'checking for new message every 3 seconds ...'
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
def stop()
|
100
|
+
|
101
|
+
@thread.stop
|
102
|
+
@thread.kill
|
103
|
+
|
104
|
+
'message checker stopped'
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
# returns a Hash object from the flat XML records returned from the response
|
110
|
+
#
|
111
|
+
def query(s)
|
112
|
+
|
113
|
+
response = RestClient.get "http://#{@host}/api/" + s
|
114
|
+
|
115
|
+
Rexle.new(response.body).root.xpath('./*').inject({}) do |r,x|
|
116
|
+
x.text ? r.merge(x.name => x.text.unescape) : r
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: huawei_e3131
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwOTE4MTU1MzQyWhcN
|
15
|
+
MjAwOTE3MTU1MzQyWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDIgB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aHCX6v+STSGJS9DjEWLtoljRlUx2+
|
32
|
+
VvuYDJiO1pza/Ek0KBGB0i1+tU2AHsygbNTdJ4LiGTz3tG+l5sEilXAnSOfnABo/
|
33
|
+
C4t6lZQxGbEKdk6+IRRW6vnWkXNzbDkyUIGDOVWSTEWDmpGF4ix1JQ9e+ENVK7MG
|
34
|
+
uTVFTLtE1rlUQyOWycwR9kfvLB+uj/BQmWl9jkFtzec8iQe4dFfYzQyWP8BCS2Ae
|
35
|
+
N1SrCPJTgrDOB/y/+EfG4Nd3mtBPJAzIOVz2TAbXwE31144UUF/uRoIySYiDYta+
|
36
|
+
/TaNrWyfORZ4WOKDaEa3p1p7
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: rexle
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.5'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.5.2
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.5'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.5.2
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rest-client
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.1.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.1'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.1.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '2.1'
|
80
|
+
description:
|
81
|
+
email: james@jamesrobertson.eu
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- lib/huawei_e3131.rb
|
87
|
+
homepage: https://github.com/jrobertson/huawei_e3131
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubygems_version: 3.0.3
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Checks the Huawei E3131 SMS inbox for new messages using the HTTP API.
|
110
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|