Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Automation for Mac #59

Merged
merged 9 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions scripts/demo_Mac/autostart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
BASEDIR=$(dirname -- "$( readlink -f -- "$0"; )")
cd $BASEDIR;
source ./settings.sh
read -p "Do you want to clean up the esp32 and m5stack before flashing? Type in yes to clean up or click enter to skip: " prompt
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
then
echo "Cleaning the esp32 and m5stack please wait..."
sh ./cleanup.sh
fi
osascript -e 'tell app "Terminal" to do script "cd '$BASEDIR'; source '$BASEDIR'/settings.sh; sh ./hub_start.sh"' $BASEDIR
read -p "Wait until Hub is flashing and click enter " prompt
osascript -e 'tell app "Terminal" to do script "cd '$BASEDIR'; source '$BASEDIR'/settings.sh; sh ./enddevice_start.sh"' $BASEDIR
read -p "Wait until Enddevice is flashing and click enter " prompt
sh ./chiptool_start.sh
osascript -e 'tell app "Terminal" to do script "matter switch binding unicast 1 333 1" in window 3'
echo "autostart process is completed!"
7 changes: 7 additions & 0 deletions scripts/demo_Mac/chiptool_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
cd $MATTERPATH/thirdparty/chip/repo
rm -rf out
./scripts/examples/gn_build_example.sh examples/chip-tool out/
./out/chip-tool pairing ble-wifi 111 "${SSID}" "${PASSWORD}" 20202021 3840
./out/chip-tool pairing ble-wifi 333 "${SSID}" "${PASSWORD}" 20202021 3840
./out/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null },{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [111], "targets": null }]' 333 0
11 changes: 11 additions & 0 deletions scripts/demo_Mac/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
BASEDIR=$(dirname -- "$( readlink -f -- "$0"; )")
cd $BASEDIR;
source $BASEDIR/settings.sh
cd $MATTERPATH
source ./scripts/activate.sh
cd src
idf.py build
idf.py erase_flash -p $HUB
idf.py erase_flash -p $ENDDEVICE
rm -rf /tmp/*.ini /tmp/chip_*
6 changes: 6 additions & 0 deletions scripts/demo_Mac/enddevice_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
cd $MATTERPATH
source ./scripts/activate.sh
cd src
idf.py build
idf.py flash monitor -p "${ENDDEVICE}"
6 changes: 6 additions & 0 deletions scripts/demo_Mac/hub_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
cd $MATTERPATH
source ./scripts/activate.sh
cd src
idf.py build
idf.py flash monitor -p "${HUB}"
31 changes: 31 additions & 0 deletions scripts/demo_Mac/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# How to configure the autostart process on Mac?
#### 1. Go to the settings.sh file and change the ENDDEVICE and HUB variables to the mounting points of your USB devices.
#### You can find it out by typing ``` ls /dev/tty* | grep usb ``` into the console.
#### 2. Write the SSID and the Passwort of your WiFi Router.
#### 3. Write the file path of the matterHub project directory.


# How to launch the program on Mac?
#### 1. Click on autostart.sh and start the script on the Terminal. Alternatively, you can also start it by using the Terminal command ``` sh autostart.sh ``` but don't forget to iterate to the folder using ``` cd path_of_the_demo_mac_folder ```.
#### 2. If you want to clean up the esp32 and m5stack before flashing, type in yes or y to clean up else click enter to skip.
#### 3. A new window will appear. If you can see the percentage of the Hub window is going up, it means the Hub is in the flashing process. Now you can continue by clicking enter in the autostart.sh window.
#### 4. Now the same thing for the Enddevice. A window will appear. When you can see the percentage of the Enddevice window is going up, it's time to click enter in the autostart.sh window.
#### 5. Wait until the autostart.sh terminal window says that the autostart process is completed.

#### Warning: Your devices must be plugged in before starting the program!
#### If you run matterHub for the first time or have deleted the build directory, the Enddevice and Hub build the dependencies. Be patient, this could take a bit!


# Troubleshooting
#### If your Hub Console gives you an ``` Error: -1 ``` after this matter command: ``` matter switch binding unicast 1 333 1 ``` autostart.sh probably tried to insert the code while matter was executing something else.
#### Type in ``` matter switch binding unicast 1 333 1 ``` and the result should be ``` Done ```.


#### If you get a Ram or Flash Error on the console for the m5stack, you have to install this tool:
https://blog.squix.org/2021/08/ch9102-driver-issues-failed-to-write-to-target-ram.html


#### If you get a Flash Error, you can try to click on the buttons to reboot and reload the respective device.


#### If you have any other troubles or Error messages like a CMake Error, go to the matterHub Project directory --> src and delete the build directory. After deleting the build directory run autostart.sh and wait until Enddevice and Hub build their dependencies. Be patient, this could take a bit!
6 changes: 6 additions & 0 deletions scripts/demo_Mac/settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
export ENDDEVICE="Write your USB Mounting Point of the m5 stack here"
export HUB="Write your USB Mounting Point of the esp32 here"
export SSID='Write your Wifi SSID here'
export PASSWORD='Write your Wifi Password here'
export MATTERPATH="Write the matterHub Project Directory Path here"