misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2019-02-22 14:10:49 +01:00
commit 87b667c1dc
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -205,33 +205,13 @@ func parseProperties(ch *gatt.Characteristic) (props []string, isReadable bool,
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 {
s := ""
for _, b := range raw {
if strconv.IsPrint(rune(b)) {
s += tui.Yellow(string(b))
} else {
s += tui.Dim(fmt.Sprintf("%x", b))
s += tui.Dim(fmt.Sprintf("%02x", b))
}
}
return s