Smartthings Integration

General Discussion

Re: Smartthings Integration

Postby mathewss » Mon Oct 12, 2020 5:51 pm

Fix:

~/esp/st-device-sdk-c-ref
./setup.py esp32_v3.3
./build.py esp32_v3.3 AlarmDecoder-STSDK

Todo:

Get it to work with v4. Something changed in the cmake files between the current switch example and what I have now that will fix this path issue. Its clear the path for the SDK includes is not working the same between 3.x and 4.x.
mathewss
Moderator
Moderator
 
Posts: 188
Joined: Fri Dec 06, 2013 11:14 am

Re: Smartthings Integration

Postby hudoh » Mon Oct 12, 2020 6:26 pm

To make my Pi build environment I followed the instructions on this page:
https://community.smartthings.com/t/how ... ces/204055

After that, I was able to get the switch example to build. Then I ran into a few error with alarmdecoder, a few which I fixed by moving missing files into the alarmdecoder directories, so I assume I may be missing something in my path. After getting through those, I'm stuck with this remaining error at step 898 of 899!:
[898/899] Linking CXX executable alarmdecoder_stsdk_esp32.elf
FAILED: alarmdecoder_stsdk_esp32.elf
hudoh
newt
newt
 
Posts: 16
Joined: Fri Feb 23, 2018 1:46 pm

Re: Smartthings Integration

Postby mathewss » Mon Oct 12, 2020 7:04 pm

I can confirm the switch example also compiles with ESP32 4.x and 3.x

Were you able to build with 3.x?

Best
SM
mathewss
Moderator
Moderator
 
Posts: 188
Joined: Fri Dec 06, 2013 11:14 am

Re: Smartthings Integration

Postby mathewss » Mon Oct 12, 2020 7:32 pm

Looks like 3.x compiles with components.mk where 4.x uses newer CMakeList.txt

Here is the fix.

Will push to github dev branch tomorrow after more testing.

Code: Select all
$ git diff
diff --git a/components/stsdk/CMakeLists.txt b/components/stsdk/CMakeLists.txt
index 8d25acb..426e9cc 100644
--- a/components/stsdk/CMakeLists.txt
+++ b/components/stsdk/CMakeLists.txt
@@ -7,6 +7,8 @@ idf_component_register(SRCS "stsdk_main.cpp"
                             "caps_smokeDetector.c"
                             "caps_switch.c"
                             "caps_tamperAlert.c"
+                    EMBED_FILES "device_info.json"
+                                "onboarding_config.json"
                     REQUIRES idf::otaupdate
-                    INCLUDE_DIRS . ../../main/)
+                    INCLUDE_DIRS . ../../main/ $ENV{STDK_CORE_PATH}/src/include/)
mathewss
Moderator
Moderator
 
Posts: 188
Joined: Fri Dec 06, 2013 11:14 am

Re: Smartthings Integration

Postby mathewss » Mon Oct 12, 2020 7:52 pm

Meh. This needs sorting. Only see this with 4.x build not 3.x so I presume on 4.x build is doing something different in branches of the STSDK that is used.

I need to work on features so hopefully you can figure this part out. It compiles so maybe this warning is not serious. yet.

I am going back to 3.x for now to get some code done :)

Best
SM

Code: Select all
In file included from ../components/stsdk/stsdk_main.h:28,
                 from ../components/stsdk/stsdk_main.cpp:58:
/home/mathewss/esp/st-device-sdk-c-ref/iot-core/src/include/st_dev.h:447:17: note: declared here
 DEPRECATED void st_cap_attr_free(IOT_EVENT* event);
                 ^~~~~~~~~~~~~~~~
../components/stsdk/stsdk_main.cpp: In function 'void cap_current_version_init_cb(void**, void*)':
../components/stsdk/stsdk_main.cpp:860:90: warning: 'void** st_cap_attr_create_string(const char*, char*, const char*)' is deprecated [-Wdeprecated-declarations]
     init_evt = st_cap_attr_create_string("currentVersion", (char *)FIRMWARE_VERSION, NULL);
                                                                                          ^
In file included from ../components/stsdk/stsdk_main.h:28,
mathewss
Moderator
Moderator
 
Posts: 188
Joined: Fri Dec 06, 2013 11:14 am

Re: Smartthings Integration

Postby hudoh » Tue Oct 13, 2020 6:01 pm

Hi Sean - I've had some success, will now try to get father. I got the AlarmDecoder to build on v4 (never got it going on 3.3 after hours of trying). I was able to flash, then connect to Wifi. Here is what I've got, will work on next steps as I start to figure it all out.


E (467842) AD2CLICMD: _cli_cmd_reboot_event: rebooting now.
Restarting now
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5388
load:0x40078000,len:12796
ho 0 tail 12 room 4
load:0x40080400,len:4032
entry 0x40080650
I (447) cpu_start: Pro cpu up.
I (447) cpu_start: Application information:
I (447) cpu_start: Project name: alarmdecoder_stsdk_esp32
I (451) cpu_start: App version: v1.0.0-397-g4367a89-dirty
I (457) cpu_start: Compile time: Oct 13 2020 21:46:00
I (463) cpu_start: ELF file SHA256: 91b36b9669b42ae8...
I (469) cpu_start: ESP-IDF: v4.0.1-317-ga32f06999
I (475) cpu_start: Single core mode
I (480) heap_init: Initializing. RAM available for dynamic allocation:
I (487) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (493) heap_init: At 3FFBB100 len 00024F00 (147 KiB): DRAM
I (499) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (505) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (512) heap_init: At 40094024 len 0000BFDC (47 KiB): IRAM
I (518) cpu_start: Pro cpu start user code
I (537) spi_flash: detected chip: generic
I (538) spi_flash: flash io: qio
I (538) cpu_start: Starting scheduler on PRO CPU.
I (541) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (541) gpio: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (551) gpio: GPIO[14]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (561) gpio: GPIO[27]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (571) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:3
This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 3, 4MB external flash
I (591) HAL: Wifi hardware init
I (611) wifi:wifi driver task: 3ffc22f8, prio:23, stack:6656, core=0
I (611) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (611) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (721) wifi:wifi firmware version: 9156a0d
I (721) wifi:config NVS flash: enabled
I (721) wifi:config nano formating: disabled
I (721) wifi:Init data frame dynamic rx buffer num: 32
I (721) wifi:Init management frame dynamic rx buffer num: 32
I (731) wifi:Init management short buffer num: 32
I (731) wifi:Init dynamic tx buffer num: 32
I (731) wifi:Init static rx buffer size: 1600
I (741) wifi:Init static rx buffer num: 10
I (741) wifi:Init dynamic rx buffer num: 32
W (751) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (891) phy: phy_version: 4180, cb3948e, Sep 12 2019, 16:39:13, 0, 2
I (941) wifi:mode : sta (fc:f5:c4:3c:64:a0)
I (941) HAL: [esp32] iot_bsp_wifi_init done
W (951) AD2_IoT: Unknown ad2source mode ''
AD2IoT operating mode configured. Configure using ad2source command.
I (951) TWILIO: Loading the CA root certificate...
E (961) TWILIO: mbedtls_x509_crt_parse returned -0x2180


I (961) STSDK: STSDK disabled
Press enter in the next 5 seconds to stop the init.
I (1911) wifi:new:<8,0>, old:<1,0>, ap:<255,255>, sta:<8,0>, prof:1
I (2781) wifi:state: init -> auth (b0)
I (2781) wifi:state: auth -> assoc (0)
I (2791) wifi:state: assoc -> run (10)
I (2821) wifi:connected with 1512, aid = 6, channel 8, BW20, bssid = c2:a5:11:28:de:9e
I (2821) wifi:security: WPA2-PSK, phy: bg, rssi: -20
I (2821) wifi:pm start, type: 1

I (2831) HAL: hal_event_handler = 4
I (2911) wifi:AP's beacon interval = 204800 us, DTIM period = 4
I (5281) tcpip_adapter: sta ip: 192.168.1.51, mask: 255.255.255.0, gw: 192.168.1.1
I (5281) HAL: got ip:192.168.1.51 rssi:-21dBm
Starting main task.
I (35981) AD2OTA: Starting check new version
I (40401) AD2OTA: ota_https_read_version_info: Connection closed,all data received
I (40401) AD2OTA: ota_https_read_version_info: Written image length 152
I (40411) AD2OTA: ota_api_get_available_version: isNewVersion : 0
hudoh
newt
newt
 
Posts: 16
Joined: Fri Feb 23, 2018 1:46 pm

Re: Smartthings Integration

Postby hudoh » Tue Oct 13, 2020 6:26 pm

OK - ESP32 is connected to Wifi, then connected to my AD2PI. I get alarm state updates on the ESP32, like this:

I (711921) AD2_IoT: MESSAGE_CB: '[00000001100000000A--],003,[f70600ff1003000028020000000000],"FAULT 03 FRONT DOOR
I (855891) AD2_IoT: MESSAGE_CB: '[10000001100000003A--],008,[f70600ff1008001c28020000000000]," DISARMED CHIME Ready to Arm "

So,this is great progress for me!

When I try to add my test devide to ST App, it is asking me to scan the QR Code on the back or add by serial number. What serial number should I use for this or is this step not working correctly?
hudoh
newt
newt
 
Posts: 16
Joined: Fri Feb 23, 2018 1:46 pm

Re: Smartthings Integration

Postby hudoh » Tue Oct 13, 2020 6:43 pm

Next update from me...

I used the serial number sent to me by you, Sean. I tried that before, but upon checking, I realized one of the letters was a lowercase L and not I. So, when I enter the serial number correctly, it does try to add the device but I end up with the following error:

Unable to join the network "AD2IOTV10_E40AOf1006vheAM1NK"

Thoughts?
hudoh
newt
newt
 
Posts: 16
Joined: Fri Feb 23, 2018 1:46 pm

Re: Smartthings Integration

Postby mathewss » Tue Oct 13, 2020 6:59 pm

Check and be sure the netmode is set to N

Then confirm after rebooting it that you see a wifi access point with the name AD2IOTV10_E40AOf1006vheAM1NK

If the network mode is W or E then it will prevent SmartThings from starting and presumes you will be running with no SmartThings.
This is because SmartThings needs to control the Wifi driver to allow auto discovery and On Boarding to your devices.

Best
SM
mathewss
Moderator
Moderator
 
Posts: 188
Joined: Fri Dec 06, 2013 11:14 am

Previous

Return to General

Who is online

Users browsing this forum: Google [Bot] and 22 guests

cron