Get bluetooth mac address mac

Shell command for getting mac address in OS X

I have been handicapped by the GUI and always seem to ask of help when it comes to the command line. On Mac OS X only I need a command line to get the mac address of the wifi currently in use. Help!

6 Answers 6

ifconfig en1 gets the interface details for wifi, the mac is on a line starting with ether, and is the second word on that line so:

awk and grep ? Why not just ifconfig en1 | awk ‘/ether/

How to know the WiFi interface index for sure? It seems like it’s en0 for some people so your code would fail

For macbooks it’s normally en0 these days, as per another answer ifconfig en0 | awk ‘/ether/

This is wrong, if your are on VPN and have additional CONX, you won’t be able to get the right MAC address. I posted a solution that chooses the right Address below.

I think the best and easiest way to get the information is using this command:

networksetup -listallhardwareports 

It will return a nice list of devices like this:

Hardware Port: USB 10/100/1000 LAN Device: en6 Ethernet Address: 00:e0:4c. Hardware Port: Wi-Fi Device: en0 Ethernet Address: 80:e6:50. Hardware Port: Bluetooth PAN Device: en3 Ethernet Address: 80:e6:50. Hardware Port: Thunderbolt 1 Device: en1 Ethernet Address: 72:00:05. Hardware Port: Thunderbolt 2 Device: en2 Ethernet Address: 72:00:05. Hardware Port: Thunderbolt Bridge Device: bridge0 Ethernet Address: 72:00:05. VLAN Configurations =================== 

Источник

How to find Bluetooth MAC Address in Windows

There are cases when you need to determine the Bluetooth MAC Address of your Windows PC or tablet.
Bluetooth Address is usually displayed in the form of 12 hexadecimalal digits.

Two different methods to obtain this information are presented below. Use the method that is more appropriate in your situation.

Finding Bluetooth MAC Address from the GUI

1. Click the Bluetooth icon in the system tray and select «Open Settings».

Open bluetooth settings from tray icon

2. In the «Bluetooth Settings» form go to «Hardware tab».

3. Select «Bluetooth Radio» in the Devices list and click «Properties».

Bluetooth settings - Hardware

4. In the «Bluetooth Radio Properties» form go to «Advanced» tab.
The Bluetooth MAC Address is displayed in the «Address» line.

Читайте также:  Bluetooth гарнитура harper hb 600

Bluetooth Radio Properties - Advanced - MAC Address

The following video shows the process of finding out Bluetooth Address in Windows 10

Finding Bluetooth MAC Address from the command line

The btinfo command displays a lot of information about your bluetooth adapter, including it’s MAC Address.

Bluetooth adapter details - btinfo command

To display only the Bluetooth MAC Address run btinfo with the «-a» switch.

Bluetooth MAC Address - btinfo command

btinfo is not available on your system out of the box. It’s a part of the freeware Bluetooth command line tools suite.

Источник

How to obtain Bluetooth MAC Address using Swift on OSX

I’ve looked online in many places on trying to obtain the Bluetooth MAC Address of my Macbook Air. Everything I’ve stumbled upon has only been based towards iOS development and nothing towards the macOS field. Everything else says it has been depreciated past iOS 7, so I don’t know if it would be possible on the latest Mac operating system. Does anyone know if it is possible under any framework? I’m not looking to submit this to the App Store.

2 Answers 2

The best option I could find for obtaining the Bluetooth MAC Address from a macOS app with Swift revolves around executing a terminal command and then formatting the output.

It would just be a matter of specifying the launchPath of networksetup & using the flag listallhardwareports to obtain an output.

I’ve reconsidered using this information as of now, but this does seem the most logical when trying to obtain the address. Thanks anyways!

@dylan — No problem, sorry I couldn’t be of more help. I was originally going to suggest importing C code into Swift to use this — but obviously that’s not the MAC address you’re looking for. Doesn’t seem they have a Bluetooth version implemented yet.

I was able to get the output, as follows: Ethernet Address: 00:00:00:00:00:00 (Hardware Port: Bluetooth PAN) . How can I only subject my output to the address rather than the information with the hardware port and stating «Ethernet Address:» beforehand. Thanks! @MattGalaxy

If encasing the shell function call with readLine doesn’t allow you to capture the output from the command- I’d suggest trying implement a pipe (perhaps using the code I linked to in my answer as an example?) Glad I can help though 🙂

I actually changed mine over to yours in this time, I’m just trying to figure out how to remove the beginning. I can remove the end characters, just nothing before the address. @MattGalaxy

Using a Bash Script

I’d like to thank @MattGalaxy for the suggestion and the assistance shown in the comments below under his answer. Eventually, it all worked out well and here’s how I pulled this off. This can work in a Playground or in a macOS application you are building with Xcode.

Читайте также:  Включить блютуз через командную строку виндовс 10

Here’s the code to go along with it:

 import Foundation let task = Process() task.launchPath = "/usr/bin/env" task.arguments = ["networksetup", "-getmacaddress", "en2"] let pipe = Pipe() task.standardOutput = pipe task.standardError = pipe task.launch() task.waitUntilExit() let data = pipe.fileHandleForReading.readDataToEndOfFile() let output: String = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as! String 
Ethernet Address: XX:XX:XX:XX:XX:XX (Device: en2) 

This does say Ethernet address, however, the device en2 is specifically used for Bluetooth, so all this captures is that.

I set the variable bluetoothAddress equal to the output above.

var bluetoothAddress = output 

And then just played around until I was able to crunch only the address between these.

let startIndex = bluetoothAddress.index(bluetoothAddress.startIndex, offsetBy: 18) let endIndex = bluetoothAddress.index(bluetoothAddress.startIndex, offsetBy: 34) bluetoothAddress = bluetoothAddress[startIndex. endIndex] 

And then finally, giving off the output I was requesting for originally in the question:

(Keep in mind, I used placeholder XX’s throughout this answer to keep my privacy :P)

Источник

3 Methods to Get Bluetooth MAC Address in Linux

3 Methods to Get Bluetooth MAC Address in Linux

A Bluetooth MAC (Media Access Control) address is a unique 48-bit value assigned to a Bluetooth device by the manufacturer to uniquely identify it.

This tutorial provides 3 methods how to get Bluetooth MAC address in the Linux. Commands have been tested on Raspberry Pi OS.

Method 1 — hcitool command

The hcitool command can be used to configure Bluetooth connections. The following command prints the MAC address of the Bluetooth device:

Method 2 — hciconfig command

The hciconfig command can be used to configure Bluetooth devices. To print Bluetooth MAC address, use the following command:

hciconfig | grep 'BD Address' | cut -d' ' -f3

Method 3 — hci0/identity file

It is possible to read hci0/identity file which contains MAC address of the Bluetooth device:

sudo cat /sys/kernel/debug/bluetooth/hci0/identity | cut -d' ' -f1

Install CrateDB Inside Docker Container in Linux

CrateDB is a distributed SQL database for relational and time-series data. CreateDB is an open-source.

Install Homer Inside Docker Container in Linux

Homer is a web-based dashboard tool that provides a customizable interface for accessing frequently used.

Источник

Get the MAC address of bluetooth adapter in Android

I’m trying to get the MAC address of bluetooth in my android device. So I’m using the following method:

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); String macAddress = mBluetoothAdapter.getAddress(); 

The address returned is 02:00:00:00:00:00 . I’ve seen questions and posts saying that it’s not possible anymore to get your MAC address in android unless your application is a System Application. So what if I really need to get the MAC address of my phone?? It’s impossible to do it or what? Note: I know this question is asked lots of times on SO, but most of the answers are out of date.

3 Answers 3

For security reasons this functionality is not available on Android since Android version 6.0 [source]:-

To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00.

The reason for this is to stop random applications gaining information about the phone’s hardware addresses therefore violating the privacy/data protection.

Читайте также:  Xbox one bluetooth module

Yes it was made impossible because it can be an attack vector. The only workaround I can think of is if you downgrade your OS to pre Android v6.0. Why do you need your mac address? There might be another way to achieve what you want without accessing the mac address.

Let’s say I have a phone with MAC Address X, and I have another nearby device with MAC address B. When the two devices are nearby each other. I was able to get the MAC address of the other device using BluetoothDevice and getAddress() method from ScanResult.getDevice() . So what I still need is to catch my own device MAC address so that in the backend I save each user with his MAC address, and when I catch it in bluetooth, I know who’s nearby me. I really don’t know if I made myself clear it;s a little bit complicated to explain, sorry for the long comment.

I think I understand your application, but as you can imagine this would be undesirable for Google because your app will know the location of any user that comes in close range with you, therefore violating their privacy. Have a look at this article which explains something a bit similar to your idea and its challenges:- wyldnetworks.com/wyld-mesh-covid-19-proximity-contact-tracing

What Youssif Saeed said in the other answer was correct. Android won’t let us get the MAC address anymore.

Brief description about what I want:

Let’s say I have a phone with MAC Address X, and I have another nearby device with MAC address B. When the two devices are nearby each other. I was able to get the MAC address of the other device using BluetoothDevice and getAddress() method from ScanResult.getDevice(). So what I still need is to catch my own device MAC address so that in the backend I save each user with his MAC address, and when I catch it in bluetooth, I know who’s nearby me

Here’s the workaround I’ve done in order to send some data between near devices.

I found something called Nearby Messages API. It is available for Android and iOS and very easy to implement. Now I’m able to catch near devices with my application installed on them, and send a unique Id generated by the application to identify the user.

Источник

Оцените статью
Adblock
detector