diff --git a/README.md b/README.md index 2840e38..56db248 100755 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ functions: 6. Automatically archive the recordings. # Release notes +## 0.5.03: +* Fixing broken SD card simuation on latest v3 firmware (4.36.0.252) + ## 0.5.02: * Fixing an install issue with RTSP firmware. * Fixing an issue with NFS connectivity detection. diff --git a/release/wyze_hacks_0_5_03.zip b/release/wyze_hacks_0_5_03.zip new file mode 100755 index 0000000..c8b99c5 Binary files /dev/null and b/release/wyze_hacks_0_5_03.zip differ diff --git a/src/utils/libhacks.c b/src/utils/libhacks.c index 451ce49..0f2f1e7 100755 --- a/src/utils/libhacks.c +++ b/src/utils/libhacks.c @@ -25,11 +25,19 @@ #define HACKDATA_MAGIC 0xDEADBEEF #define MAX_PATH 255 +#define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0]) + +const char* const mmc_gpio_paths[] = { + // 4.36.0.228 and older use GPIO50 to detect MMC insertion. + "/sys/class/gpio/gpio50/value", + // 4.36.0.252 and later uses GPIO62 to detect MMC insertion. + "/sys/class/gpio/gpio62/value" +}; + typedef struct { uint32_t magic; uint32_t nfs_mounted; - char mmc_gpio_path_orig[MAX_PATH]; - char mmc_gpio_path_redir[MAX_PATH]; + char mmc_gpio_redir[MAX_PATH]; } hackdata_t; hackdata_t* g_hackdata; @@ -162,12 +170,16 @@ int open(char * file, int oflag) { typedef int (*PFN_open)(const char*, int); DLSYM(open); - if (strcmp(file, g_hackdata->mmc_gpio_path_orig) == 0) { - // TODO: Replace hardcoded wyzehack path - return s_pfn(g_hackdata->mmc_gpio_path_redir, oflag); - } else { - return s_pfn(file, oflag); + if (g_hackdata->mmc_gpio_redir[0]) { + for (int i = 0; i < ARRAY_SIZE(mmc_gpio_paths); i ++) { + if (strcmp(file, mmc_gpio_paths[i]) == 0) { + printf("Redirecting access to %s to %s\n", + file, g_hackdata->mmc_gpio_redir); + return s_pfn(g_hackdata->mmc_gpio_redir, oflag); + } + } } + return s_pfn(file, oflag); } int hack_init() { @@ -175,20 +187,11 @@ int hack_init() { return -1; } - snprintf( - g_hackdata->mmc_gpio_path_orig, - sizeof(g_hackdata->mmc_gpio_path_orig), - "/sys/class/gpio/gpio%s/value", getenv("MMC_GPIO")); - - snprintf( - g_hackdata->mmc_gpio_path_redir, - sizeof(g_hackdata->mmc_gpio_path_redir), - "%s/mmc_gpio_value.txt", getenv("WYZEHACK_DIR")); - - printf( - "Access to %s will be redirected to %s\n", - g_hackdata->mmc_gpio_path_orig, g_hackdata->mmc_gpio_path_redir); - + const char* p = getenv("MMC_GPIO_REDIR"); + if (p) { + strncpy(g_hackdata->mmc_gpio_redir, p, + sizeof(g_hackdata->mmc_gpio_redir)); + } return 0; } diff --git a/src/utils/libhacks.so b/src/utils/libhacks.so index 91ef9f6..f9122f3 100755 Binary files a/src/utils/libhacks.so and b/src/utils/libhacks.so differ diff --git a/wyze_hack/hack_ver.inc b/wyze_hack/hack_ver.inc index 2023cb9..1d6171a 100755 --- a/wyze_hack/hack_ver.inc +++ b/wyze_hack/hack_ver.inc @@ -1 +1 @@ -export WYZEHACK_VER=0.5.02 +export WYZEHACK_VER=0.5.03 diff --git a/wyze_hack/main.sh b/wyze_hack/main.sh index 4747581..251d4e1 100755 --- a/wyze_hack/main.sh +++ b/wyze_hack/main.sh @@ -18,7 +18,6 @@ case $WYZEAPP_VER in export DEVICE_ID=$(grep -oE "NETRELATED_MAC=[A-F0-9]{12}" /params/config/.product_config | sed 's/NETRELATED_MAC=//g') export DEVICE_MODEL="V1" export SPEAKER_GPIO=63 - export MMC_GPIO=50 ;; 4.9.*) @@ -26,7 +25,6 @@ case $WYZEAPP_VER in export DEVICE_ID=$(grep -oE "NETRELATED_MAC=[A-F0-9]{12}" /params/config/.product_config | sed 's/NETRELATED_MAC=//g') export DEVICE_MODEL="V2" export SPEAKER_GPIO=63 - export MMC_GPIO=50 ;; 4.28.*) @@ -34,7 +32,6 @@ case $WYZEAPP_VER in export DEVICE_ID=$(grep -oE "NETRELATED_MAC=[A-F0-9]{12}" /params/config/.product_config | sed 's/NETRELATED_MAC=//g') export DEVICE_MODEL="V2" export SPEAKER_GPIO=63 - export MMC_GPIO=50 ;; 4.10.*) @@ -42,7 +39,6 @@ case $WYZEAPP_VER in export DEVICE_ID=$(grep -oE "NETRELATED_MAC=[A-F0-9]{12}" /params/config/.product_config | sed 's/NETRELATED_MAC=//g') export DEVICE_MODEL="PAN" export SPEAKER_GPIO=63 - export MMC_GPIO=50 ;; 4.29.*) @@ -50,7 +46,6 @@ case $WYZEAPP_VER in export DEVICE_ID=$(grep -oE "NETRELATED_MAC=[A-F0-9]{12}" /params/config/.product_config | sed 's/NETRELATED_MAC=//g') export DEVICE_MODEL="PAN" export SPEAKER_GPIO=63 - export MMC_GPIO=50 ;; 4.25.*) @@ -58,7 +53,6 @@ case $WYZEAPP_VER in export DEVICE_ID=$(grep -E -o CONFIG_INFO=[0-9A-F]+ /params/config/.product_config | cut -c 13-24) export DEVICE_MODEL="DB" export SPEAKER_GPIO=63 - export MMC_GPIO=50 ;; 4.36.*) @@ -66,7 +60,7 @@ case $WYZEAPP_VER in export DEVICE_ID=$(grep -E -o CONFIG_INFO=[0-9A-F]+ /configs/.product_config | cut -c 13-24) export DEVICE_MODEL="V3" export SPEAKER_GPIO=63 - export MMC_GPIO=50 + export MMC_GPIO_REDIR="$WYZEHACK_DIR/mmc_gpio_value.txt" ;; *) @@ -382,7 +376,9 @@ mount_nfs() { done echo "WyzeHack: Notifying iCamera about SD card insertion event..." - echo "0" > $WYZEHACK_DIR/mmc_gpio_value.txt + if [ ! -z $MMC_GPIO_REDIR ]; then + echo "0" > $MMC_GPIO_REDIR + fi $WYZEHACK_DIR/bin/hackutils mmc_insert # Mark this directory for this camera @@ -525,7 +521,9 @@ cmd_run() { # MMC detection hook init export PATH=$WYZEHACK_DIR/bin:$PATH export LD_LIBRARY_PATH=$WYZEHACK_DIR/bin:$LD_LIBRARY_PATH - echo "1" > $WYZEHACK_DIR/mmc_gpio_value.txt + if [ ! -z $MMC_GPIO_REDIR ];then + echo "1" > $MMC_GPIO_REDIR + fi $WYZEHACK_DIR/bin/hackutils init export WYZEINIT_MD5=$(md5sum $WYZEINIT_SCRIPT| grep -oE "^[0-9a-f]*")