Class: Cwmp::Cpe

Inherits:
Object
  • Object
show all
Defined in:
lib/cwmp/cpe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(acs_url, periodic, h = {}) ⇒ Cpe

Returns a new instance of Cpe.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cwmp/cpe.rb', line 9

def initialize (acs_url, periodic, h = {})
    @acs_url = acs_url
    @serial = h[:serial] || "23434ds"
    @oui = h[:oui] || "006754"
    @software_version = h[:software_version] || "0.1.1"
    @manufacturer = h[:manufacturer] || "Moonar"
    @state = 'off'
    @periodic = Thread.new { periodic periodic } if periodic > 0
    @conn_req = Thread.new { connection_request }
    @factory = true
end

Instance Attribute Details

#acs_urlObject

Returns the value of attribute acs_url.



7
8
9
# File 'lib/cwmp/cpe.rb', line 7

def acs_url
  @acs_url
end

#manufacturerObject

Returns the value of attribute manufacturer.



7
8
9
# File 'lib/cwmp/cpe.rb', line 7

def manufacturer
  @manufacturer
end

#ouiObject

Returns the value of attribute oui.



7
8
9
# File 'lib/cwmp/cpe.rb', line 7

def oui
  @oui
end

#serialObject

Returns the value of attribute serial.



7
8
9
# File 'lib/cwmp/cpe.rb', line 7

def serial
  @serial
end

#software_versionObject

Returns the value of attribute software_version.



7
8
9
# File 'lib/cwmp/cpe.rb', line 7

def software_version
  @software_version
end

#stateObject

Returns the value of attribute state.



7
8
9
# File 'lib/cwmp/cpe.rb', line 7

def state
  @state
end

Instance Method Details

#loopObject



48
49
50
# File 'lib/cwmp/cpe.rb', line 48

def loop
    @conn_req.join
end

#poweroffObject



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

def poweroff
    @state = 'off'
end

#poweronObject



21
22
23
24
25
26
27
28
29
# File 'lib/cwmp/cpe.rb', line 21

def poweron
    @state = 'on'
    if @factory
        do_connection '0 BOOTSTRAP'
    else
        do_connection '1 BOOT'
    end
    @factory = false
end

#rebootObject



35
36
37
38
39
40
# File 'lib/cwmp/cpe.rb', line 35

def reboot
    @state = 'off'
    sleep 2
    @state = 'on'
    do_connection '1 BOOT'
end

#resetObject



42
43
44
45
46
# File 'lib/cwmp/cpe.rb', line 42

def reset
    poweroff
    @factory = true
    poweron
end