LazGem 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
  class LAZURITE_ERROR < StandardError; end
8
- class LazGem::Client
8
+ class LazGem::Device
9
9
  ##
10
10
  # func : Read the data from the receiving pipe
11
11
  # input : Receive pipe fp
@@ -1,3 +1,3 @@
1
1
  module LazGem
2
- VERSION = "0.0.0"
2
+ VERSION = "0.0.1"
3
3
  end
data/lib/LazGem.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module LazGem; end
2
2
 
3
3
  require_relative "LazGem/version"
4
- require_relative "LazGem/client"
4
+ require_relative "LazGem/device
5
5
 
@@ -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
+
@@ -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.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/client.rb
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