mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
fix: setting BLE device name once services are enumerated
This commit is contained in:
parent
64a5ce2b58
commit
d6e6746809
2 changed files with 14 additions and 3 deletions
|
@ -367,6 +367,10 @@ func (mod *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) {
|
||||||
data = parseRawData(raw)
|
data = parseRawData(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ch.Name() == "Device Name" && data != "" && mod.currDevice.DeviceName == "" {
|
||||||
|
mod.currDevice.DeviceName = data
|
||||||
|
}
|
||||||
|
|
||||||
if multi == nil {
|
if multi == nil {
|
||||||
char.Data = data
|
char.Data = data
|
||||||
rows = append(rows, []string{
|
rows = append(rows, []string{
|
||||||
|
|
|
@ -28,6 +28,7 @@ type BLEService struct {
|
||||||
|
|
||||||
type BLEDevice struct {
|
type BLEDevice struct {
|
||||||
LastSeen time.Time
|
LastSeen time.Time
|
||||||
|
DeviceName string
|
||||||
Vendor string
|
Vendor string
|
||||||
RSSI int
|
RSSI int
|
||||||
Device gatt.Peripheral
|
Device gatt.Peripheral
|
||||||
|
@ -62,9 +63,15 @@ func NewBLEDevice(p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BLEDevice) Name() string {
|
func (d *BLEDevice) Name() string {
|
||||||
name := d.Device.Name()
|
// get the name if it's being set during services enumeration via 'Device Name'
|
||||||
if name == "" && d.Advertisement != nil {
|
name := d.DeviceName
|
||||||
name = d.Advertisement.LocalName
|
if name == "" {
|
||||||
|
// get the name from the device
|
||||||
|
name := d.Device.Name()
|
||||||
|
if name == "" && d.Advertisement != nil {
|
||||||
|
// get the name from the advertisement data
|
||||||
|
name = d.Advertisement.LocalName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue