LazGem 0.0.0 → 0.0.1
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.
- data/lib/LazGem/{client.rb → device.rb} +1 -1
- data/lib/LazGem/version.rb +1 -1
- data/lib/LazGem.rb +1 -1
- data/sample/sample_rx.rb +51 -0
- data/sample/sample_tx.rb +29 -0
- metadata +4 -2
data/lib/LazGem/version.rb
CHANGED
data/lib/LazGem.rb
CHANGED
data/sample/sample_rx.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#! /usr/bin/ruby
|
2
|
+
# -*- coding: utf-8; mode: ruby -*-
|
3
|
+
# Function:
|
4
|
+
# Lazurite Sub-GHz/Lazurite Pi Gateway Sample program
|
5
|
+
# SerialMonitor.rb
|
6
|
+
require 'LazGem'
|
7
|
+
|
8
|
+
laz = LazGem::Device.new
|
9
|
+
|
10
|
+
# Halt process when CTRL+C is pushed.
|
11
|
+
finish_flag=0
|
12
|
+
Signal.trap(:INT){
|
13
|
+
finish_flag=1
|
14
|
+
}
|
15
|
+
# open device deriver
|
16
|
+
#
|
17
|
+
# LAZURITE.open(ch=36,panid=0xabcd,pwr=20,rate=100),mode=2)
|
18
|
+
# parameter
|
19
|
+
# ch: frequency 24-61. 36 is in default
|
20
|
+
# panid: pan id
|
21
|
+
# pwr: tx power
|
22
|
+
# rate: bit rate 50 or 100
|
23
|
+
# pwr: tx power 1 or 20
|
24
|
+
# mode: must be 2
|
25
|
+
laz.device_open()
|
26
|
+
|
27
|
+
# printing header of receiving log
|
28
|
+
print(sprintf("time\t\t\t\trxPanid\trxAddr\ttxAddr\trssi\tpayload\n"))
|
29
|
+
print(sprintf("------------------------------------------------------------------------------------------\n"))
|
30
|
+
|
31
|
+
# main routine
|
32
|
+
while finish_flag == 0 do
|
33
|
+
rcv = laz.read()
|
34
|
+
if rcv == -1 then
|
35
|
+
next
|
36
|
+
end
|
37
|
+
# printing data
|
38
|
+
print(sprintf("%s.%06d\t0x%04X\t0x%04X\t0x%04X\t%03d\t%s",
|
39
|
+
rcv["Time"].strftime("%Y-%m-%d %H:%M:%S"),
|
40
|
+
rcv["usec"],
|
41
|
+
rcv["rxPanid"],
|
42
|
+
rcv["rxAddr"],
|
43
|
+
rcv["txAddr"],
|
44
|
+
rcv["rssi"],
|
45
|
+
rcv["payload"].unpack("a*")[0]))
|
46
|
+
end
|
47
|
+
|
48
|
+
# finishing process
|
49
|
+
laz.device_close()
|
50
|
+
|
51
|
+
|
data/sample/sample_tx.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#! /usr/bin/ruby
|
2
|
+
# -*- coding: utf-8; mode: ruby -*-
|
3
|
+
# Function:
|
4
|
+
# Lazurite Sub-GHz/Lazurite Pi Gateway Sample program
|
5
|
+
# SerialMonitor.rb
|
6
|
+
require './lazurite'
|
7
|
+
|
8
|
+
laz = LazGem::Device.new
|
9
|
+
|
10
|
+
#laz.open(ch=10)
|
11
|
+
#laz.open()
|
12
|
+
##laz.open(ch=24)
|
13
|
+
|
14
|
+
finish_flag=0
|
15
|
+
Signal.trap(:INT){
|
16
|
+
finish_flag=1
|
17
|
+
}
|
18
|
+
|
19
|
+
laz.device_open()
|
20
|
+
|
21
|
+
while finish_flag == 0 do
|
22
|
+
tx = Hash["rxAddr" => 0x902b]
|
23
|
+
tx["payload"] = "Welcome SubGHz\n"
|
24
|
+
laz.write(tx)
|
25
|
+
end
|
26
|
+
|
27
|
+
laz.device_close()
|
28
|
+
|
29
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: LazGem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -78,8 +78,10 @@ files:
|
|
78
78
|
- bin/console
|
79
79
|
- bin/setup
|
80
80
|
- lib/LazGem.rb
|
81
|
-
- lib/LazGem/
|
81
|
+
- lib/LazGem/device.rb
|
82
82
|
- lib/LazGem/version.rb
|
83
|
+
- sample/sample_rx.rb
|
84
|
+
- sample/sample_tx.rb
|
83
85
|
homepage: https://github.com/NaotakaSaito/LazGem
|
84
86
|
licenses:
|
85
87
|
- MIT
|