mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
774413fad7
commit
87b667c1dc
1 changed files with 1 additions and 21 deletions
|
@ -205,33 +205,13 @@ func parseProperties(ch *gatt.Characteristic) (props []string, isReadable bool,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func isMostlyPrintable(raw []byte) bool {
|
|
||||||
if raw == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
tot := len(raw)
|
|
||||||
if tot == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
pr := 0
|
|
||||||
for _, b := range raw {
|
|
||||||
if strconv.IsPrint(rune(b)) {
|
|
||||||
pr++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (float32(pr) / float32(tot)) >= 0.5
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseRawData(raw []byte) string {
|
func parseRawData(raw []byte) string {
|
||||||
s := ""
|
s := ""
|
||||||
for _, b := range raw {
|
for _, b := range raw {
|
||||||
if strconv.IsPrint(rune(b)) {
|
if strconv.IsPrint(rune(b)) {
|
||||||
s += tui.Yellow(string(b))
|
s += tui.Yellow(string(b))
|
||||||
} else {
|
} else {
|
||||||
s += tui.Dim(fmt.Sprintf("%x", b))
|
s += tui.Dim(fmt.Sprintf("%02x", b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue