Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from woodbusy/mr_changes
Last of mrakhmanov's changes
- Loading branch information
Showing
32 changed files
with
412 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
module Net | ||
module TTI | ||
class Capabilities | ||
def initialize(caps_bytes=[]) | ||
@caps_bytes = caps_bytes | ||
end | ||
|
||
def self.from_byte_array(bytes) | ||
Capabilities.new(bytes) | ||
end | ||
|
||
def self.from_binary_string(string) | ||
Capabilities.new( string.unpack("C*") ) | ||
end | ||
|
||
def [](index) | ||
@caps_bytes[index] | ||
end | ||
|
||
def []=(index, value) | ||
@caps_bytes[index] = value | ||
end | ||
|
||
def length | ||
@caps_bytes.length | ||
end | ||
|
||
def to_binary_s | ||
@caps_bytes.pack("C*") | ||
end | ||
|
||
# Returns hexified bytes, delimited by spaces | ||
# e.g. [0x01,0x41,0x81,0xa1] -> "01 41 81 a1" | ||
def to_hexified_s | ||
to_binary_s.scan(/../).join(" ") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "bindata" | ||
|
||
module Net | ||
module TTI | ||
module DataTypes | ||
class Flags < BinData::Primitive | ||
uint8 :value_length | ||
choice :flag_value, :selection => :value_length do | ||
virtual 0, :value => 0 | ||
uint8 1 | ||
uint16be 2 | ||
uint32be 4 | ||
end | ||
|
||
def get | ||
self.flag_value.to_i | ||
end | ||
|
||
def set(new_value) | ||
if new_value > 0xffff | ||
self.value_length = 4 | ||
self.flag_value = new_value | ||
elsif new_value > 0xff | ||
self.value_length = 2 | ||
self.flag_value = new_value | ||
elsif new_value > 0 | ||
self.value_length = 1 | ||
self.flag_value = new_value | ||
else | ||
self.value_length = 0 | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.