Skip to content

Useful Technical details

Tony edited this page Feb 8, 2021 · 28 revisions

Connecting Chrome debug tools to Node session running on the Raspberry Pi:

On the Raspberry Pi...

Kill the existing node session...

 sudo service homebridge stop
 sudo killall nodejs

Start a debug node session...

 cd /Downloads/HAP-NodeJS
 sudo node --inspect=0.0.0.0:9229 BridgedCore.js

On the remote ( Chrome ) device...

 Open chrome session<br>
 Browse to chrome://inspect/
 Click on 'open dedicated dev tools for node'
 Add <IP address of the Raspberry Pi>:<Port 9229> e.g. 192.168.1.100:9229

After a few seconds, the Raspberry Pi node session should appear under 'Remote Target'

Running the Alarm service as a console app...

This views the text output from the alarm service, and is useful when debugging the interaction between the web page and the alarm service.

From the Raspberry Pi...

Kill the existing alarm session...

 sudo service alarm stop

Run the service as a BASH shell script...

 sudo /var/www/Scripts/alarm.sh

Restart the alarm as a background service...

 Ctrl+C
 sudo service alarm start

Running the HomeBridge service as a console app...

This views the text output of the HomeBridge service, and is useful when debugging issues with the HomeKit accessories, or with the HomeBridge service failing to start.
NB. The HomeBridge service is written in TypeScript. As such, it needs to compile before the code runs. The compilation creates a pause of approximately 2 minutes each time the HomeBridge service is started.

Kill the existing HomeBridge session, and ensure the node process terminates...

 sudo service homebridge stop
 sudo killall node

Move to the code directory...

 cd ~/Downloads/HAP-NodeJS

Run the service as a script...

 sudo ts-node --files src/BridgedCore.ts

HomeBridge common errors:

  1. The script reports 'HAP-NodeJS starting...' then hangs for up to 2 minutes before providing any text output - This is expected behaviour caused by the TypeScript code compiling before running.
  2. Error: listen EADDRINUSE: address already in use - This is caused by a second instance of the service still running in the background. Use sudo killall node to stop the second instance, then re-run the service as a script.

Creating a data partitioning on the SD card...

Copy new image on SD card. Move SD card to Raspberry Pi Boot on Raspberry Pi - image now fills entire disk Shutdown Raspberry Pi

Move SD card back to Windows device... Use Computer management | Disk management to find the Disk number Open VMware player Select Debian device Select Edit virtual machine settings Add... hard disk (next) Select IDE (next) Select Use a physical disk (for advanced users) From the dropdown, select the disk number (next) Click Finish Click OK

Start the Virtual machine Run GPARTED (requires Root credentials) Change device to /dev/sdb Resize (shrink) partition to 4096 MB From the menu bar, select Edit | Apply all operations

Right click and check partition (this is required to set START and END points correctly) From the menu bar, select Edit | Apply all operations

Create new Extended partition From the menu bar, select Edit | Apply all operations

Create new Logical partition - ext4 From the menu bar, select Edit | Apply all operations

Close GPARTED and Shut down Virtual machine

Move SD card back to Rasp Pi

From a terminal session run 'blkid' to find ID for new partition (usually /dev/mncblk0p5) sudo mkdir -p /mnt/media sudo mount -o defaults /dev/mmcblk0p5 /mnt/media ( temp mount )

Permanent mount... blkid - then record the PARTUUID info

sudo nano /etc/fstab

PARTUUID=6c586e13-05 /mnt/media ext4 defaults 0 2

Reboot df -h ( Check if disk available )

Edit /etc/samba/smb.conf to create new data share...

add a section similar to...

[media]

comment = Data directory

path = /mnt/media

browseable = yes

guest ok = no

read only = no

valid users = pi, root