mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
new: ble.show shows device names if available for at least one of the devices
This commit is contained in:
parent
3e7aa68184
commit
a72801f9b5
2 changed files with 46 additions and 14 deletions
|
@ -40,14 +40,21 @@ func NewBLEDevice(p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice
|
|||
}
|
||||
}
|
||||
|
||||
func (d *BLEDevice) Name() string {
|
||||
name := d.Device.Name()
|
||||
if name == "" && d.Advertisement != nil {
|
||||
name = d.Advertisement.LocalName
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func (d *BLEDevice) MarshalJSON() ([]byte, error) {
|
||||
doc := bleDeviceJSON{
|
||||
LastSeen: d.LastSeen,
|
||||
Name: d.Device.Name(),
|
||||
Name: d.Name(),
|
||||
MAC: d.Device.ID(),
|
||||
Vendor: d.Vendor,
|
||||
RSSI: d.RSSI,
|
||||
}
|
||||
|
||||
return json.Marshal(doc)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue