This python script will connect to your Meshtastic node, and return a list of nodes that your node is directly connected to (that is, Zero hops away).
Tested on Linux and Windows.
cd ~
git clone https://github.com/brad28b/meshtastic-direct-nodes.git
cd meshtastic-direct-nodes
pip3 install -r requirements.txt
python meshtastic-direct-nodes.py
Note: If you use Serial, the script will attempt to find your serial port automatically. You can also change the code to directly specify your serial port, by changing this line:
return meshtastic.serial_interface.SerialInterface("/dev/ttyUSB0") # Replace with your serial port address, for Windows, use "COMx", eg "COM14"