Class: MF60::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/mf60.rb

Constant Summary collapse

DEVICE_URL =
ENV['MF60URL'] || "http://192.168.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(user, pass) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mf60.rb', line 17

def initialize(user, pass)
  @lucknum = 123456
  response = self.class.post(
                DEVICE_URL + '/goform/goform_process',
                :body => {
                  'user' => user, 
                  'psw' => pass,
                  'goformId'=>'LOGIN',
                  'lucknum'=>@lucknum
                }
              )
  @cookie = response.headers['set-cookie']
end

Instance Method Details

#connectObject



35
36
37
# File 'lib/mf60.rb', line 35

def connect
  net_connect(true)
end

#disconnectObject



39
40
41
# File 'lib/mf60.rb', line 39

def disconnect
  net_connect(false)
end

#get(path) ⇒ Object



31
32
33
# File 'lib/mf60.rb', line 31

def get(path)
  response = self.class.get(DEVICE_URL + path, :headers => {'Cookie' => @cookie})
end

#resetObject



43
44
45
46
47
# File 'lib/mf60.rb', line 43

def reset
  self.disconnect
  sleep 5
  self.connect
end

#statsObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/mf60.rb', line 49

def stats
  response = self.get('/adm/statistics.asp')
  info = response.match(/var realtime_statistics = '([\d\,]+)'/)[1]
  stats = info.split(',')
  {
    :current_trans => stats[2].to_i,
    :current_recv  => stats[3].to_i,
    :connect_time  => "%02d:%02d" % [stats[4].to_i/60, stats[4].to_i%60],
    :total_recv   => stats[5].to_i
  }
end

#statusObject

0 -113 dBm or less

1 -111 dBm

2…30 -109… -53 dBm

31 -51 dBm or greater “good”

99 not known or not detectable

RSCP is the received signal code power from the CPICH channel and it is usually constant in a cell and it gives an indication of the level in the area. RSSI: is the received signal strength indicator and it is the total power with the noise. Ec/N0 : is the Received Signal Code Power equal to RSCP/RSSI or the code power over (noise+code power) So… rscp/rssi = ecno

rscp

—- = ecio | rscp = ecio * rssi | rssi = rscp/ecio rssi



78
79
80
81
82
83
84
85
86
87
# File 'lib/mf60.rb', line 78

def status
  response = self.get('/air_network/wireless_info.asp')
  vars = %w(provider network_type_var cardstate current_network_mode rscp ecio)
  status = {}
  vars.each do |var_name|
    status[var_name.to_sym] = grab_var(response, var_name)
  end
  status[:rssi] = (status[:rscp].to_f/status[:ecio].to_f)
  status
end