mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -07:00
new: exposing flags and connectable fields for BLE devices in api.rest
This commit is contained in:
parent
384815524f
commit
e90c6b5e2d
1 changed files with 14 additions and 10 deletions
|
@ -19,11 +19,13 @@ type BLEDevice struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bleDeviceJSON struct {
|
type bleDeviceJSON struct {
|
||||||
LastSeen time.Time `json:"last_seen"`
|
LastSeen time.Time `json:"last_seen"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
MAC string `json:"mac"`
|
MAC string `json:"mac"`
|
||||||
Vendor string `json:"vendor"`
|
Vendor string `json:"vendor"`
|
||||||
RSSI int `json:"rssi"`
|
RSSI int `json:"rssi"`
|
||||||
|
Connectable bool `json:"connectable"`
|
||||||
|
Flags string `json:"flags"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBLEDevice(p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice {
|
func NewBLEDevice(p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice {
|
||||||
|
@ -50,11 +52,13 @@ func (d *BLEDevice) Name() string {
|
||||||
|
|
||||||
func (d *BLEDevice) MarshalJSON() ([]byte, error) {
|
func (d *BLEDevice) MarshalJSON() ([]byte, error) {
|
||||||
doc := bleDeviceJSON{
|
doc := bleDeviceJSON{
|
||||||
LastSeen: d.LastSeen,
|
LastSeen: d.LastSeen,
|
||||||
Name: d.Name(),
|
Name: d.Name(),
|
||||||
MAC: d.Device.ID(),
|
MAC: d.Device.ID(),
|
||||||
Vendor: d.Vendor,
|
Vendor: d.Vendor,
|
||||||
RSSI: d.RSSI,
|
RSSI: d.RSSI,
|
||||||
|
Connectable: d.Advertisement.Connectable,
|
||||||
|
Flags: d.Advertisement.Flags.String(),
|
||||||
}
|
}
|
||||||
return json.Marshal(doc)
|
return json.Marshal(doc)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue