├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .gitmodules ├── CHANGELOG ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── doc ├── APIs.md ├── Commercialization_Guide.md ├── SAMSUNGCLA.docx ├── STDK_Key_Generation.md ├── STDK_QR_Generation.md ├── getting_started.md ├── porting_guide.md └── res │ ├── add-product-info.gif │ ├── add_device1.png │ ├── add_device2.png │ ├── add_device3.png │ ├── adding_test_device2.png │ ├── create-device-onboarding.gif │ ├── create-device-profile.gif │ ├── create-project.gif │ ├── deploy_to_test_switch.png │ ├── developer_mode.png │ ├── device_control1.png │ ├── downloading_onboarding_config_file_switch.png │ ├── register-test-device.gif │ ├── sign_in.png │ ├── st_device_sdk_arch.jpg │ └── st_logo.png ├── example ├── esp32 │ ├── CMakeLists.txt │ ├── README.md │ ├── custom_partitions.csv │ ├── main │ │ ├── CMakeLists.txt │ │ ├── device_control.c │ │ ├── device_control.h │ │ ├── device_info.json │ │ ├── idf_component.yml │ │ ├── iot_cli_cmd.c │ │ ├── iot_cli_cmd.h │ │ ├── iot_uart_cli.c │ │ ├── iot_uart_cli.h │ │ ├── main.c │ │ ├── onboarding_config.json │ │ └── stdkconfig.cmake │ ├── sdkconfig │ ├── sdkconfig.esp32c3 │ └── sdkconfig.esp32s3 ├── posix │ ├── CMakeLists.txt │ ├── README.md │ ├── example.c │ └── stdkconfig.cmake └── raspberry │ ├── CMakeLists.txt │ ├── README.md │ ├── device_info.json │ ├── example.c │ ├── onboarding_config.json │ └── stdkconfig.cmake ├── make └── common.mk ├── src ├── CMakeLists.txt ├── Kconfig ├── component.cmake ├── component.mk ├── deps │ ├── cbor │ │ └── tinycbor │ │ │ ├── LICENSE │ │ │ ├── README │ │ │ ├── VERSION │ │ │ └── src │ │ │ ├── cbor.h │ │ │ ├── cborencoder.c │ │ │ ├── cborencoder_close_container_checked.c │ │ │ ├── cborerrorstrings.c │ │ │ ├── cborinternal_p.h │ │ │ ├── cborjson.h │ │ │ ├── cborparser.c │ │ │ ├── cborparser_dup_string.c │ │ │ ├── cbortojson.c │ │ │ ├── cborvalidation.c │ │ │ ├── compilersupport_p.h │ │ │ ├── tinycbor-version.h │ │ │ └── utf8_p.h │ ├── curl │ │ ├── Makefile │ │ └── port │ │ │ └── include │ │ │ └── curl_config.h │ ├── json │ │ └── Makefile │ ├── libsodium │ │ ├── CMakeLists.txt │ │ ├── Makefile │ │ └── port │ │ │ └── include │ │ │ └── sodium │ │ │ └── version.h │ └── mbedtls │ │ ├── Makefile │ │ └── port │ │ └── posix │ │ └── include │ │ └── mbedtls │ │ └── posix_config.h ├── easysetup │ ├── CMakeLists.txt │ ├── ble │ │ ├── easysetup_ble.h │ │ ├── iot_easysetup_ble.c │ │ ├── iot_easysetup_ble_ecdh.c │ │ ├── iot_easysetup_ble_msg.c │ │ ├── iot_easysetup_ble_task.c │ │ └── iot_easysetup_d2d_ble.c │ ├── discovery │ │ ├── advertiser │ │ │ └── iot_easysetup_discovery_advertiser.c │ │ └── ssid │ │ │ └── iot_easysetup_discovery_ssid.c │ ├── http │ │ ├── easysetup_http.h │ │ ├── iot_easysetup_http.c │ │ ├── iot_easysetup_http_parser.c │ │ ├── tcp │ │ │ ├── iot_easysetup_d2d_tcp.c │ │ │ └── iot_easysetup_httpd.c │ │ └── tls │ │ │ ├── iot_easysetup_d2d_tls.c │ │ │ └── iot_easysetup_http_tls.c │ └── iot_easysetup_st_mqtt.c ├── include │ ├── bsp │ │ ├── bl602 │ │ │ └── iot_bsp_custom.h │ │ ├── esp32 │ │ │ └── iot_bsp_custom.h │ │ ├── iot_bsp_ble.h │ │ ├── iot_bsp_debug.h │ │ ├── iot_bsp_fs.h │ │ ├── iot_bsp_nv_data.h │ │ ├── iot_bsp_random.h │ │ ├── iot_bsp_system.h │ │ ├── iot_bsp_wifi.h │ │ └── posix │ │ │ └── iot_bsp_custom.h │ ├── caps │ │ ├── iot_caps_helper.h │ │ ├── iot_caps_helper_accelerationSensor.h │ │ ├── iot_caps_helper_activityLightingMode.h │ │ ├── iot_caps_helper_airQualitySensor.h │ │ ├── iot_caps_helper_alarm.h │ │ ├── iot_caps_helper_audioMute.h │ │ ├── iot_caps_helper_audioVolume.h │ │ ├── iot_caps_helper_battery.h │ │ ├── iot_caps_helper_bodyMassIndexMeasurement.h │ │ ├── iot_caps_helper_bodyWeightMeasurement.h │ │ ├── iot_caps_helper_button.h │ │ ├── iot_caps_helper_carbonDioxideHealthConcern.h │ │ ├── iot_caps_helper_carbonDioxideMeasurement.h │ │ ├── iot_caps_helper_carbonMonoxideDetector.h │ │ ├── iot_caps_helper_carbonMonoxideMeasurement.h │ │ ├── iot_caps_helper_colorControl.h │ │ ├── iot_caps_helper_colorTemperature.h │ │ ├── iot_caps_helper_contactSensor.h │ │ ├── iot_caps_helper_dishwasherOperatingState.h │ │ ├── iot_caps_helper_doorControl.h │ │ ├── iot_caps_helper_dryerOperatingState.h │ │ ├── iot_caps_helper_dustHealthConcern.h │ │ ├── iot_caps_helper_dustSensor.h │ │ ├── iot_caps_helper_energyMeter.h │ │ ├── iot_caps_helper_equivalentCarbonDioxideMeasurement.h │ │ ├── iot_caps_helper_execute.h │ │ ├── iot_caps_helper_fanOscillationMode.h │ │ ├── iot_caps_helper_fanSpeed.h │ │ ├── iot_caps_helper_filterStatus.h │ │ ├── iot_caps_helper_fineDustHealthConcern.h │ │ ├── iot_caps_helper_fineDustSensor.h │ │ ├── iot_caps_helper_firmwareUpdate.h │ │ ├── iot_caps_helper_formaldehydeMeasurement.h │ │ ├── iot_caps_helper_garageDoorControl.h │ │ ├── iot_caps_helper_gasMeter.h │ │ ├── iot_caps_helper_illuminanceMeasurement.h │ │ ├── iot_caps_helper_imageCapture.h │ │ ├── iot_caps_helper_lock.h │ │ ├── iot_caps_helper_mediaInputSource.h │ │ ├── iot_caps_helper_mediaPlayback.h │ │ ├── iot_caps_helper_mediaPlaybackRepeat.h │ │ ├── iot_caps_helper_mediaPlaybackShuffle.h │ │ ├── iot_caps_helper_mode.h │ │ ├── iot_caps_helper_moldHealthConcern.h │ │ ├── iot_caps_helper_momentary.h │ │ ├── iot_caps_helper_motionSensor.h │ │ ├── iot_caps_helper_objectDetection.h │ │ ├── iot_caps_helper_odorSensor.h │ │ ├── iot_caps_helper_operatingState.h │ │ ├── iot_caps_helper_ovenOperatingState.h │ │ ├── iot_caps_helper_ovenSetpoint.h │ │ ├── iot_caps_helper_pHMeasurement.h │ │ ├── iot_caps_helper_panicAlarm.h │ │ ├── iot_caps_helper_powerMeter.h │ │ ├── iot_caps_helper_powerSource.h │ │ ├── iot_caps_helper_presenceSensor.h │ │ ├── iot_caps_helper_radonHealthConcern.h │ │ ├── iot_caps_helper_rapidCooling.h │ │ ├── iot_caps_helper_refresh.h │ │ ├── iot_caps_helper_relativeHumidityMeasurement.h │ │ ├── iot_caps_helper_remoteControlStatus.h │ │ ├── iot_caps_helper_robotCleanerMovement.h │ │ ├── iot_caps_helper_robotCleanerTurboMode.h │ │ ├── iot_caps_helper_samsungTV.h │ │ ├── iot_caps_helper_securitySystem.h │ │ ├── iot_caps_helper_signalStrength.h │ │ ├── iot_caps_helper_sleepSensor.h │ │ ├── iot_caps_helper_smokeDetector.h │ │ ├── iot_caps_helper_soundPressureLevel.h │ │ ├── iot_caps_helper_soundSensor.h │ │ ├── iot_caps_helper_switch.h │ │ ├── iot_caps_helper_switchLevel.h │ │ ├── iot_caps_helper_tamperAlert.h │ │ ├── iot_caps_helper_temperatureAlarm.h │ │ ├── iot_caps_helper_temperatureMeasurement.h │ │ ├── iot_caps_helper_thermostatCoolingSetpoint.h │ │ ├── iot_caps_helper_thermostatFanMode.h │ │ ├── iot_caps_helper_thermostatHeatingSetpoint.h │ │ ├── iot_caps_helper_thermostatMode.h │ │ ├── iot_caps_helper_thermostatOperatingState.h │ │ ├── iot_caps_helper_thermostatSetpoint.h │ │ ├── iot_caps_helper_threeAxis.h │ │ ├── iot_caps_helper_timedSession.h │ │ ├── iot_caps_helper_tone.h │ │ ├── iot_caps_helper_tvocHealthConcern.h │ │ ├── iot_caps_helper_tvocMeasurement.h │ │ ├── iot_caps_helper_ultravioletIndex.h │ │ ├── iot_caps_helper_valve.h │ │ ├── iot_caps_helper_veryFineDustHealthConcern.h │ │ ├── iot_caps_helper_veryFineDustSensor.h │ │ ├── iot_caps_helper_voltageMeasurement.h │ │ ├── iot_caps_helper_waterSensor.h │ │ └── iot_caps_helper_windowShade.h │ ├── certs │ │ └── root_ca.h │ ├── external │ │ └── JSON.h │ ├── iot_capability.h │ ├── iot_common.h │ ├── iot_debug.h │ ├── iot_dump_log.h │ ├── iot_easysetup.h │ ├── iot_error.h │ ├── iot_internal.h │ ├── iot_log_file.h │ ├── iot_main.h │ ├── iot_mqtt.h │ ├── iot_nv_data.h │ ├── iot_serialize.h │ ├── iot_util.h │ ├── iot_uuid.h │ ├── iot_wt.h │ ├── mqtt │ │ ├── iot_mqtt_client.h │ │ ├── iot_mqtt_connect.h │ │ ├── iot_mqtt_format.h │ │ ├── iot_mqtt_packet.h │ │ ├── iot_mqtt_publish.h │ │ ├── iot_mqtt_stacktrace.h │ │ ├── iot_mqtt_subscribe.h │ │ └── iot_mqtt_unsubscribe.h │ ├── os │ │ └── iot_os_util.h │ ├── port │ │ ├── port_crypto.h │ │ └── port_net.h │ ├── profile │ │ └── json │ │ │ ├── device_info_example.json │ │ │ └── onboarding_config_example.json │ ├── security │ │ ├── backend │ │ │ ├── iot_security_be.h │ │ │ └── iot_security_be_bsp.h │ │ ├── iot_security_common.h │ │ ├── iot_security_crypto.h │ │ ├── iot_security_ecdh.h │ │ ├── iot_security_error.h │ │ ├── iot_security_manager.h │ │ ├── iot_security_storage.h │ │ └── iot_security_util.h │ ├── st_caps.h │ ├── st_dev.h │ └── st_dev_version.h ├── iot_api.c ├── iot_capability.c ├── iot_dump_log.c ├── iot_log_file.c ├── iot_main.c ├── iot_nv_data.c ├── iot_root_ca.c ├── iot_serialize.c ├── iot_util.c ├── iot_uuid.c ├── iot_wt.c ├── mqtt │ ├── CMakeLists.txt │ ├── client │ │ └── iot_mqtt_client.c │ └── packet │ │ ├── iot_mqtt_connect_client.c │ │ ├── iot_mqtt_connect_server.c │ │ ├── iot_mqtt_deserialize_publish.c │ │ ├── iot_mqtt_format.c │ │ ├── iot_mqtt_packet.c │ │ ├── iot_mqtt_serialize_publish.c │ │ ├── iot_mqtt_subscribe_client.c │ │ ├── iot_mqtt_subscribe_server.c │ │ ├── iot_mqtt_unsubscribe_client.c │ │ └── iot_mqtt_unsubscribe_server.c ├── port │ ├── bsp │ │ ├── bl602 │ │ │ ├── iot_bsp_ble_bl602.c │ │ │ ├── iot_bsp_debug_bl602.c │ │ │ ├── iot_bsp_fs_bl602.c │ │ │ ├── iot_bsp_nv_data_bl602.c │ │ │ ├── iot_bsp_random_bl602.c │ │ │ ├── iot_bsp_system_bl602.c │ │ │ └── iot_bsp_wifi_bl602.c │ │ ├── esp32 │ │ │ ├── CMakeLists.txt │ │ │ ├── iot_bsp_ble_esp32.c │ │ │ ├── iot_bsp_debug_esp32.c │ │ │ ├── iot_bsp_fs_esp32.c │ │ │ ├── iot_bsp_nv_data_esp32.c │ │ │ ├── iot_bsp_random_esp32.c │ │ │ ├── iot_bsp_system_esp32.c │ │ │ └── iot_bsp_wifi_esp32.c │ │ ├── posix │ │ │ ├── CMakeLists.txt │ │ │ ├── iot_bsp_debug_posix.c │ │ │ ├── iot_bsp_fs_posix.c │ │ │ ├── iot_bsp_nv_data_posix.c │ │ │ ├── iot_bsp_random_posix.c │ │ │ ├── iot_bsp_system_posix.c │ │ │ └── iot_bsp_wifi_posix.c │ │ └── raspberry │ │ │ ├── CMakeLists.txt │ │ │ ├── iot_bsp_debug_linux.c │ │ │ ├── iot_bsp_fs_linux.c │ │ │ ├── iot_bsp_nv_data_linux.c │ │ │ ├── iot_bsp_random_linux.c │ │ │ ├── iot_bsp_system_linux.c │ │ │ ├── iot_bsp_wifi_linux.c │ │ │ ├── wifi_supplicant.c │ │ │ └── wifi_supplicant.h │ ├── crypto │ │ ├── CMakeLists.txt │ │ └── reference │ │ │ ├── libsodium_helper.c │ │ │ ├── libsodium_helper.h │ │ │ ├── mbedtls_helper.c │ │ │ ├── mbedtls_helper.h │ │ │ └── port_crypto_reference.c │ ├── net │ │ └── mbedtls │ │ │ ├── CMakeLists.txt │ │ │ └── port_net_mbedtls.c │ ├── os │ │ ├── freertos │ │ │ ├── CMakeLists.txt │ │ │ └── iot_os_util_freertos.c │ │ └── posix │ │ │ ├── CMakeLists.txt │ │ │ └── iot_os_util_posix.c │ └── security │ │ └── iot_security_be_hardware_se.h └── security │ ├── CMakeLists.txt │ ├── backend │ ├── CMakeLists.txt │ ├── hardware │ │ ├── CMakeLists.txt │ │ ├── iot_security_be_hardware.c │ │ └── virtual │ │ │ ├── CMakeLists.txt │ │ │ └── iot_security_be_virtual.c │ └── software │ │ ├── CMakeLists.txt │ │ ├── iot_security_be_bsp.c │ │ └── iot_security_be_software.c │ ├── iot_security_common.c │ ├── iot_security_crypto.c │ ├── iot_security_ecdh.c │ ├── iot_security_manager.c │ ├── iot_security_storage.c │ └── iot_security_util.c ├── stdkconfig ├── stdkconfig.cmake ├── test ├── CMakeLists.txt ├── TC_FUNC_iot_api.c ├── TC_FUNC_iot_capability.c ├── TC_FUNC_iot_dump_log.c ├── TC_FUNC_iot_easysetup_d2d.c ├── TC_FUNC_iot_easysetup_http.c ├── TC_FUNC_iot_easysetup_http_parser.c ├── TC_FUNC_iot_easysetup_httpd.c ├── TC_FUNC_iot_easysetup_st_mqtt.c ├── TC_FUNC_iot_main.c ├── TC_FUNC_iot_mqtt_client.c ├── TC_FUNC_iot_nv_data.c ├── TC_FUNC_iot_security_be_bsp.c ├── TC_FUNC_iot_security_common.c ├── TC_FUNC_iot_security_crypto.c ├── TC_FUNC_iot_security_ecdh.c ├── TC_FUNC_iot_security_helper.c ├── TC_FUNC_iot_security_helper_ed25519.c ├── TC_FUNC_iot_security_manager.c ├── TC_FUNC_iot_security_storage.c ├── TC_FUNC_iot_util.c ├── TC_FUNC_iot_uuid.c ├── TC_FUNC_iot_wt.c ├── TC_FUNCs.h ├── TC_MOCK_functions.h ├── TC_MOCK_iot_bsp.c ├── TC_MOCK_iot_net.c ├── TC_MOCK_iot_os.c ├── TC_UTIL_easysetup_common.c ├── TC_UTIL_easysetup_common.h ├── TEST_main.c └── framework │ └── cmocka │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── COPYING │ ├── CPackConfig.cmake │ ├── CTestConfig.cmake │ ├── ChangeLog │ ├── CompilerChecks.cmake │ ├── ConfigureChecks.cmake │ ├── DefineOptions.cmake │ ├── INSTALL.md │ ├── NEWS │ ├── README.md │ ├── cmake │ ├── Modules │ │ ├── AddCCompilerFlag.cmake │ │ ├── AddCMockaTest.cmake │ │ ├── COPYING-CMAKE-SCRIPTS │ │ ├── CheckCCompilerFlagSSP.cmake │ │ ├── DefineCMakeDefaults.cmake │ │ ├── DefineCompilerFlags.cmake │ │ ├── DefinePlatformDefaults.cmake │ │ ├── FindNSIS.cmake │ │ └── MacroEnsureOutOfSourceBuild.cmake │ ├── Toolchain-Debian-mips.cmake │ └── Toolchain-cross-m32.cmake │ ├── cmocka-build-tree-settings.cmake.in │ ├── cmocka-config.cmake.in │ ├── cmocka.pc.cmake │ ├── config.h.cmake │ ├── coverity │ ├── README │ ├── coverity_assert_model.c │ └── coverity_internal_model.c │ ├── doc │ ├── CMakeLists.txt │ ├── index.html │ ├── mainpage.dox │ └── that_style │ │ ├── LICENSE │ │ ├── README.md │ │ ├── header.html │ │ ├── img │ │ ├── doc.svg │ │ ├── folderclosed.svg │ │ ├── folderopen.svg │ │ ├── mag_glass.svg │ │ ├── nav_edge_inter.svg │ │ ├── nav_edge_left.svg │ │ ├── nav_edge_right.svg │ │ ├── splitbar_handle.svg │ │ ├── sync_off.png │ │ └── sync_on.png │ │ ├── js │ │ └── striped_bg.js │ │ └── that_style.css │ ├── example │ ├── CMakeLists.txt │ ├── allocate_module.c │ ├── allocate_module_test.c │ ├── assert_macro.c │ ├── assert_macro.h │ ├── assert_macro_test.c │ ├── assert_module.c │ ├── assert_module.h │ ├── assert_module_test.c │ ├── calculator.c │ ├── calculator_test.c │ ├── database.h │ ├── mock │ │ ├── CMakeLists.txt │ │ ├── chef_wrap │ │ │ ├── CMakeLists.txt │ │ │ ├── chef.c │ │ │ ├── chef.h │ │ │ ├── waiter_test_wrap.c │ │ │ └── waiter_test_wrap.h │ │ └── uptime │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── proc_uptime.c │ │ │ ├── proc_uptime.h │ │ │ ├── test_uptime.c │ │ │ └── uptime.c │ └── simple_test.c │ ├── include │ ├── CMakeLists.txt │ ├── cmocka.h │ ├── cmocka_pbc.h │ ├── cmocka_private.h │ └── cmockery │ │ ├── cmockery.h │ │ └── pbc.h │ ├── src │ ├── CMakeLists.txt │ ├── cmocka.c │ └── cmocka.def │ └── tests │ ├── CMakeLists.txt │ ├── cmocka_test.cmake │ ├── ctest-default.cmake │ ├── test_alloc.c │ ├── test_assert_macros.c │ ├── test_assert_macros_fail.c │ ├── test_basics.c │ ├── test_cmockery.c │ ├── test_exception_handler.c │ ├── test_fixtures.c │ ├── test_float_macros.c │ ├── test_group_fixtures.c │ ├── test_group_setup_assert.c │ ├── test_group_setup_fail.c │ ├── test_groups.c │ ├── test_ordering.c │ ├── test_ordering_fail.c │ ├── test_returns.c │ ├── test_returns_fail.c │ ├── test_setup_fail.c │ ├── test_skip.c │ ├── test_skip_filter.c │ ├── test_strmatch.c │ └── test_wildcard.c └── tools ├── keygen ├── README.md └── stdk-keygen.py ├── manual_onboarding ├── README.md ├── res │ ├── DevWS_device_profile.png │ ├── DevWS_device_serial.png │ ├── manual_onboarding_choose_device_profile.png │ ├── manual_onboarding_choose_location_room.png │ ├── manual_onboarding_enter_PAT.png │ ├── manual_onboarding_enter_label.png │ ├── manual_onboarding_enter_serial.png │ ├── manual_onboarding_register_result.png │ ├── manual_onboarding_result.png │ └── manual_onboarding_review_register_info.png └── stdk-manual-onboarding.py └── qrgen ├── README.md └── stdk-qrgen.py /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | ## Marking lists 7 | - [x] I have read the [Contributing Guidelines](https://github.com/SmartThingsCommunity/st-device-sdk-c/blob/master/CONTRIBUTING.md). 8 | - [x] I have read the [Samsung Individual CLA](https://github.com/SmartThingsCommunity/st-device-sdk-c/blob/master/doc/SAMSUNGCLA.docx) and agree with it 9 | * We (SmartThings SDK team) may ask you to sign it for larger changes. In this case, once we receive it, we'll be able to accept your pull requests according to relevant laws. 10 | 11 | - I submitted this PR against the correct branch: 12 | - [x] This pull-request is based on the latest [develop](https://github.com/SmartThingsCommunity/st-device-sdk-c/tree/develop) branch. 13 | - [x] I have ensured local tests pass about my code changes. 14 | 15 | ## License 16 | 17 | Your contribution will be licensed under the [Apache License Ver2.0](https://github.com/SmartThingsCommunity/st-device-sdk-c/blob/master/LICENSE). 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | src/deps/curl/curl/ 2 | src/deps/json/cJSON/ 3 | src/deps/libsodium/libsodium/ 4 | src/deps/lwip/lwip/ 5 | src/deps/mbedtls/mbedtls/ 6 | tools/keygen/linux/ed25519* 7 | tools/keygen/linux/output_* 8 | tools/keygen/output_* 9 | doc/doxygen/ 10 | build/ 11 | output/ 12 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/deps/libsodium/libsodium"] 2 | path = src/deps/libsodium/libsodium 3 | url = https://github.com/jedisct1/libsodium.git 4 | [submodule "src/deps/json/cJSON"] 5 | path = src/deps/json/cJSON 6 | url = https://github.com/DaveGamble/cJSON.git 7 | [submodule "src/deps/mbedtls/mbedtls"] 8 | path = src/deps/mbedtls/mbedtls 9 | url = https://github.com/ARMmbed/mbedtls.git 10 | [submodule "src/deps/curl/curl"] 11 | path = src/deps/curl/curl 12 | url = https://github.com/curl/curl.git 13 | -------------------------------------------------------------------------------- /doc/Commercialization_Guide.md: -------------------------------------------------------------------------------- 1 | # Commercialization Guide for IoT device with SmartThings SDK 2 | 3 | Please contact partners@smartthings.com for commercialization inquiries. 4 | 5 | ### Check List for the commercialization 6 | 1. Products shall have unique serial number and public key.
7 | We recommend to modify and apply the opensource example tools in the link below to suit each company's production. 8 | 9 | - [STDK key generation tool](https://github.com/SmartThingsCommunity/st-device-sdk-c/blob/main/doc/STDK_Key_Generation.md) 10 | - [STDK QR generation tool](https://github.com/SmartThingsCommunity/st-device-sdk-c/blob/main/doc/STDK_QR_Generation.md) 11 | 12 | 2. Created serial number, public key and private key shall be saved in the secure module.
13 | Private key shall not be exposed to the outside and shall be injected and stored in the secure region of the device. 14 | 15 | 3. Serial Number and Device Public key shall be registered with Samsung SmartThings before sale. 16 | 17 | 4. QR should be attached to the device for the commercialization. 18 | - The QR size requested for the product should meet the specifications below. 19 | - Recommended : Above 10mm * 10mm 20 | - Minimum : 7mm * 7mm 21 | 22 | 5. Products certified by WWST shall have a WWST logo attached to the product package.
You can get the WWST(Work With Samsung SmartThings) Logo image with [the following link](https://partners.smartthings.com/brand-guidelines). 23 | 24 | 6. Products shall provide the firmware update function for security patch, feature upgrade, bug fix and etc.
25 | If the partner has their own firmware update system, they can use it.
But if not, they can implement it by referring to [the OTA guide](https://github.com/SmartThingsCommunity/st-device-sdk-c-ref/blob/main/doc/ota_demo.md) we provide. -------------------------------------------------------------------------------- /doc/SAMSUNGCLA.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/SAMSUNGCLA.docx -------------------------------------------------------------------------------- /doc/res/add-product-info.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/add-product-info.gif -------------------------------------------------------------------------------- /doc/res/add_device1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/add_device1.png -------------------------------------------------------------------------------- /doc/res/add_device2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/add_device2.png -------------------------------------------------------------------------------- /doc/res/add_device3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/add_device3.png -------------------------------------------------------------------------------- /doc/res/adding_test_device2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/adding_test_device2.png -------------------------------------------------------------------------------- /doc/res/create-device-onboarding.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/create-device-onboarding.gif -------------------------------------------------------------------------------- /doc/res/create-device-profile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/create-device-profile.gif -------------------------------------------------------------------------------- /doc/res/create-project.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/create-project.gif -------------------------------------------------------------------------------- /doc/res/deploy_to_test_switch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/deploy_to_test_switch.png -------------------------------------------------------------------------------- /doc/res/developer_mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/developer_mode.png -------------------------------------------------------------------------------- /doc/res/device_control1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/device_control1.png -------------------------------------------------------------------------------- /doc/res/downloading_onboarding_config_file_switch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/downloading_onboarding_config_file_switch.png -------------------------------------------------------------------------------- /doc/res/register-test-device.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/register-test-device.gif -------------------------------------------------------------------------------- /doc/res/sign_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/sign_in.png -------------------------------------------------------------------------------- /doc/res/st_device_sdk_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/st_device_sdk_arch.jpg -------------------------------------------------------------------------------- /doc/res/st_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/doc/res/st_logo.png -------------------------------------------------------------------------------- /example/esp32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For more information about build system see 2 | # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html 3 | # The following five lines of boilerplate have to be in your project's 4 | # CMakeLists in this exact order for cmake to work correctly 5 | cmake_minimum_required(VERSION 3.5) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | 9 | project(main) 10 | -------------------------------------------------------------------------------- /example/esp32/custom_partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | stnv, data, nvs, , 0x4000, 3 | nvs, data, nvs, , 0x4000, 4 | otadata, data, ota, , 0x2000, 5 | phy_init, data, phy, , 0x1000, 6 | nvs_key, data, nvs_keys, , 0x1000, encrypted 7 | ota_0, app, ota_0, , 0x1b0000, 8 | ota_1, app, ota_1, , 0x1b0000, 9 | -------------------------------------------------------------------------------- /example/esp32/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "main.c" 2 | "device_control.c" 3 | "iot_cli_cmd.c" 4 | "iot_uart_cli.c" 5 | EMBED_FILES "device_info.json" 6 | "onboarding_config.json" 7 | ) 8 | 9 | set(stdk_config ${CMAKE_CURRENT_LIST_DIR}/stdkconfig.cmake) 10 | add_subdirectory(../../.. iotcore) 11 | target_link_libraries(${COMPONENT_LIB} PUBLIC iotcore) 12 | -------------------------------------------------------------------------------- /example/esp32/main/device_control.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | 20 | //#define CONFIG_TARGET_WEMOS_D1_R32 21 | #ifdef CONFIG_TARGET_WEMOS_D1_R32 22 | 23 | #define GPIO_INPUT_BUTTON 18 24 | 25 | #define GPIO_OUTPUT_MAINLED 16 26 | #define GPIO_OUTPUT_MAINLED_0 26 /* use as ground */ 27 | 28 | #define GPIO_OUTPUT_NOUSE1 17 29 | #define GPIO_OUTPUT_NOUSE2 25 30 | #else // ESP32_DEVKITC_V4 31 | 32 | #define GPIO_INPUT_BUTTON 0 33 | 34 | #define GPIO_OUTPUT_MAINLED 12 35 | #define GPIO_OUTPUT_MAINLED_0 26 /* use as ground */ 36 | 37 | #define GPIO_OUTPUT_NOUSE1 14 38 | #define GPIO_OUTPUT_NOUSE2 27 39 | 40 | #endif 41 | 42 | enum switch_onoff_state { 43 | SWITCH_OFF = 0, 44 | SWITCH_ON = 1, 45 | }; 46 | 47 | enum main_led_gpio_state { 48 | MAINLED_GPIO_ON = 1, 49 | MAINLED_GPIO_OFF = 0, 50 | }; 51 | 52 | enum button_gpio_state { 53 | BUTTON_GPIO_RELEASED = 1, 54 | BUTTON_GPIO_PRESSED = 0, 55 | }; 56 | 57 | #define BUTTON_DEBOUNCE_TIME_MS 20 58 | #define BUTTON_LONG_THRESHOLD_MS 5000 59 | #define BUTTON_DELAY_MS 300 60 | 61 | enum button_event_type { 62 | BUTTON_LONG_PRESS = 0, 63 | BUTTON_SHORT_PRESS = 1, 64 | }; 65 | 66 | void change_switch_state(int switch_state); 67 | int get_button_event(int* button_event_type, int* button_event_count); 68 | void iot_gpio_init(void); 69 | -------------------------------------------------------------------------------- /example/esp32/main/device_info.json: -------------------------------------------------------------------------------- 1 | { 2 | "deviceInfo": { 3 | "firmwareVersion": "firmwareVersion_here", 4 | "privateKey": "privateKey_here", 5 | "publicKey": "publicKey_here", 6 | "serialNumber": "serialNumber_here" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /example/esp32/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | espressif/libsodium: "^1.0.20" 4 | ## Required IDF version 5 | idf: 6 | version: ">=4.1.0" 7 | # # Put list of dependencies here 8 | # # For components maintained by Espressif: 9 | # component: "~1.0.0" 10 | # # For 3rd party components: 11 | # username/component: ">=1.0.0,<2.0.0" 12 | # username2/component2: 13 | # version: "~1.0.0" 14 | # # For transient dependencies `public` flag can be set. 15 | # # `public` flag doesn't have an effect dependencies of the `main` component. 16 | # # All dependencies of `main` are public by default. 17 | # public: true 18 | -------------------------------------------------------------------------------- /example/esp32/main/iot_cli_cmd.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | void register_iot_cli_cmd(void); 20 | -------------------------------------------------------------------------------- /example/esp32/main/iot_uart_cli.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_ESP_UART_CLI_H_ 20 | #define _IOT_ESP_UART_CLI_H_ 21 | 22 | #define ARRAY_SIZE(x) (int)(sizeof(x)/sizeof(x[0])) 23 | #define CLI_TASK_PRIORITY (5) 24 | #define CLI_TASK_SIZE (8192) 25 | #define MAX_UART_LINE_SIZE (1024) 26 | typedef void (* command_function_t)(char *string); 27 | 28 | typedef struct cli_command { 29 | char *command; 30 | char *help_string; 31 | command_function_t command_fn; 32 | } cli_cmd_t; 33 | 34 | typedef struct cli_command_list { 35 | cli_cmd_t* cmd; 36 | struct cli_command_list* next; 37 | } cli_cmd_list_t; 38 | 39 | void uart_cli_main(); 40 | void cli_register_command(cli_cmd_t* cmd); 41 | 42 | #endif /* _IOT_ESP_UART_CLI_H_ */ 43 | -------------------------------------------------------------------------------- /example/esp32/main/onboarding_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "onboardingConfig": { 3 | "deviceOnboardingId": "NAME", 4 | "mnId": "MNID", 5 | "setupId": "999", 6 | "vid": "VID", 7 | "deviceTypeId": "TYPE", 8 | "ownershipValidationTypes": [ 9 | "JUSTWORKS", 10 | "BUTTON", 11 | "PIN", 12 | "QR" 13 | ], 14 | "identityType": "ED25519", 15 | "deviceIntegrationProfileKey": { 16 | "id": "DIP_UUID", 17 | "majorVersion": 0, 18 | "minorVersion": 1 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /example/esp32/main/stdkconfig.cmake: -------------------------------------------------------------------------------- 1 | SET(STDK_EXTRA_CFLAGS 2 | CONFIG_STDK_IOT_CORE 3 | CONFIG_STDK_IOT_CORE_EASYSETUP_BLE 4 | CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_ADVERTISER 5 | # CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID is not set 6 | # CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP is not set 7 | # CONFIG_STDK_IOT_CORE_EASYSETUP_BLE is not set 8 | # CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API is not set 9 | # CONFIG_STDK_IOT_CORE_EASYSETUP_X509 is not set 10 | # CONFIG_STDK_IOT_CORE_EASYSETUP_LOG_SUPPORT_NO_USE_LOGFILE is not set 11 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_ERROR 12 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_WARN 13 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_INFO 14 | # CONFIG_STDK_IOT_CORE_LOG_LEVEL_DEBUG is not set 15 | # CONFIG_STDK_IOT_CORE_SUPPORT_STNV_PARTITION is not set 16 | CONFIG_STDK_IOT_CORE_LOG_FILE 17 | CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_ONLY 18 | # CONFIG_STDK_IOT_CORE_LOG_FILE_FLASH_WITH_RAM is not set 19 | CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_BUF_SIZE=8192 20 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP8266 is not set 21 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32 22 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32S2 is not set 23 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32C3 is not set 24 | CONFIG_STDK_IOT_CORE_OS_SUPPORT_FREERTOS 25 | # CONFIG_STDK_IOT_CORE_OS_SUPPORT_TIZENRT is not set 26 | # CONFIG_STDK_IOT_CORE_OS_SUPPORT_POSIX is not set 27 | # CONFIG_STDK_DEBUG_MEMORY_CHECK is not set 28 | 29 | CONFIG_STDK_IOT_CORE_USE_MBEDTLS 30 | # CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_RSA is not set 31 | # CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_ECDSA is not set 32 | CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_ED25519 33 | CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE 34 | # CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE is not set 35 | # CONFIG_STDK_IOT_CORE_FS_SW_ENCRYPTION is not set 36 | CONFIG_STDK_IOT_CORE_FS_HW_ENCRYPTION 37 | 38 | CONFIG_STDK_IOT_CORE_NET_MBEDTLS 39 | # CONFIG_STDK_IOT_CORE_NET_OPENSSL is not set 40 | ) 41 | -------------------------------------------------------------------------------- /example/posix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(example) 3 | 4 | add_executable(example example.c) 5 | 6 | set(stdk_config ${CMAKE_CURRENT_LIST_DIR}/stdkconfig.cmake) 7 | add_subdirectory(../.. iotcore) 8 | target_link_libraries(example PUBLIC iotcore) 9 | -------------------------------------------------------------------------------- /example/posix/stdkconfig.cmake: -------------------------------------------------------------------------------- 1 | SET(STDK_EXTRA_CFLAGS 2 | CONFIG_STDK_IOT_CORE 3 | CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID 4 | CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP 5 | # CONFIG_STDK_IOT_CORE_EASYSETUP_BLE is not set 6 | CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API 7 | # CONFIG_STDK_IOT_CORE_EASYSETUP_X509 is not set 8 | # CONFIG_STDK_IOT_CORE_EASYSETUP_LOG_SUPPORT_NO_USE_LOGFILE is not set 9 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_ERROR 10 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_WARN 11 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_INFO 12 | # CONFIG_STDK_IOT_CORE_LOG_LEVEL_DEBUG is not set 13 | # CONFIG_STDK_IOT_CORE_SUPPORT_STNV_PARTITION is not set 14 | CONFIG_STDK_IOT_CORE_LOG_FILE 15 | CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_ONLY 16 | # CONFIG_STDK_IOT_CORE_LOG_FILE_FLASH_WITH_RAM is not set 17 | CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_BUF_SIZE=8192 18 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_LINUX 19 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP8266 is not set 20 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32 21 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32S2 is not set 22 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32C3 is not set 23 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_POSIX 24 | # CONFIG_STDK_IOT_CORE_OS_SUPPORT_FREERTOS is not set 25 | # CONFIG_STDK_IOT_CORE_OS_SUPPORT_TIZENRT is not set 26 | CONFIG_STDK_IOT_CORE_OS_SUPPORT_POSIX 27 | # CONFIG_STDK_DEBUG_MEMORY_CHECK is not set 28 | 29 | CONFIG_STDK_IOT_CORE_USE_MBEDTLS 30 | # CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_RSA is not set 31 | # CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_ECDSA is not set 32 | CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_ED25519 33 | CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE 34 | # CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE is not set 35 | # CONFIG_STDK_IOT_CORE_FS_SW_ENCRYPTION is not set 36 | 37 | CONFIG_STDK_IOT_CORE_NET_MBEDTLS 38 | # CONFIG_STDK_IOT_CORE_NET_OPENSSL is not set 39 | ) 40 | -------------------------------------------------------------------------------- /example/raspberry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(example) 3 | 4 | add_executable(example example.c) 5 | 6 | add_custom_target( 7 | convertJson 8 | COMMENT "Converting jsons to objects" 9 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 10 | COMMAND sh -c \"ld -r -b binary -o onboarding_config.o onboarding_config.json\" 11 | COMMAND sh -c \"ld -r -b binary -o device_info.o device_info.json\" 12 | ) 13 | 14 | add_dependencies(example convertJson) 15 | 16 | set(stdk_config ${CMAKE_CURRENT_LIST_DIR}/stdkconfig.cmake) 17 | add_subdirectory(../.. iotcore) 18 | target_link_libraries(example PUBLIC iotcore ${CMAKE_CURRENT_SOURCE_DIR}/onboarding_config.o ${CMAKE_CURRENT_SOURCE_DIR}/device_info.o) 19 | -------------------------------------------------------------------------------- /example/raspberry/README.md: -------------------------------------------------------------------------------- 1 | # _Raspberry Pi switch example_ 2 | 3 | ## Build environment 4 | 5 | 1. Raspberry Pi 4 Model B 6 | 7 | 2. Raspberry Pi OS(32-bit) Released : 2023-02-21 8 | 9 | 3. apt-get install git cmake libglib2.0-dev 10 | 11 | 4. Stop Network Manager service. (systemctl stop NetworkManager) 12 | (Because we manipulate wlan0 with wpa_supplicant, need to stop other network interference) 13 | 14 | 5. Run `git submodule update --init --recursive` on the SDK to download all modules. 15 | 16 | ```sh 17 | $ cd st-device-sdk-c/ 18 | $ git submodule update --init --recursive 19 | ``` 20 | 21 | ## How to build example 22 | 23 | 1. Move to example/raspberry directory, run cmake and build example. 24 | 25 | ```sh 26 | $ cd st-device-sdk-c/example/raspberry 27 | $ cmake -B build 28 | $ cd build 29 | $ make 30 | ``` 31 | 32 | 2. To test your registered devices on DevWS, replace onboarding_config.json and device.json with yours before build. (Refer [Getting Started](../..//doc/getting_started.md)) 33 | 34 | 3. Excute example with root right and test (sudo ./example) 35 | 36 | ```sh 37 | $ sudo ./example 38 | ``` 39 | 40 | Please refer [Getting Started](../../doc/getting_started.md) guide for testing example with ST app. 41 | -------------------------------------------------------------------------------- /example/raspberry/device_info.json: -------------------------------------------------------------------------------- 1 | { 2 | "deviceInfo": { 3 | "firmwareVersion": "firmwareVersion_here", 4 | "privateKey": "privateKey_here", 5 | "publicKey": "publicKey_here", 6 | "serialNumber": "serialNumber_here" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /example/raspberry/onboarding_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "onboardingConfig": { 3 | "deviceOnboardingId": "NAME", 4 | "mnId": "MNID", 5 | "setupId": "999", 6 | "vid": "VID", 7 | "deviceTypeId": "TYPE", 8 | "ownershipValidationTypes": [ 9 | "JUSTWORKS", 10 | "BUTTON", 11 | "PIN", 12 | "QR" 13 | ], 14 | "identityType": "ED25519_or_CERTIFICATE" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/raspberry/stdkconfig.cmake: -------------------------------------------------------------------------------- 1 | SET(STDK_EXTRA_CFLAGS 2 | CONFIG_STDK_IOT_CORE 3 | CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID 4 | CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP 5 | # CONFIG_STDK_IOT_CORE_EASYSETUP_BLE is not set 6 | CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API 7 | # CONFIG_STDK_IOT_CORE_EASYSETUP_X509 is not set 8 | # CONFIG_STDK_IOT_CORE_EASYSETUP_LOG_SUPPORT_NO_USE_LOGFILE is not set 9 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_ERROR 10 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_WARN 11 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_INFO 12 | # CONFIG_STDK_IOT_CORE_LOG_LEVEL_DEBUG is not set 13 | # CONFIG_STDK_IOT_CORE_SUPPORT_STNV_PARTITION is not set 14 | CONFIG_STDK_IOT_CORE_LOG_FILE 15 | CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_ONLY 16 | # CONFIG_STDK_IOT_CORE_LOG_FILE_FLASH_WITH_RAM is not set 17 | CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_BUF_SIZE=8192 18 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_RASPBERRY 19 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP8266 is not set 20 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32 21 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32S2 is not set 22 | # CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32C3 is not set 23 | # CONFIG_STDK_IOT_CORE_OS_SUPPORT_FREERTOS is not set 24 | # CONFIG_STDK_IOT_CORE_OS_SUPPORT_TIZENRT is not set 25 | CONFIG_STDK_IOT_CORE_OS_SUPPORT_POSIX 26 | # CONFIG_STDK_DEBUG_MEMORY_CHECK is not set 27 | 28 | CONFIG_STDK_IOT_CORE_USE_MBEDTLS 29 | # CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_RSA is not set 30 | # CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_ECDSA is not set 31 | CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_ED25519 32 | CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE 33 | # CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE is not set 34 | # CONFIG_STDK_IOT_CORE_FS_SW_ENCRYPTION is not set 35 | CONFIG_STDK_IOT_CORE_FS_HW_ENCRYPTION 36 | 37 | CONFIG_STDK_IOT_CORE_NET_MBEDTLS 38 | # CONFIG_STDK_IOT_CORE_NET_OPENSSL is not set 39 | ) 40 | -------------------------------------------------------------------------------- /make/common.mk: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | AR = ar 3 | MV = mv 4 | 5 | .c.o: 6 | @echo " CC $@" 7 | @$(CC) -c -o $@ $< $(CFLAGS) $(LOCAL_CFLAGS) 8 | @mv -f $@ $(dir $@)$(PREFIX)$(notdir $@) 9 | @mv -f $(dir $@)*.o $(BUILD_DIR) 10 | 11 | %.a: 12 | @echo " AR $@" 13 | @$(AR) rcs $@ $^ 14 | -------------------------------------------------------------------------------- /src/component.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Component Cmake 3 | # 4 | message("Enter component.cmake") 5 | 6 | if(CONFIG_STDK_IOT_CORE) 7 | set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" include include/bsp include/os include/mqtt) 8 | set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" include/external) 9 | 10 | if(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32 OR 11 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32S2 OR 12 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32C3) 13 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/bsp/esp32) 14 | set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" include/bsp/esp32) 15 | elseif(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_RASPBERRY) 16 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/bsp/raspberry) 17 | set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" include/bsp/raspberry) 18 | else() 19 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/bsp/posix) 20 | set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" include/bsp/posix) 21 | endif() 22 | 23 | set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" port/net) 24 | if(CONFIG_STDK_IOT_CORE_USE_MBEDTLS) 25 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/net/mbedtls) 26 | endif() 27 | 28 | if(CONFIG_STDK_IOT_CORE_OS_SUPPORT_FREERTOS) 29 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/os/freertos) 30 | elseif(CONFIG_STDK_IOT_CORE_OS_SUPPORT_POSIX) 31 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/os/posix) 32 | endif() 33 | 34 | if (CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE_ESE) 35 | set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" port/security) 36 | elseif (CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE) 37 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/crypto) 38 | endif() 39 | 40 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" security) 41 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" easysetup) 42 | set(STDK_SRC_PATH "${STDK_SRC_PATH}" mqtt) 43 | 44 | else() 45 | message("Fail to find SDK config") 46 | # Disable SmartThing Device SDK support 47 | set(STDK_INCLUDE_PATH "") 48 | set(STDK_SRC_PATH "") 49 | endif() 50 | -------------------------------------------------------------------------------- /src/deps/cbor/tinycbor/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Intel Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/deps/cbor/tinycbor/README: -------------------------------------------------------------------------------- 1 | Concise Binary Object Representation (CBOR) Library 2 | --------------------------------------------------- 3 | 4 | To build TinyCBOR: 5 | 6 | make 7 | 8 | If you want to change the compiler or pass extra compiler flags: 9 | 10 | make CC=clang CFLAGS="-m32 -Oz" LDFLAGS="-m32" 11 | 12 | Documentation: https://intel.github.io/tinycbor/current/ 13 | 14 | -------------------------------------------------------------------------------- /src/deps/cbor/tinycbor/VERSION: -------------------------------------------------------------------------------- 1 | 0.5.4 2 | -------------------------------------------------------------------------------- /src/deps/cbor/tinycbor/src/tinycbor-version.h: -------------------------------------------------------------------------------- 1 | #define TINYCBOR_VERSION_MAJOR 0 2 | #define TINYCBOR_VERSION_MINOR 5 3 | #define TINYCBOR_VERSION_PATCH 4 4 | -------------------------------------------------------------------------------- /src/deps/curl/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/make/common.mk 2 | 3 | SRCDIR = curl 4 | PREFIX := curl_ 5 | 6 | LOCAL_CFLAGS := -I$(SRCDIR)/lib -I$(SRCDIR)/include -Iport/include 7 | 8 | CFLAGS := -DHAVE_CONFIG_H 9 | CFLAGS += -DBUILDING_LIBCURL 10 | 11 | SRCS = $(shell find $(SRCDIR)/lib -name '*.c') 12 | SRCS += $(shell find $(SRCDIR)/lib/vauth -name '*.c') 13 | SRCS += $(shell find $(SRCDIR)/lib/vtls -name '*.c') 14 | OBJS = $(SRCS:.c=.o) 15 | 16 | all: $(OBJS) 17 | 18 | clean: 19 | @rm -f $(OBJS) 20 | 21 | .PHONY: clean 22 | -------------------------------------------------------------------------------- /src/deps/json/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/make/common.mk 2 | 3 | SRCDIR = cJSON 4 | PREFIX := cJSON_ 5 | 6 | LOCAL_CFLAGS := -I$(SRCDIR) 7 | 8 | SRCS = $(SRCDIR)/cJSON.c 9 | OBJS = $(SRCS:.c=.o) 10 | 11 | all: $(OBJS) 12 | 13 | clean: 14 | @rm -f $(OBJS) 15 | 16 | .PHONY: clean 17 | -------------------------------------------------------------------------------- /src/deps/libsodium/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | file(GLOB_RECURSE libsodium_SRCS libsodium/src/*.c) 3 | SET(LIBSODIUM_CFLAGS 4 | CONFIGURED 5 | NATIVE_LITTLE_ENDIAN 6 | HAVE_WEAK_SYMBOLS 7 | __STDC_LIMIT_MACROS 8 | __STDC_CONSTANT_MACROS 9 | ) 10 | foreach(libsodium_cflags ${LIBSODIUM_CFLAGS}) 11 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${libsodium_cflags}") 12 | endforeach() 13 | 14 | add_library(sodium 15 | ${libsodium_SRCS} 16 | ) 17 | target_include_directories(sodium 18 | PRIVATE 19 | libsodium/src/libsodium/include 20 | libsodium/src/libsodium/include/sodium 21 | port/include/sodium 22 | port/include 23 | ) -------------------------------------------------------------------------------- /src/deps/libsodium/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/make/common.mk 2 | 3 | SRCDIR = libsodium/src/libsodium 4 | PREFIX := libsodium_ 5 | 6 | LOCAL_CFLAGS := -I$(SRCDIR)/include -I$(SRCDIR)/include/sodium -Iport/include/sodium 7 | 8 | CFLAGS := -DCONFIGURED 9 | CFLAGS += -DNATIVE_LITTLE_ENDIAN 10 | CFLAGS += -DHAVE_WEAK_SYMBOLS 11 | CFLAGS += -D__STDC_LIMIT_MACROS 12 | CFLAGS += -D__STDC_CONSTANT_MACROS 13 | 14 | SRCS = $(shell find $(SRCDIR) -name '*.c') 15 | OBJS = $(SRCS:.c=.o) 16 | 17 | all: $(OBJS) 18 | 19 | clean: 20 | @rm -f $(OBJS) 21 | 22 | .PHONY: clean 23 | -------------------------------------------------------------------------------- /src/deps/libsodium/port/include/sodium/version.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef sodium_version_H 3 | #define sodium_version_H 4 | 5 | #include "export.h" 6 | 7 | /* 8 | * IMPORTANT: As we don't use autotools, these version are not automatically 9 | * updated if we change submodules. They need to be changed manually. 10 | */ 11 | 12 | #define SODIUM_VERSION_STRING "1.0.18" 13 | 14 | #define SODIUM_LIBRARY_VERSION_MAJOR 10 15 | #define SODIUM_LIBRARY_VERSION_MINOR 3 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | SODIUM_EXPORT 22 | const char *sodium_version_string(void); 23 | 24 | SODIUM_EXPORT 25 | int sodium_library_version_major(void); 26 | 27 | SODIUM_EXPORT 28 | int sodium_library_version_minor(void); 29 | 30 | SODIUM_EXPORT 31 | int sodium_library_minimal(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/deps/mbedtls/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/make/common.mk 2 | 3 | SRCDIR = mbedtls/library 4 | PREFIX := mbedtls_ 5 | 6 | LOCAL_CFLAGS := -Imbedtls/include -Iport/posix/include 7 | 8 | LOCAL_CFLAGS += -Wall -W -Wdeclaration-after-statement 9 | LOCAL_CFLAGS += -D_FILE_OFFSET_BITS=64 10 | LOCAL_CFLAGS += -DMBEDTLS_CONFIG_FILE='"mbedtls/posix_config.h"' 11 | 12 | OBJS_CRYPTO= aes.o aesni.o arc4.o \ 13 | aria.o asn1parse.o asn1write.o \ 14 | base64.o bignum.o blowfish.o \ 15 | camellia.o ccm.o chacha20.o \ 16 | chachapoly.o cipher.o cipher_wrap.o \ 17 | cmac.o ctr_drbg.o des.o \ 18 | dhm.o ecdh.o ecdsa.o \ 19 | ecjpake.o ecp.o \ 20 | ecp_curves.o entropy.o entropy_poll.o \ 21 | error.o gcm.o havege.o \ 22 | hkdf.o \ 23 | hmac_drbg.o md.o md2.o \ 24 | md4.o md5.o md_wrap.o \ 25 | memory_buffer_alloc.o nist_kw.o \ 26 | oid.o padlock.o pem.o \ 27 | pk.o pk_wrap.o pkcs12.o \ 28 | pkcs5.o pkparse.o pkwrite.o \ 29 | platform.o platform_util.o poly1305.o \ 30 | ripemd160.o rsa_internal.o rsa.o \ 31 | sha1.o sha256.o sha512.o \ 32 | threading.o timing.o version.o \ 33 | version_features.o xtea.o 34 | 35 | OBJS_X509= certs.o pkcs11.o x509.o \ 36 | x509_create.o x509_crl.o x509_crt.o \ 37 | x509_csr.o x509write_crt.o x509write_csr.o 38 | 39 | OBJS_TLS= debug.o net_sockets.o \ 40 | ssl_cache.o ssl_ciphersuites.o \ 41 | ssl_cli.o ssl_cookie.o \ 42 | ssl_srv.o ssl_ticket.o \ 43 | ssl_tls.o 44 | 45 | OBJS = $(addprefix $(SRCDIR)/,$(OBJS_CRYPTO) $(OBJS_X509) $(OBJS_TLS)) 46 | 47 | all: $(OBJS) 48 | 49 | clean: 50 | @rm -f $(OBJS) 51 | 52 | .PHONY: clean 53 | -------------------------------------------------------------------------------- /src/easysetup/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP) 2 | set(EASYSETUP_D2D_SOURCES 3 | "${EASYSETUP_D2D_SOURCES}" 4 | http/iot_easysetup_http_parser.c 5 | http/iot_easysetup_http.c 6 | http/easysetup_http.h 7 | ) 8 | elseif(CONFIG_STDK_IOT_CORE_EASYSETUP_BLE) 9 | SET(EASYSETUP_D2D_SOURCES 10 | "${EASYSETUP_D2D_SOURCES}" 11 | ble/iot_easysetup_ble.c 12 | ble/iot_easysetup_ble_task.c 13 | ble/iot_easysetup_ble_msg.c 14 | ble/iot_easysetup_ble_ecdh.c 15 | ble/iot_easysetup_d2d_ble.c 16 | ble/easysetup_ble.h 17 | ) 18 | endif() 19 | 20 | if(CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP) 21 | if(CONFIG_STDK_IOT_CORE_EASYSETUP_X509) 22 | set(EASYSETUP_D2D_SOURCES 23 | "${EASYSETUP_D2D_SOURCES}" 24 | http/tls/iot_easysetup_d2d_tls.c 25 | http/tls/iot_easysetup_http_tls.c 26 | ) 27 | else() 28 | set(EASYSETUP_D2D_SOURCES 29 | "${EASYSETUP_D2D_SOURCES}" 30 | http/tcp/iot_easysetup_d2d_tcp.c 31 | http/tcp/iot_easysetup_httpd.c 32 | ) 33 | endif() 34 | endif() 35 | 36 | if(CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID) 37 | set(EASYSETUP_DISCOVERY_SOURCES 38 | "${EASYSETUP_DISCOVERY_SOURCES}" 39 | discovery/ssid/iot_easysetup_discovery_ssid.c 40 | ) 41 | elseif(CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_ADVERTISER) 42 | set(EASYSETUP_DISCOVERY_SOURCES 43 | "${EASYSETUP_DISCOVERY_SOURCES}" 44 | discovery/advertiser/iot_easysetup_discovery_advertiser.c 45 | ) 46 | endif() 47 | 48 | target_sources(iotcore 49 | PRIVATE 50 | iot_easysetup_st_mqtt.c 51 | ${EASYSETUP_D2D_SOURCES} 52 | ${EASYSETUP_DISCOVERY_SOURCES} 53 | ) 54 | -------------------------------------------------------------------------------- /src/easysetup/http/easysetup_http.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _EASYSETUP_HTTP_H_ 20 | #define _EASYSETUP_HTTP_H_ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | #include "iot_main.h" 26 | #include "iot_error.h" 27 | 28 | enum cgi_type { 29 | D2D_GET= 0, 30 | D2D_POST, 31 | D2D_ERROR, 32 | }; 33 | 34 | void http_msg_handler(int cmd, char **buffer, enum cgi_type type, char* data_buf); 35 | 36 | iot_error_t es_msg_parser(char *rx_buffer, size_t rx_buffer_len, char **payload, int *cmd, int *type, size_t *content_len); 37 | 38 | void es_http_init(void); 39 | 40 | void es_http_deinit(void); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* _EASYSETUP_HTTP_H_ */ 47 | -------------------------------------------------------------------------------- /src/include/bsp/bl602/iot_bsp_custom.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_BSP_CUSTOM_H_ 20 | #define _IOT_BSP_CUSTOM_H_ 21 | 22 | #include "sdkconfig.h" 23 | 24 | #endif /* _IOT_BSP_CUSTOM_H_ */ 25 | -------------------------------------------------------------------------------- /src/include/bsp/esp32/iot_bsp_custom.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_BSP_CUSTOM_H_ 20 | #define _IOT_BSP_CUSTOM_H_ 21 | 22 | #include "sdkconfig.h" 23 | 24 | #endif /* _IOT_BSP_CUSTOM_H_ */ -------------------------------------------------------------------------------- /src/include/bsp/iot_bsp_nv_data.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_BSP_NV_DATA_H_ 20 | #define _IOT_BSP_NV_DATA_H_ 21 | 22 | #include "iot_nv_data.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * @brief Get a nv data path. 30 | * 31 | * @details This function will return the nv data path. 32 | * The detail of data path depends on the file-system type. 33 | * ex : espressif nvs-system - nvs key ("nvItemKey") 34 | * linux file-system - file path ("/stnv/nvItemKey") 35 | * 36 | * @param[in] nv_type The type of nv data. declaration is in "iot_nv_data.h" 37 | * @return nv data path. 38 | * 39 | * @see iot_nv_data.h 40 | */ 41 | const char* iot_bsp_nv_get_data_path(iot_nvd_t nv_type); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* _IOT_BSP_NV_DATA_H_ */ 48 | -------------------------------------------------------------------------------- /src/include/bsp/iot_bsp_random.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_BSP_RANDOM_H_ 20 | #define _IOT_BSP_RANDOM_H_ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** 27 | * @brief Generate random number 28 | * 29 | * @details This function generates and returns a random number. 30 | * 31 | * @return unsigned int random number 32 | */ 33 | unsigned int iot_bsp_random(); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* _IOT_BSP_RANDOM_H_ */ 40 | -------------------------------------------------------------------------------- /src/include/bsp/posix/iot_bsp_custom.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_BSP_CUSTOM_H_ 20 | #define _IOT_BSP_CUSTOM_H_ 21 | 22 | #endif /* _IOT_BSP_CUSTOM_H_ */ -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | #ifndef _IOT_CAPS_HELPER_ 19 | #define _IOT_CAPS_HELPER_ 20 | 21 | #define _ATTR_BIT_VALUE_MIN 0 22 | #define _ATTR_BIT_VALUE_MAX 1 23 | #define _ATTR_BIT_VALUE_REQUIRED 2 24 | #define _ATTR_BIT_UNIT_REQUIRED 3 25 | #define _ATTR_BIT_MAX_LENGTH 4 26 | #define _ATTR_BIT_VALUE_ARRAY 5 27 | 28 | #define ATTR_SET_VALUE_MIN (1 << _ATTR_BIT_VALUE_MIN) 29 | #define ATTR_SET_VALUE_MAX (1 << _ATTR_BIT_VALUE_MAX) 30 | #define ATTR_SET_VALUE_REQUIRED (1 << _ATTR_BIT_VALUE_REQUIRED) 31 | #define ATTR_SET_UNIT_REQUIRED (1 << _ATTR_BIT_UNIT_REQUIRED) 32 | #define ATTR_SET_MAX_LENGTH (1 << _ATTR_BIT_MAX_LENGTH) 33 | #define ATTR_SET_VALUE_ARRAY (1 << _ATTR_BIT_VALUE_ARRAY) 34 | 35 | #define VALUE_TYPE_INTEGER 1 36 | #define VALUE_TYPE_NUMBER 2 37 | #define VALUE_TYPE_STRING 3 38 | #define VALUE_TYPE_OBJECT 4 39 | #define VALUE_TYPE_BOOLEAN 5 40 | 41 | #endif /* _IOT_CAPS_HELPER_ */ 42 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_airQualitySensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_AIR_QUALITY_SENSOR_ 20 | #define _IOT_CAPS_HELPER_AIR_QUALITY_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_AIRQUALITYSENSOR_AIRQUALITY_UNIT_CAQI, 30 | CAP_ENUM_AIRQUALITYSENSOR_AIRQUALITY_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_airQualitySensor { 34 | const char *id; 35 | const struct airQualitySensor_attr_airQuality { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_AIRQUALITYSENSOR_AIRQUALITY_UNIT_MAX]; 40 | const char *unit_CAQI; 41 | const int min; 42 | const int max; 43 | } attr_airQuality; 44 | } caps_helper_airQualitySensor = { 45 | .id = "airQualitySensor", 46 | .attr_airQuality = { 47 | .name = "airQuality", 48 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_MAX | ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_INTEGER, 50 | .units = {"CAQI"}, 51 | .unit_CAQI = "CAQI", 52 | .min = 0, 53 | .max = 100, 54 | }, 55 | }; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _IOT_CAPS_HERLPER_AIR_QUALITY_SENSOR_ */ 62 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_battery.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_BATTERY_ 20 | #define _IOT_CAPS_HELPER_BATTERY_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_BATTERY_BATTERY_UNIT_PERCENT, 30 | CAP_ENUM_BATTERY_BATTERY_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_battery { 34 | const char *id; 35 | const struct battery_attr_battery { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_BATTERY_BATTERY_UNIT_MAX]; 40 | const char *unit_percent; 41 | const int min; 42 | const int max; 43 | } attr_battery; 44 | } caps_helper_battery = { 45 | .id = "battery", 46 | .attr_battery = { 47 | .name = "battery", 48 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_MAX | ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_INTEGER, 50 | .units = {"%"}, 51 | .unit_percent = "%", 52 | .min = 0, 53 | .max = 100, 54 | }, 55 | }; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _IOT_CAPS_HERLPER_BATTERY_ */ 62 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_contactSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_CONTACT_SENSOR_ 20 | #define _IOT_CAPS_HELPER_CONTACT_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_CONTACTSENSOR_CONTACT_VALUE_CLOSED, 30 | CAP_ENUM_CONTACTSENSOR_CONTACT_VALUE_OPEN, 31 | CAP_ENUM_CONTACTSENSOR_CONTACT_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_contactSensor { 35 | const char *id; 36 | const struct contactSensor_attr_contact { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_CONTACTSENSOR_CONTACT_VALUE_MAX]; 41 | const char *value_closed; 42 | const char *value_open; 43 | } attr_contact; 44 | } caps_helper_contactSensor = { 45 | .id = "contactSensor", 46 | .attr_contact = { 47 | .name = "contact", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"closed", "open"}, 51 | .value_closed = "closed", 52 | .value_open = "open", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_CONTACT_SENSOR_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_execute.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_EXECUTE_ 20 | #define _IOT_CAPS_HELPER_EXECUTE_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_execute { 29 | const char *id; 30 | const struct execute_attr_data { 31 | const char *name; 32 | const unsigned char property; 33 | const unsigned char valueType; 34 | } attr_data; 35 | const struct execute_cmd_execute { const char* name; } cmd_execute; 36 | } caps_helper_execute = { 37 | .id = "execute", 38 | .attr_data = { 39 | .name = "data", 40 | .property = ATTR_SET_VALUE_REQUIRED, 41 | .valueType = VALUE_TYPE_OBJECT, 42 | }, 43 | .cmd_execute = { .name = "execute" }, // arguments: command(string) args(object) 44 | }; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* _IOT_CAPS_HERLPER_EXECUTE_ */ 51 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_fanSpeed.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_FAN_SPEED_ 20 | #define _IOT_CAPS_HELPER_FAN_SPEED_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_fanSpeed { 29 | const char *id; 30 | const struct fanSpeed_attr_fanSpeed { 31 | const char *name; 32 | const unsigned char property; 33 | const unsigned char valueType; 34 | const int min; 35 | } attr_fanSpeed; 36 | const struct fanSpeed_cmd_setFanSpeed { const char* name; } cmd_setFanSpeed; 37 | } caps_helper_fanSpeed = { 38 | .id = "fanSpeed", 39 | .attr_fanSpeed = { 40 | .name = "fanSpeed", 41 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_REQUIRED, 42 | .valueType = VALUE_TYPE_INTEGER, 43 | .min = 0, 44 | }, 45 | .cmd_setFanSpeed = { .name = "setFanSpeed" }, // arguments: speed(integer) 46 | }; 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* _IOT_CAPS_HERLPER_FAN_SPEED_ */ 53 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_filterStatus.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_FILTER_STATUS_ 20 | #define _IOT_CAPS_HELPER_FILTER_STATUS_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_FILTERSTATUS_FILTERSTATUS_VALUE_NORMAL, 30 | CAP_ENUM_FILTERSTATUS_FILTERSTATUS_VALUE_REPLACE, 31 | CAP_ENUM_FILTERSTATUS_FILTERSTATUS_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_filterStatus { 35 | const char *id; 36 | const struct filterStatus_attr_filterStatus { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_FILTERSTATUS_FILTERSTATUS_VALUE_MAX]; 41 | const char *value_normal; 42 | const char *value_replace; 43 | } attr_filterStatus; 44 | } caps_helper_filterStatus = { 45 | .id = "filterStatus", 46 | .attr_filterStatus = { 47 | .name = "filterStatus", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"normal", "replace"}, 51 | .value_normal = "normal", 52 | .value_replace = "replace", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_FILTER_STATUS_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_fineDustSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_FINE_DUST_SENSOR_ 20 | #define _IOT_CAPS_HELPER_FINE_DUST_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_FINEDUSTSENSOR_FINEDUSTLEVEL_UNIT_UG_PER_M3, 30 | CAP_ENUM_FINEDUSTSENSOR_FINEDUSTLEVEL_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_fineDustSensor { 34 | const char *id; 35 | const struct fineDustSensor_attr_fineDustLevel { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_FINEDUSTSENSOR_FINEDUSTLEVEL_UNIT_MAX]; 40 | const char *unit_ug_per_m3; 41 | const int min; 42 | } attr_fineDustLevel; 43 | } caps_helper_fineDustSensor = { 44 | .id = "fineDustSensor", 45 | .attr_fineDustLevel = { 46 | .name = "fineDustLevel", 47 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_REQUIRED, 48 | .valueType = VALUE_TYPE_INTEGER, 49 | .units = {"μg/m^3"}, 50 | .unit_ug_per_m3 = "μg/m^3", 51 | .min = 0, 52 | }, 53 | }; 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* _IOT_CAPS_HERLPER_FINE_DUST_SENSOR_ */ 60 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_mode.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2021 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_MODE_ 20 | #define _IOT_CAPS_HELPER_MODE_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_mode { 29 | const char *id; 30 | const struct mode_attr_supportedModes { 31 | const char *name; 32 | const unsigned char property; 33 | const unsigned char valueType; 34 | } attr_supportedModes; 35 | const struct mode_attr_mode { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | } attr_mode; 40 | const struct mode_cmd_setMode { const char* name; } cmd_setMode; 41 | } caps_helper_mode = { 42 | .id = "mode", 43 | .attr_supportedModes = { 44 | .name = "supportedModes", 45 | .property = ATTR_SET_VALUE_ARRAY, 46 | .valueType = VALUE_TYPE_STRING, 47 | }, 48 | .attr_mode = { 49 | .name = "mode", 50 | .property = ATTR_SET_VALUE_REQUIRED, 51 | .valueType = VALUE_TYPE_STRING, 52 | }, 53 | .cmd_setMode = { .name = "setMode" }, // arguments: mode(string) 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_MODE_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_momentary.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_MOMENTARY_ 20 | #define _IOT_CAPS_HELPER_MOMENTARY_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_momentary { 29 | const char *id; 30 | const struct momentary_cmd_push { const char* name; } cmd_push; 31 | } caps_helper_momentary = { 32 | .id = "momentary", 33 | .cmd_push = { .name = "push" }, 34 | }; 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* _IOT_CAPS_HERLPER_MOMENTARY_ */ 41 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_motionSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_MOTION_SENSOR_ 20 | #define _IOT_CAPS_HELPER_MOTION_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_MOTIONSENSOR_MOTION_VALUE_ACTIVE, 30 | CAP_ENUM_MOTIONSENSOR_MOTION_VALUE_INACTIVE, 31 | CAP_ENUM_MOTIONSENSOR_MOTION_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_motionSensor { 35 | const char *id; 36 | const struct motionSensor_attr_motion { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_MOTIONSENSOR_MOTION_VALUE_MAX]; 41 | const char *value_active; 42 | const char *value_inactive; 43 | } attr_motion; 44 | } caps_helper_motionSensor = { 45 | .id = "motionSensor", 46 | .attr_motion = { 47 | .name = "motion", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"active", "inactive"}, 51 | .value_active = "active", 52 | .value_inactive = "inactive", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_MOTION_SENSOR_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_objectDetection.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_OBJECT_DETECTION_ 20 | #define _IOT_CAPS_HELPER_OBJECT_DETECTION_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_objectDetection { 29 | const char *id; 30 | const struct objectDetection_attr_detected { 31 | const char *name; 32 | const unsigned char property; 33 | const unsigned char valueType; 34 | } attr_detected; 35 | const struct objectDetection_attr_supportedValues { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const unsigned int max_length; 40 | } attr_supportedValues; 41 | } caps_helper_objectDetection = { 42 | .id = "objectDetection", 43 | .attr_detected = { 44 | .name = "detected", 45 | .property = ATTR_SET_VALUE_REQUIRED, 46 | .valueType = VALUE_TYPE_OBJECT, 47 | }, 48 | .attr_supportedValues = { 49 | .name = "supportedValues", 50 | .property = ATTR_SET_MAX_LENGTH | ATTR_SET_VALUE_ARRAY, 51 | .valueType = VALUE_TYPE_STRING, 52 | .max_length = 255, 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_OBJECT_DETECTION_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_odorSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_ODOR_SENSOR_ 20 | #define _IOT_CAPS_HELPER_ODOR_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_odorSensor { 29 | const char *id; 30 | const struct odorSensor_attr_odorLevel { 31 | const char *name; 32 | const unsigned char property; 33 | const unsigned char valueType; 34 | const int min; 35 | } attr_odorLevel; 36 | } caps_helper_odorSensor = { 37 | .id = "odorSensor", 38 | .attr_odorLevel = { 39 | .name = "odorLevel", 40 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_REQUIRED, 41 | .valueType = VALUE_TYPE_INTEGER, 42 | .min = 0, 43 | }, 44 | }; 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* _IOT_CAPS_HERLPER_ODOR_SENSOR_ */ 51 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_ovenSetpoint.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_OVEN_SETPOINT_ 20 | #define _IOT_CAPS_HELPER_OVEN_SETPOINT_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_ovenSetpoint { 29 | const char *id; 30 | const struct ovenSetpoint_attr_ovenSetpoint { 31 | const char *name; 32 | const unsigned char property; 33 | const unsigned char valueType; 34 | const int min; 35 | } attr_ovenSetpoint; 36 | const struct ovenSetpoint_cmd_setOvenSetpoint { const char* name; } cmd_setOvenSetpoint; 37 | } caps_helper_ovenSetpoint = { 38 | .id = "ovenSetpoint", 39 | .attr_ovenSetpoint = { 40 | .name = "ovenSetpoint", 41 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_REQUIRED, 42 | .valueType = VALUE_TYPE_INTEGER, 43 | .min = 0, 44 | }, 45 | .cmd_setOvenSetpoint = { .name = "setOvenSetpoint" }, // arguments: setpoint(integer) 46 | }; 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* _IOT_CAPS_HERLPER_OVEN_SETPOINT_ */ 53 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_pHMeasurement.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2022 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_PH_MEASUREMENT_ 20 | #define _IOT_CAPS_HELPER_PH_MEASUREMENT_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_PHMEASUREMENT_PH_UNIT_PH, 30 | CAP_ENUM_PHMEASUREMENT_PH_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_pHMeasurement { 34 | const char *id; 35 | const struct pHMeasurement_attr_pH { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_PHMEASUREMENT_PH_UNIT_MAX]; 40 | const char *unit_pH; 41 | const double min; 42 | const double max; 43 | } attr_pH; 44 | } caps_helper_pHMeasurement = { 45 | .id = "pHMeasurement", 46 | .attr_pH = { 47 | .name = "pH", 48 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_MAX | ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_NUMBER, 50 | .units = {"pH"}, 51 | .unit_pH = "pH", 52 | .min = 0, 53 | .max = 14, 54 | }, 55 | }; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _IOT_CAPS_HERLPER_PH_MEASUREMENT_ */ 62 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_panicAlarm.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2022 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_PANIC_ALARM_ 20 | #define _IOT_CAPS_HELPER_PANIC_ALARM_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_PANICALARM_PANICALARM_VALUE_PANIC, 30 | CAP_ENUM_PANICALARM_PANICALARM_VALUE_CLEAR, 31 | CAP_ENUM_PANICALARM_PANICALARM_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_panicAlarm { 35 | const char *id; 36 | const struct panicAlarm_attr_panicAlarm { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_PANICALARM_PANICALARM_VALUE_MAX]; 41 | const char *value_panic; 42 | const char *value_clear; 43 | } attr_panicAlarm; 44 | } caps_helper_panicAlarm = { 45 | .id = "panicAlarm", 46 | .attr_panicAlarm = { 47 | .name = "panicAlarm", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"panic", "clear"}, 51 | .value_panic = "panic", 52 | .value_clear = "clear", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_PANIC_ALARM_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_powerMeter.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_POWER_METER_ 20 | #define _IOT_CAPS_HELPER_POWER_METER_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_POWERMETER_POWER_UNIT_W, 30 | CAP_ENUM_POWERMETER_POWER_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_powerMeter { 34 | const char *id; 35 | const struct powerMeter_attr_power { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_POWERMETER_POWER_UNIT_MAX]; 40 | const char *unit_W; 41 | const double min; 42 | } attr_power; 43 | } caps_helper_powerMeter = { 44 | .id = "powerMeter", 45 | .attr_power = { 46 | .name = "power", 47 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_REQUIRED, 48 | .valueType = VALUE_TYPE_NUMBER, 49 | .units = {"W"}, 50 | .unit_W = "W", 51 | .min = 0, 52 | }, 53 | }; 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* _IOT_CAPS_HERLPER_POWER_METER_ */ 60 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_presenceSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_PRESENCE_SENSOR_ 20 | #define _IOT_CAPS_HELPER_PRESENCE_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_PRESENCESENSOR_PRESENCE_VALUE_PRESENT, 30 | CAP_ENUM_PRESENCESENSOR_PRESENCE_VALUE_NOT_PRESENT, 31 | CAP_ENUM_PRESENCESENSOR_PRESENCE_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_presenceSensor { 35 | const char *id; 36 | const struct presenceSensor_attr_presence { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_PRESENCESENSOR_PRESENCE_VALUE_MAX]; 41 | const char *value_present; 42 | const char *value_not_present; 43 | } attr_presence; 44 | } caps_helper_presenceSensor = { 45 | .id = "presenceSensor", 46 | .attr_presence = { 47 | .name = "presence", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"present", "not present"}, 51 | .value_present = "present", 52 | .value_not_present = "not present", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_PRESENCE_SENSOR_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_refresh.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_REFRESH_ 20 | #define _IOT_CAPS_HELPER_REFRESH_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_refresh { 29 | const char *id; 30 | const struct refresh_cmd_refresh { const char* name; } cmd_refresh; 31 | } caps_helper_refresh = { 32 | .id = "refresh", 33 | .cmd_refresh = { .name = "refresh" }, 34 | }; 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* _IOT_CAPS_HERLPER_REFRESH_ */ 41 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_sleepSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_SLEEP_SENSOR_ 20 | #define _IOT_CAPS_HELPER_SLEEP_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_SLEEPSENSOR_SLEEPING_VALUE_NOT_SLEEPING, 30 | CAP_ENUM_SLEEPSENSOR_SLEEPING_VALUE_SLEEPING, 31 | CAP_ENUM_SLEEPSENSOR_SLEEPING_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_sleepSensor { 35 | const char *id; 36 | const struct sleepSensor_attr_sleeping { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_SLEEPSENSOR_SLEEPING_VALUE_MAX]; 41 | const char *value_not_sleeping; 42 | const char *value_sleeping; 43 | } attr_sleeping; 44 | } caps_helper_sleepSensor = { 45 | .id = "sleepSensor", 46 | .attr_sleeping = { 47 | .name = "sleeping", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"not sleeping", "sleeping"}, 51 | .value_not_sleeping = "not sleeping", 52 | .value_sleeping = "sleeping", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_SLEEP_SENSOR_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_soundSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_SOUND_SENSOR_ 20 | #define _IOT_CAPS_HELPER_SOUND_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_SOUNDSENSOR_SOUND_VALUE_DETECTED, 30 | CAP_ENUM_SOUNDSENSOR_SOUND_VALUE_NOT_DETECTED, 31 | CAP_ENUM_SOUNDSENSOR_SOUND_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_soundSensor { 35 | const char *id; 36 | const struct soundSensor_attr_sound { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_SOUNDSENSOR_SOUND_VALUE_MAX]; 41 | const char *value_detected; 42 | const char *value_not_detected; 43 | } attr_sound; 44 | } caps_helper_soundSensor = { 45 | .id = "soundSensor", 46 | .attr_sound = { 47 | .name = "sound", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"detected", "not detected"}, 51 | .value_detected = "detected", 52 | .value_not_detected = "not detected", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_SOUND_SENSOR_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_switch.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_SWITCH_ 20 | #define _IOT_CAPS_HELPER_SWITCH_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_SWITCH_SWITCH_VALUE_ON, 30 | CAP_ENUM_SWITCH_SWITCH_VALUE_OFF, 31 | CAP_ENUM_SWITCH_SWITCH_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_switch { 35 | const char *id; 36 | const struct switch_attr_switch { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_SWITCH_SWITCH_VALUE_MAX]; 41 | const char *value_on; 42 | const char *value_off; 43 | } attr_switch; 44 | const struct switch_cmd_on { const char* name; } cmd_on; 45 | const struct switch_cmd_off { const char* name; } cmd_off; 46 | } caps_helper_switch = { 47 | .id = "switch", 48 | .attr_switch = { 49 | .name = "switch", 50 | .property = ATTR_SET_VALUE_REQUIRED, 51 | .valueType = VALUE_TYPE_STRING, 52 | .values = {"on", "off"}, 53 | .value_on = "on", 54 | .value_off = "off", 55 | }, 56 | .cmd_on = { .name = "on" }, 57 | .cmd_off = { .name = "off" }, 58 | }; 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* _IOT_CAPS_HERLPER_SWITCH_ */ 65 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_tamperAlert.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_TAMPER_ALERT_ 20 | #define _IOT_CAPS_HELPER_TAMPER_ALERT_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_TAMPERALERT_TAMPER_VALUE_CLEAR, 30 | CAP_ENUM_TAMPERALERT_TAMPER_VALUE_DETECTED, 31 | CAP_ENUM_TAMPERALERT_TAMPER_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_tamperAlert { 35 | const char *id; 36 | const struct tamperAlert_attr_tamper { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_TAMPERALERT_TAMPER_VALUE_MAX]; 41 | const char *value_clear; 42 | const char *value_detected; 43 | } attr_tamper; 44 | } caps_helper_tamperAlert = { 45 | .id = "tamperAlert", 46 | .attr_tamper = { 47 | .name = "tamper", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"clear", "detected"}, 51 | .value_clear = "clear", 52 | .value_detected = "detected", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_TAMPER_ALERT_ */ 61 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_threeAxis.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_THREE_AXIS_ 20 | #define _IOT_CAPS_HELPER_THREE_AXIS_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_THREEAXIS_THREEAXIS_UNIT_MG, 30 | CAP_ENUM_THREEAXIS_THREEAXIS_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_threeAxis { 34 | const char *id; 35 | const struct threeAxis_attr_threeAxis { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_THREEAXIS_THREEAXIS_UNIT_MAX]; 40 | const char *unit_mG; 41 | const int min; 42 | const int max; 43 | } attr_threeAxis; 44 | } caps_helper_threeAxis = { 45 | .id = "threeAxis", 46 | .attr_threeAxis = { 47 | .name = "threeAxis", 48 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_MAX | ATTR_SET_VALUE_REQUIRED | ATTR_SET_VALUE_ARRAY, 49 | .valueType = VALUE_TYPE_INTEGER, 50 | .units = {"mG"}, 51 | .unit_mG = "mG", 52 | .min = -10000, 53 | .max = 10000, 54 | }, 55 | }; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _IOT_CAPS_HERLPER_THREE_AXIS_ */ 62 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_tone.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_TONE_ 20 | #define _IOT_CAPS_HELPER_TONE_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_tone { 29 | const char *id; 30 | const struct tone_cmd_beep { const char* name; } cmd_beep; 31 | } caps_helper_tone = { 32 | .id = "tone", 33 | .cmd_beep = { .name = "beep" }, 34 | }; 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* _IOT_CAPS_HERLPER_TONE_ */ 41 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_tvocMeasurement.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_TVOC_MEASUREMENT_ 20 | #define _IOT_CAPS_HELPER_TVOC_MEASUREMENT_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_TVOCMEASUREMENT_TVOCLEVEL_UNIT_PPM, 30 | CAP_ENUM_TVOCMEASUREMENT_TVOCLEVEL_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_tvocMeasurement { 34 | const char *id; 35 | const struct tvocMeasurement_attr_tvocLevel { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_TVOCMEASUREMENT_TVOCLEVEL_UNIT_MAX]; 40 | const char *unit_ppm; 41 | const double min; 42 | const double max; 43 | } attr_tvocLevel; 44 | } caps_helper_tvocMeasurement = { 45 | .id = "tvocMeasurement", 46 | .attr_tvocLevel = { 47 | .name = "tvocLevel", 48 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_MAX | ATTR_SET_VALUE_REQUIRED | ATTR_SET_UNIT_REQUIRED, 49 | .valueType = VALUE_TYPE_NUMBER, 50 | .units = {"ppm"}, 51 | .unit_ppm = "ppm", 52 | .min = 0, 53 | .max = 1000000, 54 | }, 55 | }; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _IOT_CAPS_HERLPER_TVOC_MEASUREMENT_ */ 62 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_ultravioletIndex.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_ULTRAVIOLET_INDEX_ 20 | #define _IOT_CAPS_HELPER_ULTRAVIOLET_INDEX_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | const static struct iot_caps_ultravioletIndex { 29 | const char *id; 30 | const struct ultravioletIndex_attr_ultravioletIndex { 31 | const char *name; 32 | const unsigned char property; 33 | const unsigned char valueType; 34 | const double min; 35 | const double max; 36 | } attr_ultravioletIndex; 37 | } caps_helper_ultravioletIndex = { 38 | .id = "ultravioletIndex", 39 | .attr_ultravioletIndex = { 40 | .name = "ultravioletIndex", 41 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_MAX | ATTR_SET_VALUE_REQUIRED, 42 | .valueType = VALUE_TYPE_NUMBER, 43 | .min = 0, 44 | .max = 255, 45 | }, 46 | }; 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* _IOT_CAPS_HERLPER_ULTRAVIOLET_INDEX_ */ 53 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_veryFineDustSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_VERY_FINE_DUST_SENSOR_ 20 | #define _IOT_CAPS_HELPER_VERY_FINE_DUST_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_VERYFINEDUSTSENSOR_VERYFINEDUSTLEVEL_UNIT_UG_PER_M3, 30 | CAP_ENUM_VERYFINEDUSTSENSOR_VERYFINEDUSTLEVEL_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_veryFineDustSensor { 34 | const char *id; 35 | const struct veryFineDustSensor_attr_veryFineDustLevel { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_VERYFINEDUSTSENSOR_VERYFINEDUSTLEVEL_UNIT_MAX]; 40 | const char *unit_ug_per_m3; 41 | const int min; 42 | } attr_veryFineDustLevel; 43 | } caps_helper_veryFineDustSensor = { 44 | .id = "veryFineDustSensor", 45 | .attr_veryFineDustLevel = { 46 | .name = "veryFineDustLevel", 47 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_REQUIRED, 48 | .valueType = VALUE_TYPE_INTEGER, 49 | .units = {"μg/m^3"}, 50 | .unit_ug_per_m3 = "μg/m^3", 51 | .min = 0, 52 | }, 53 | }; 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* _IOT_CAPS_HERLPER_VERY_FINE_DUST_SENSOR_ */ 60 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_voltageMeasurement.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_VOLTAGE_MEASUREMENT_ 20 | #define _IOT_CAPS_HELPER_VOLTAGE_MEASUREMENT_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_VOLTAGEMEASUREMENT_VOLTAGE_UNIT_V, 30 | CAP_ENUM_VOLTAGEMEASUREMENT_VOLTAGE_UNIT_MAX 31 | }; 32 | 33 | const static struct iot_caps_voltageMeasurement { 34 | const char *id; 35 | const struct voltageMeasurement_attr_voltage { 36 | const char *name; 37 | const unsigned char property; 38 | const unsigned char valueType; 39 | const char *units[CAP_ENUM_VOLTAGEMEASUREMENT_VOLTAGE_UNIT_MAX]; 40 | const char *unit_V; 41 | const double min; 42 | } attr_voltage; 43 | } caps_helper_voltageMeasurement = { 44 | .id = "voltageMeasurement", 45 | .attr_voltage = { 46 | .name = "voltage", 47 | .property = ATTR_SET_VALUE_MIN | ATTR_SET_VALUE_REQUIRED, 48 | .valueType = VALUE_TYPE_NUMBER, 49 | .units = {"V"}, 50 | .unit_V = "V", 51 | .min = 0, 52 | }, 53 | }; 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif /* _IOT_CAPS_HERLPER_VOLTAGE_MEASUREMENT_ */ 60 | -------------------------------------------------------------------------------- /src/include/caps/iot_caps_helper_waterSensor.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_CAPS_HELPER_WATER_SENSOR_ 20 | #define _IOT_CAPS_HELPER_WATER_SENSOR_ 21 | 22 | #include "iot_caps_helper.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | enum { 29 | CAP_ENUM_WATERSENSOR_WATER_VALUE_DRY, 30 | CAP_ENUM_WATERSENSOR_WATER_VALUE_WET, 31 | CAP_ENUM_WATERSENSOR_WATER_VALUE_MAX 32 | }; 33 | 34 | const static struct iot_caps_waterSensor { 35 | const char *id; 36 | const struct waterSensor_attr_water { 37 | const char *name; 38 | const unsigned char property; 39 | const unsigned char valueType; 40 | const char *values[CAP_ENUM_WATERSENSOR_WATER_VALUE_MAX]; 41 | const char *value_dry; 42 | const char *value_wet; 43 | } attr_water; 44 | } caps_helper_waterSensor = { 45 | .id = "waterSensor", 46 | .attr_water = { 47 | .name = "water", 48 | .property = ATTR_SET_VALUE_REQUIRED, 49 | .valueType = VALUE_TYPE_STRING, 50 | .values = {"dry", "wet"}, 51 | .value_dry = "dry", 52 | .value_wet = "wet", 53 | }, 54 | }; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* _IOT_CAPS_HERLPER_WATER_SENSOR_ */ 61 | -------------------------------------------------------------------------------- /src/include/certs/root_ca.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | #ifndef _ST_ROOT_CA_H_ 19 | #define _ST_ROOT_CA_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | extern unsigned char st_root_ca[]; 26 | extern unsigned int st_root_ca_len; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | #endif /* _ST_ROOT_CA_H_ */ -------------------------------------------------------------------------------- /src/include/iot_common.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _IOT_COMMON_H_ 20 | #define _IOT_COMMON_H_ 21 | 22 | #include "iot_bsp_custom.h" 23 | 24 | #endif /* _IOT_COMMON_H_ */ -------------------------------------------------------------------------------- /src/include/mqtt/iot_mqtt_format.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | * 13 | * Contributors: 14 | * Ian Craggs - initial API and implementation and/or initial documentation 15 | *******************************************************************************/ 16 | 17 | #if !defined(MQTTFORMAT_H) 18 | #define MQTTFORMAT_H 19 | 20 | #include "iot_mqtt_stacktrace.h" 21 | 22 | const char* MQTTPacket_getName(unsigned short packetid); 23 | int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data); 24 | int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent); 25 | int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained, 26 | unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen); 27 | int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid); 28 | int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count, 29 | MQTTString topicFilters[], int requestedQoSs[]); 30 | int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs); 31 | int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, 32 | int count, MQTTString topicFilters[]); 33 | char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen); 34 | char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/include/mqtt/iot_mqtt_publish.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | * 13 | * Contributors: 14 | * Ian Craggs - initial API and implementation and/or initial documentation 15 | * Xiang Rong - 442039 Add makefile to Embedded C client 16 | *******************************************************************************/ 17 | 18 | #ifndef MQTTPUBLISH_H_ 19 | #define MQTTPUBLISH_H_ 20 | 21 | #if !defined(DLLImport) 22 | #define DLLImport 23 | #endif 24 | #if !defined(DLLExport) 25 | #define DLLExport 26 | #endif 27 | 28 | DLLExport int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, 29 | MQTTString topicName, unsigned char* payload, int payloadlen); 30 | DLLExport int MQTTSerialize_publish_size(int qos, MQTTString topicName, int payloadlen); 31 | DLLExport int MQTTSerialize_publish_header(unsigned char* buf, unsigned char dup, int qos, unsigned char retained, unsigned short packetid, 32 | MQTTString topicName, int payloadlen); 33 | 34 | DLLExport int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName, 35 | unsigned char** payload, int* payloadlen, unsigned char* buf, int len); 36 | 37 | DLLExport int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid); 38 | DLLExport int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid); 39 | DLLExport int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid); 40 | 41 | #endif /* MQTTPUBLISH_H_ */ 42 | -------------------------------------------------------------------------------- /src/include/mqtt/iot_mqtt_subscribe.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | * 13 | * Contributors: 14 | * Ian Craggs - initial API and implementation and/or initial documentation 15 | * Xiang Rong - 442039 Add makefile to Embedded C client 16 | *******************************************************************************/ 17 | 18 | #ifndef MQTTSUBSCRIBE_H_ 19 | #define MQTTSUBSCRIBE_H_ 20 | 21 | #if !defined(DLLImport) 22 | #define DLLImport 23 | #endif 24 | #if !defined(DLLExport) 25 | #define DLLExport 26 | #endif 27 | 28 | DLLExport int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, 29 | int count, MQTTString topicFilters[], int requestedQoSs[]); 30 | int MQTTSerialize_subscribe_size(int count, MQTTString topicFilters[]); 31 | 32 | DLLExport int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, 33 | int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], unsigned char* buf, int len); 34 | 35 | DLLExport int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs); 36 | 37 | DLLExport int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int len); 38 | 39 | 40 | #endif /* MQTTSUBSCRIBE_H_ */ 41 | -------------------------------------------------------------------------------- /src/include/mqtt/iot_mqtt_unsubscribe.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014 IBM Corp. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. 7 | * 8 | * The Eclipse Public License is available at 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * and the Eclipse Distribution License is available at 11 | * http://www.eclipse.org/org/documents/edl-v10.php. 12 | * 13 | * Contributors: 14 | * Ian Craggs - initial API and implementation and/or initial documentation 15 | * Xiang Rong - 442039 Add makefile to Embedded C client 16 | *******************************************************************************/ 17 | 18 | #ifndef MQTTUNSUBSCRIBE_H_ 19 | #define MQTTUNSUBSCRIBE_H_ 20 | 21 | #if !defined(DLLImport) 22 | #define DLLImport 23 | #endif 24 | #if !defined(DLLExport) 25 | #define DLLExport 26 | #endif 27 | 28 | DLLExport int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, 29 | int count, MQTTString topicFilters[]); 30 | DLLExport int MQTTSerialize_unsubscribe_size(int count, MQTTString topicFilters[]); 31 | 32 | DLLExport int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int max_count, int* count, MQTTString topicFilters[], 33 | unsigned char* buf, int len); 34 | 35 | DLLExport int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid); 36 | 37 | DLLExport int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int len); 38 | 39 | #endif /* MQTTUNSUBSCRIBE_H_ */ 40 | -------------------------------------------------------------------------------- /src/include/port/port_net.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright (c) 2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _PORT_NET_H_ 20 | #define _PORT_NET_H_ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #define PORT_NET_WAIT_FOREVER 0xffffffff 27 | 28 | typedef void *PORT_NET_CONTEXT; 29 | 30 | typedef struct { 31 | char *ca_cert; /**< @brief a pointer to a CA certificate chain */ 32 | unsigned int ca_cert_len; /**< @brief a size of CA certificate chain */ 33 | char *device_cert; /**< @brief a pointer to a device certificate chain */ 34 | unsigned int device_cert_len; /**< @brief a size of device certificate chain */ 35 | } port_net_tls_config; 36 | 37 | void port_net_free(PORT_NET_CONTEXT ctx); 38 | 39 | PORT_NET_CONTEXT port_net_connect(char *address, char *port, port_net_tls_config *config); 40 | 41 | PORT_NET_CONTEXT port_net_listen(char *port, port_net_tls_config *config); 42 | 43 | int port_net_read(PORT_NET_CONTEXT ctx, void *buf, size_t len); 44 | 45 | int port_net_read_poll(PORT_NET_CONTEXT ctx, unsigned int wait_time_ms); 46 | 47 | int port_net_write(PORT_NET_CONTEXT ctx, void *buf, size_t len); 48 | 49 | void port_net_close(PORT_NET_CONTEXT ctx); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _PORT_NET_H_ */ 56 | -------------------------------------------------------------------------------- /src/include/profile/json/device_info_example.json: -------------------------------------------------------------------------------- 1 | { 2 | "deviceInfo": { 3 | "firmwareVersion": "firmwareVersion_here", 4 | "privateKey": "privateKey_here", 5 | "publicKey": "publicKey_here", 6 | "serialNumber": "serialNumber_here" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/include/profile/json/onboarding_config_example.json: -------------------------------------------------------------------------------- 1 | { 2 | "onboardingConfig": { 3 | "deviceOnboardingId": "NAME", 4 | "mnId": "MNID", 5 | "setupId": "999", 6 | "vid": "VID", 7 | "deviceTypeId": "TYPE", 8 | "ownershipValidationTypes": [ 9 | "JUSTWORKS", 10 | "BUTTON", 11 | "PIN", 12 | "QR" 13 | ], 14 | "identityType": "ED25519", 15 | "deviceIntegrationProfileKey": { 16 | "id": "DIP_UUID", 17 | "majorVersion": 0, 18 | "minorVersion": 1 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/include/st_dev_version.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019-2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _ST_DEV_VERSION_H_ 20 | #define _ST_DEV_VERSION_H_ 21 | 22 | /* major: api incompatible */ 23 | #define VER_MAJOR 2 24 | 25 | /* minor: feature added. keep api backward compatibility */ 26 | #define VER_MINOR 1 27 | 28 | /* patch: bug fix */ 29 | #define VER_PATCH 1 30 | 31 | #define _STDK_STR(s) #s 32 | #define _STDK_VERSION_STR(a, b, c) _STDK_STR(a) "." _STDK_STR(b) "." _STDK_STR(c) 33 | 34 | /* External Macro for Apps, refer to linux's version.h */ 35 | #define STDK_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 36 | #define STDK_VERSION_CODE (STDK_VERSION(VER_MAJOR,VER_MINOR,VER_PATCH)) 37 | #define STDK_VERSION_STRING _STDK_VERSION_STR(VER_MAJOR, VER_MINOR, VER_PATCH) 38 | 39 | /* Protocol Version */ 40 | #define STDK_D2D_PROTOCOL_VERSION _STDK_VERSION_STR(2, 1, 0) 41 | #define STDK_D2S_PROTOCOL_VERSION _STDK_VERSION_STR(1, 0, 0) 42 | #define STDK_DWS_PROTOCOL_VERSION _STDK_VERSION_STR(1, 0, 0) 43 | 44 | #endif /* _ST_DEV_VERSION_H_ */ 45 | -------------------------------------------------------------------------------- /src/mqtt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(iotcore 2 | PRIVATE 3 | client/iot_mqtt_client.c 4 | packet/iot_mqtt_connect_client.c 5 | packet/iot_mqtt_connect_server.c 6 | packet/iot_mqtt_deserialize_publish.c 7 | packet/iot_mqtt_format.c 8 | packet/iot_mqtt_packet.c 9 | packet/iot_mqtt_serialize_publish.c 10 | packet/iot_mqtt_subscribe_client.c 11 | packet/iot_mqtt_subscribe_server.c 12 | packet/iot_mqtt_unsubscribe_client.c 13 | packet/iot_mqtt_unsubscribe_server.c 14 | ) -------------------------------------------------------------------------------- /src/port/bsp/bl602/iot_bsp_random_bl602.c: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | #include 19 | #include 20 | #include "iot_bsp_random.h" 21 | #include "iot_debug.h" 22 | #include "iot_error.h" 23 | 24 | unsigned int iot_bsp_random() 25 | { 26 | int ret = -1; 27 | unsigned int random; 28 | /*init rng */ 29 | hosal_rng_init(); 30 | ret = hosal_random_num_read(&random, sizeof(random)/sizeof(uint32_t)); 31 | if (0 != ret) { 32 | IOT_ERROR("rng read error\r\n"); 33 | return IOT_ERROR_INVALID_ARGS; 34 | } 35 | 36 | return random; 37 | } 38 | -------------------------------------------------------------------------------- /src/port/bsp/bl602/iot_bsp_system_bl602.c: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "hal_sys.h" 23 | #include "bl_timer.h" 24 | #include "iot_bsp_system.h" 25 | #include "iot_debug.h" 26 | 27 | 28 | const char* iot_bsp_get_bsp_name() 29 | { 30 | return "bl602"; 31 | } 32 | 33 | const char* iot_bsp_get_bsp_version_string() 34 | { 35 | setenv("CONFIG_CHIP_NAME", "BL602", 1); 36 | getenv("BL_SDK_VER"); 37 | return BL_SDK_VER; 38 | } 39 | 40 | void iot_bsp_system_reboot() 41 | { 42 | // Disable scheduler on this core. 43 | vTaskSuspendAll(); 44 | hal_sys_reset(); 45 | } 46 | 47 | void iot_bsp_system_poweroff() 48 | { 49 | iot_bsp_system_reboot(); // no poweroff feature. 50 | } 51 | 52 | iot_error_t iot_bsp_system_get_time_in_sec(time_t *time_in_sec) 53 | { 54 | struct timeval tv = {0,}; 55 | 56 | gettimeofday(&tv, NULL); 57 | *time_in_sec = tv.tv_sec; 58 | 59 | return IOT_ERROR_NONE; 60 | } 61 | 62 | iot_error_t iot_bsp_system_set_time_in_sec(time_t time_in_sec) 63 | { 64 | IOT_WARN_CHECK(time_in_sec == NULL, IOT_ERROR_INVALID_ARGS, "time data is NULL"); 65 | 66 | struct timeval tv = {0,}; 67 | 68 | tv.tv_sec = time_in_sec; 69 | settimeofday(&tv, NULL); 70 | 71 | return IOT_ERROR_NONE; 72 | } 73 | 74 | clock_t clock() 75 | { 76 | return bl_timer_now_us(); 77 | } 78 | -------------------------------------------------------------------------------- /src/port/bsp/esp32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(iotcore 2 | PRIVATE 3 | iot_bsp_debug_esp32.c 4 | iot_bsp_fs_esp32.c 5 | iot_bsp_nv_data_esp32.c 6 | iot_bsp_random_esp32.c 7 | iot_bsp_system_esp32.c 8 | iot_bsp_wifi_esp32.c 9 | ) 10 | 11 | if(CONFIG_STDK_IOT_CORE_EASYSETUP_BLE) 12 | target_sources(iotcore 13 | PUBLIC 14 | iot_bsp_ble_esp32.c 15 | ) 16 | target_link_libraries(iotcore PRIVATE idf::bt) 17 | endif() 18 | 19 | target_link_libraries(iotcore PRIVATE idf::spi_flash idf::esp_partition idf::esp_wifi idf::json idf::nvs_flash idf::bootloader_support) 20 | -------------------------------------------------------------------------------- /src/port/bsp/esp32/iot_bsp_random_esp32.c: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #include "iot_bsp_random.h" 20 | #include "esp_random.h" 21 | 22 | unsigned int iot_bsp_random() 23 | { 24 | return esp_random(); 25 | } 26 | -------------------------------------------------------------------------------- /src/port/bsp/esp32/iot_bsp_system_esp32.c: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "esp_system.h" 24 | #include "soc/efuse_reg.h" 25 | 26 | #include "iot_bsp_system.h" 27 | #include "iot_debug.h" 28 | 29 | const char* iot_bsp_get_bsp_name() 30 | { 31 | return "esp32"; 32 | } 33 | 34 | const char* iot_bsp_get_bsp_version_string() 35 | { 36 | return esp_get_idf_version(); 37 | } 38 | 39 | void iot_bsp_system_reboot() 40 | { 41 | esp_restart(); 42 | } 43 | 44 | void iot_bsp_system_poweroff() 45 | { 46 | esp_restart(); // no poweroff feature. 47 | } 48 | 49 | iot_error_t iot_bsp_system_get_time_in_sec(time_t *time_in_sec) 50 | { 51 | struct timeval tv = {0,}; 52 | 53 | gettimeofday(&tv, NULL); 54 | *time_in_sec = tv.tv_sec; 55 | 56 | return IOT_ERROR_NONE; 57 | } 58 | 59 | iot_error_t iot_bsp_system_set_time_in_sec(time_t time_in_sec) 60 | { 61 | struct timeval tv = {0,}; 62 | 63 | tv.tv_sec = time_in_sec; 64 | settimeofday(&tv, NULL); 65 | 66 | return IOT_ERROR_NONE; 67 | } 68 | -------------------------------------------------------------------------------- /src/port/bsp/posix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(iotcore 2 | PRIVATE 3 | iot_bsp_debug_posix.c 4 | iot_bsp_fs_posix.c 5 | iot_bsp_nv_data_posix.c 6 | iot_bsp_random_posix.c 7 | iot_bsp_system_posix.c 8 | iot_bsp_wifi_posix.c 9 | ) 10 | 11 | target_link_libraries(iotcore PUBLIC pthread rt) 12 | -------------------------------------------------------------------------------- /src/port/bsp/posix/iot_bsp_random_posix.c: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include "iot_bsp_random.h" 23 | 24 | unsigned int iot_bsp_random() 25 | { 26 | static int seed = 0; 27 | 28 | if (seed == 0) { 29 | srand(time(NULL)); 30 | seed = 1; 31 | } 32 | 33 | uint32_t rand1 = rand() << 24; 34 | uint32_t rand2 = (rand() << 16) & 0x00FF0000; 35 | uint32_t rand3 = (rand() << 8) & 0x0000FF00;; 36 | uint32_t rand4 = rand() & 0x000000FF; 37 | 38 | return (rand1 | rand2 | rand3 | rand4) % UINT32_MAX; 39 | } 40 | -------------------------------------------------------------------------------- /src/port/bsp/posix/iot_bsp_system_posix.c: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2019 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "iot_bsp_system.h" 24 | #include "iot_debug.h" 25 | 26 | const char* iot_bsp_get_bsp_name() 27 | { 28 | return "posix"; 29 | } 30 | 31 | const char* iot_bsp_get_bsp_version_string() 32 | { 33 | return ""; 34 | } 35 | 36 | void iot_bsp_system_reboot() 37 | { 38 | exit(0); 39 | } 40 | 41 | void iot_bsp_system_poweroff() 42 | { 43 | exit(0); 44 | } 45 | 46 | iot_error_t iot_bsp_system_get_time_in_sec(time_t *time_in_sec) 47 | { 48 | struct timespec ts = {0,}; 49 | 50 | clock_gettime(CLOCK_REALTIME, &ts); 51 | *time_in_sec = ts.tv_sec; 52 | 53 | return IOT_ERROR_NONE; 54 | } 55 | 56 | iot_error_t iot_bsp_system_set_time_in_sec(time_t time_in_sec) 57 | { 58 | struct timespec ts = {0,}; 59 | int ret; 60 | 61 | ts.tv_sec = time_in_sec; 62 | ret = clock_settime(CLOCK_REALTIME, &ts); 63 | if (ret == -1) 64 | return IOT_ERROR_INVALID_ARGS; 65 | 66 | return IOT_ERROR_NONE; 67 | } 68 | -------------------------------------------------------------------------------- /src/port/bsp/raspberry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(FindPkgConfig) 2 | 3 | pkg_check_modules(GLIB2 REQUIRED glib-2.0) 4 | pkg_check_modules(GIO2 REQUIRED gio-2.0) 5 | 6 | target_sources(iotcore 7 | PRIVATE 8 | iot_bsp_debug_linux.c 9 | iot_bsp_fs_linux.c 10 | iot_bsp_nv_data_linux.c 11 | iot_bsp_random_linux.c 12 | iot_bsp_system_linux.c 13 | iot_bsp_wifi_linux.c 14 | wifi_supplicant.c 15 | ) 16 | 17 | target_include_directories(iotcore PRIVATE . ${GLIB2_INCLUDE_DIRS} ${GIO2_INCLUDE_DIRS}) 18 | 19 | target_link_libraries(iotcore PUBLIC pthread rt ${GIO2_LIBRARIES} ${GLIB2_LIBRARIES}) 20 | -------------------------------------------------------------------------------- /src/port/bsp/raspberry/iot_bsp_random_linux.c: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright 2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include "iot_bsp_random.h" 23 | 24 | unsigned int iot_bsp_random(void) 25 | { 26 | static int seed = 0; 27 | 28 | if (seed == 0) { 29 | srand(time(NULL)); 30 | seed = 1; 31 | } 32 | 33 | uint32_t rand1 = rand() << 24; 34 | uint32_t rand2 = (rand() << 16) & 0x00FF0000; 35 | uint32_t rand3 = (rand() << 8) & 0x0000FF00;; 36 | uint32_t rand4 = rand() & 0x000000FF; 37 | 38 | return (rand1 | rand2 | rand3 | rand4) % UINT32_MAX; 39 | } 40 | -------------------------------------------------------------------------------- /src/port/crypto/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Port Crypto Cmake 3 | # 4 | 5 | target_sources(iotcore 6 | PRIVATE 7 | reference/port_crypto_reference.c 8 | reference/mbedtls_helper.c 9 | reference/libsodium_helper.c 10 | ) 11 | 12 | if(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32 OR 13 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32S2 OR 14 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32C3) 15 | target_link_libraries(iotcore PRIVATE idf::mbedtls idf::espressif__libsodium) 16 | endif() 17 | -------------------------------------------------------------------------------- /src/port/crypto/reference/libsodium_helper.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright (c) 2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef _LIBSODIUM_HELPER_H_ 20 | #define _LIBSODIUM_HELPER_H_ 21 | 22 | #include "security/iot_security_common.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | iot_error_t libsodium_helper_pk_sign_ed25519(iot_security_pk_params_t *pk_params, iot_security_buffer_t *input_buf, iot_security_buffer_t *sig_buf); 29 | 30 | iot_error_t libsodium_helper_pk_verify_ed25519(iot_security_pk_params_t *pk_params, iot_security_buffer_t *input_buf, iot_security_buffer_t *sig_buf); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* _LIBSODIUM_HELPER_H_ */ 37 | -------------------------------------------------------------------------------- /src/port/net/mbedtls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(iotcore 2 | PRIVATE 3 | port_net_mbedtls.c 4 | ) 5 | -------------------------------------------------------------------------------- /src/port/os/freertos/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(iotcore 2 | PRIVATE 3 | iot_os_util_freertos.c 4 | ) 5 | 6 | if(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32 OR 7 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32S2 OR 8 | CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32C3) 9 | target_link_libraries(iotcore PRIVATE idf::freertos) 10 | endif() 11 | -------------------------------------------------------------------------------- /src/port/os/posix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(iotcore 2 | PRIVATE 3 | iot_os_util_posix.c 4 | ) -------------------------------------------------------------------------------- /src/security/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(backend) 2 | 3 | target_sources(iotcore 4 | PRIVATE 5 | iot_security_util.c 6 | iot_security_common.c 7 | iot_security_crypto.c 8 | iot_security_ecdh.c 9 | iot_security_manager.c 10 | iot_security_storage.c 11 | ) 12 | -------------------------------------------------------------------------------- /src/security/backend/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE}) 2 | add_subdirectory(software) 3 | elseif(${CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE}) 4 | add_subdirectory(hardware) 5 | endif() 6 | -------------------------------------------------------------------------------- /src/security/backend/hardware/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_HARDWARE_VIRTUAL}) 2 | add_subdirectory(virtual) 3 | else 4 | target_sources(iotcore 5 | PRIVATE 6 | iot_security_be_hardware.c 7 | ) 8 | endif() 9 | -------------------------------------------------------------------------------- /src/security/backend/hardware/virtual/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(iotcore 2 | PRIVATE 3 | iot_security_be_virtual.c 4 | ) 5 | -------------------------------------------------------------------------------- /src/security/backend/software/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(iotcore 2 | PRIVATE 3 | iot_security_be_software.c 4 | iot_security_be_bsp.c 5 | ) 6 | -------------------------------------------------------------------------------- /stdkconfig: -------------------------------------------------------------------------------- 1 | STDK_CONFIGS = STDK_IOT_CORE 2 | STDK_CONFIGS += STDK_IOT_CORE_OS_SUPPORT_POSIX 3 | STDK_CONFIGS += STDK_IOT_CORE_USE_MBEDTLS 4 | STDK_CONFIGS += STDK_IOT_CORE_NET_MBEDTLS 5 | STDK_CONFIGS += STDK_IOT_CORE_CRYPTO_SUPPORT_ED25519 6 | STDK_CONFIGS += STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE 7 | STDK_CONFIGS += STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID 8 | STDK_CONFIGS += STDK_IOT_CORE_EASYSETUP_HTTP 9 | STDK_CONFIGS += STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API 10 | #STDK_CONFIGS += STDK_IOT_CORE_EASYSETUP_X509 11 | STDK_CONFIGS += STDK_IOT_CORE_LOG_LEVEL_ERROR 12 | STDK_CONFIGS += STDK_IOT_CORE_LOG_LEVEL_WARN 13 | STDK_CONFIGS += STDK_IOT_CORE_LOG_LEVEL_INFO 14 | #STDK_CONFIGS += STDK_IOT_CORE_LOG_LEVEL_DEBUG 15 | -------------------------------------------------------------------------------- /stdkconfig.cmake: -------------------------------------------------------------------------------- 1 | SET(STDK_EXTRA_CFLAGS 2 | CONFIG_STDK_IOT_CORE 3 | CONFIG_STDK_IOT_CORE_OS_SUPPORT_POSIX 4 | CONFIG_STDK_IOT_CORE_USE_MBEDTLS 5 | CONFIG_STDK_IOT_CORE_NET_MBEDTLS 6 | CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_ED25519 7 | CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE 8 | CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID 9 | CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP 10 | CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API 11 | CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_VERIFY 12 | 13 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_ERROR 14 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_WARN 15 | CONFIG_STDK_IOT_CORE_LOG_LEVEL_INFO 16 | #CONFIG_STDK_IOT_CORE_LOG_LEVEL_DEBUG 17 | ) 18 | 19 | SET(STDK_UNITTEST_EXTRA_CFLAGS 20 | CONFIG_STDK_IOT_CORE 21 | CONFIG_STDK_IOT_CORE_OS_SUPPORT_POSIX 22 | CONFIG_STDK_IOT_CORE_USE_MBEDTLS 23 | CONFIG_STDK_IOT_CORE_NET_MBEDTLS 24 | CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_ED25519 25 | CONFIG_STDK_IOT_CORE_SECURITY_BACKEND_SOFTWARE 26 | CONFIG_STDK_IOT_CORE_EASYSETUP_DISCOVERY_SSID 27 | CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP 28 | CONFIG_STDK_IOT_CORE_EASYSETUP_HTTP_USE_SOCKET_API 29 | CONFIG_STDK_IOT_CORE_CRYPTO_SUPPORT_VERIFY 30 | CONFIG_STDK_IOT_CORE_LOG_FILE 31 | CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_ONLY 32 | CONFIG_STDK_IOT_CORE_LOG_FILE_RAM_BUF_SIZE=8192 33 | #CONFIG_STDK_IOT_CORE_LOG_LEVEL_ERROR 34 | #CONFIG_STDK_IOT_CORE_LOG_LEVEL_WARN 35 | #CONFIG_STDK_IOT_CORE_LOG_LEVEL_INFO 36 | #CONFIG_STDK_IOT_CORE_LOG_LEVEL_DEBUG 37 | ) 38 | -------------------------------------------------------------------------------- /test/TC_MOCK_functions.h: -------------------------------------------------------------------------------- 1 | /* *************************************************************************** 2 | * 3 | * Copyright (c) 2020 Samsung Electronics All Rights Reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the License. 16 | * 17 | ****************************************************************************/ 18 | 19 | #ifndef ST_DEVICE_SDK_C_TC_MOCK_FUNCTIONS_H 20 | #define ST_DEVICE_SDK_C_TC_MOCK_FUNCTIONS_H 21 | 22 | #include 23 | 24 | void set_mock_iot_os_malloc_failure_with_index(unsigned int index); 25 | void set_mock_iot_os_malloc_failure(); 26 | void do_not_use_mock_iot_os_malloc_failure(); 27 | void set_mock_detect_memory_leak(bool detect); 28 | 29 | void port_net_mock_reset_read_stream(unsigned char *read_stream, size_t size); 30 | void port_net_mock_reset_socket_status(int status); 31 | 32 | #endif //ST_DEVICE_SDK_C_TC_MOCK_FUNCTIONS_H 33 | -------------------------------------------------------------------------------- /test/framework/cmocka/AUTHORS: -------------------------------------------------------------------------------- 1 | opensource@google.com 2 | Andreas Schneider 3 | Jakub Hrozek 4 | -------------------------------------------------------------------------------- /test/framework/cmocka/CPackConfig.cmake: -------------------------------------------------------------------------------- 1 | # For help take a look at: 2 | # http://www.cmake.org/Wiki/CMake:CPackConfiguration 3 | 4 | ### general settings 5 | set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) 6 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Unit testing framework for C with mock objects") 7 | set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") 8 | set(CPACK_PACKAGE_VENDOR "Andreas Schneider") 9 | set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) 10 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") 11 | 12 | 13 | ### versions 14 | set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) 15 | 16 | 17 | ### source generator 18 | set(CPACK_SOURCE_GENERATOR "TXZ") 19 | set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/obj*;tags;cscope.*;.ycm_extra_conf.pyc") 20 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") 21 | 22 | if (WIN32) 23 | set(CPACK_GENERATOR "ZIP") 24 | 25 | ### nsis generator 26 | find_package(NSIS) 27 | if (NSIS_MAKE) 28 | set(CPACK_GENERATOR "${CPACK_GENERATOR};NSIS") 29 | set(CPACK_NSIS_DISPLAY_NAME "CMocka") 30 | set(CPACK_NSIS_COMPRESSOR "/SOLID zlib") 31 | set(CPACK_NSIS_MENU_LINKS "http://cmocka.org/" "cmocka homepage") 32 | endif (NSIS_MAKE) 33 | endif (WIN32) 34 | 35 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "cmocka") 36 | 37 | set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}) 38 | 39 | set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") 40 | set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers") 41 | set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION 42 | "Libraries used to build programs which use cmocka") 43 | set(CPACK_COMPONENT_HEADERS_DESCRIPTION 44 | "C/C++ header files for use with cmocka") 45 | set(CPACK_COMPONENT_HEADERS_DEPENDS libraries) 46 | #set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime") 47 | set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") 48 | set(CPACK_COMPONENT_HEADERS_GROUP "Development") 49 | 50 | include(CPack) 51 | -------------------------------------------------------------------------------- /test/framework/cmocka/CTestConfig.cmake: -------------------------------------------------------------------------------- 1 | set(UPDATE_TYPE "true") 2 | 3 | set(CTEST_PROJECT_NAME "cmocka") 4 | set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") 5 | 6 | set(CTEST_DROP_METHOD "https") 7 | set(CTEST_DROP_SITE "test.cmocka.org") 8 | set(CTEST_DROP_LOCATION "/submit.php?project=${CTEST_PROJECT_NAME}") 9 | set(CTEST_DROP_SITE_CDASH TRUE) 10 | -------------------------------------------------------------------------------- /test/framework/cmocka/DefineOptions.cmake: -------------------------------------------------------------------------------- 1 | option(WITH_STATIC_LIB "Build with a static library" OFF) 2 | option(WITH_CMOCKERY_SUPPORT "Install a cmockery header" OFF) 3 | option(WITH_EXAMPLES "Build examples" ON) 4 | option(UNIT_TESTING "Build with unit testing" OFF) 5 | option(PICKY_DEVELOPER "Build with picky developer flags" OFF) 6 | 7 | if (WITH_STATIC_LIB) 8 | set(BUILD_STATIC_LIB ON) 9 | endif (WITH_STATIC_LIB) 10 | 11 | if (UNIT_TESTING) 12 | set(BUILD_STATIC_LIB ON) 13 | endif (UNIT_TESTING) 14 | -------------------------------------------------------------------------------- /test/framework/cmocka/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/test/framework/cmocka/NEWS -------------------------------------------------------------------------------- /test/framework/cmocka/README.md: -------------------------------------------------------------------------------- 1 | cmocka 2 | ====== 3 | 4 | cmocka is an elegant unit testing framework for C with support for mock 5 | objects. It only requires the standard C library, works on a range of computing 6 | platforms (including embedded) and with different compilers. 7 | 8 | For information about how to use the cmocka unit testing framework see 9 | doc/index.html or https://api.cmocka.org/. 10 | 11 | Compiling 12 | --------- 13 | 14 | To compile the cmocka library and example applications run, create a build dir, 15 | and in the build dir call 'cmake /path/to/cmocka' followed by 'make'. On 16 | Windows you can use the cmake gui. More details can be found in the INSTALL file. 17 | 18 | Website 19 | ------- 20 | 21 | https://cmocka.org 22 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Modules/AddCCompilerFlag.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # add_c_compiler_flag("-Werror" SUPPORTED_CFLAGS) 3 | # 4 | # Copyright (c) 2018 Andreas Schneider 5 | # 6 | # Redistribution and use is allowed according to the terms of the BSD license. 7 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 8 | 9 | include(CheckCCompilerFlag) 10 | 11 | macro(add_c_compiler_flag _COMPILER_FLAG _OUTPUT_VARIABLE) 12 | string(TOUPPER ${_COMPILER_FLAG} _COMPILER_FLAG_NAME) 13 | string(REGEX REPLACE "^-" "" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}") 14 | string(REGEX REPLACE "(-|=|\ )" "_" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}") 15 | 16 | check_c_compiler_flag("${_COMPILER_FLAG}" WITH_${_COMPILER_FLAG_NAME}_FLAG) 17 | if (WITH_${_COMPILER_FLAG_NAME}_FLAG) 18 | #string(APPEND ${_OUTPUT_VARIABLE} "${_COMPILER_FLAG} ") 19 | list(APPEND ${_OUTPUT_VARIABLE} ${_COMPILER_FLAG}) 20 | endif() 21 | endmacro() 22 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Modules/COPYING-CMAKE-SCRIPTS: -------------------------------------------------------------------------------- 1 | Redistribution and use in source and binary forms, with or without 2 | modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain the copyright 6 | notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | 3. The name of the author may not be used to endorse or promote products 11 | derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Modules/CheckCCompilerFlagSSP.cmake: -------------------------------------------------------------------------------- 1 | # - Check whether the C compiler supports a given flag in the 2 | # context of a stack checking compiler option. 3 | 4 | # CHECK_C_COMPILER_FLAG_SSP(FLAG VARIABLE) 5 | # 6 | # FLAG - the compiler flag 7 | # VARIABLE - variable to store the result 8 | # 9 | # This actually calls check_c_source_compiles. 10 | # See help for CheckCSourceCompiles for a listing of variables 11 | # that can modify the build. 12 | 13 | # Copyright (c) 2006, Alexander Neundorf, 14 | # 15 | # Redistribution and use is allowed according to the terms of the BSD license. 16 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 17 | 18 | # Requires cmake 3.10 19 | #include_guard(GLOBAL) 20 | include(CheckCSourceCompiles) 21 | include(CMakeCheckCompilerFlagCommonPatterns) 22 | 23 | macro(CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT) 24 | set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") 25 | set(CMAKE_REQUIRED_FLAGS "${_FLAG}") 26 | 27 | # Normalize locale during test compilation. 28 | set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) 29 | foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) 30 | set(_CheckCCompilerFlag_SAVED_${v} "$ENV{${v}}") 31 | set(ENV{${v}} C) 32 | endforeach() 33 | 34 | CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS) 35 | check_c_source_compiles("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" 36 | ${_RESULT} 37 | # Some compilers do not fail with a bad flag 38 | FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU 39 | ${_CheckCCompilerFlag_COMMON_PATTERNS}) 40 | foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) 41 | set(ENV{${v}} ${_CheckCCompilerFlag_SAVED_${v}}) 42 | unset(_CheckCCompilerFlag_SAVED_${v}) 43 | endforeach() 44 | unset(_CheckCCompilerFlag_LOCALE_VARS) 45 | unset(_CheckCCompilerFlag_COMMON_PATTERNS) 46 | 47 | set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") 48 | endmacro(CHECK_C_COMPILER_FLAG_SSP) 49 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Modules/DefineCMakeDefaults.cmake: -------------------------------------------------------------------------------- 1 | # Always include srcdir and builddir in include path 2 | # This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in 3 | # about every subdir 4 | # since cmake 2.4.0 5 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 6 | 7 | # Put the include dirs which are in the source or build tree 8 | # before all other include dirs, so the headers in the sources 9 | # are prefered over the already installed ones 10 | # since cmake 2.4.1 11 | set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) 12 | 13 | # Use colored output 14 | # since cmake 2.4.0 15 | set(CMAKE_COLOR_MAKEFILE ON) 16 | 17 | # Create the compile command database for clang by default 18 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 19 | 20 | # Always build with -fPIC 21 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 22 | 23 | # Avoid source tree pollution 24 | set(CMAKE_DISABLE_SOURCE_CHANGES ON) 25 | set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) 26 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Modules/DefinePlatformDefaults.cmake: -------------------------------------------------------------------------------- 1 | # Set system vars 2 | 3 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 4 | set(LINUX TRUE) 5 | endif(CMAKE_SYSTEM_NAME MATCHES "Linux") 6 | 7 | if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 8 | set(FREEBSD TRUE) 9 | endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 10 | 11 | if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") 12 | set(OPENBSD TRUE) 13 | endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") 14 | 15 | if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") 16 | set(NETBSD TRUE) 17 | endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD") 18 | 19 | if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") 20 | set(SOLARIS TRUE) 21 | endif (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") 22 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Modules/FindNSIS.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find NSIS 2 | # Once done this will define 3 | # 4 | # NSIS_ROOT_PATH - Set this variable to the root installation of NSIS 5 | # 6 | # Read-Only variables: 7 | # 8 | # NSIS_FOUND - system has NSIS 9 | # NSIS_MAKE - NSIS creator executable 10 | # 11 | #============================================================================= 12 | # Copyright (c) 2010-2013 Andreas Schneider 13 | # 14 | # Distributed under the OSI-approved BSD License (the "License"); 15 | # see accompanying file Copyright.txt for details. 16 | # 17 | # This software is distributed WITHOUT ANY WARRANTY; without even the 18 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | # See the License for more information. 20 | #============================================================================= 21 | # 22 | 23 | if (WIN32) 24 | set(_x86 "(x86)") 25 | 26 | set(_NSIS_ROOT_PATHS 27 | "$ENV{ProgramFiles}/NSIS" 28 | "$ENV{ProgramFiles${_x86}}/NSIS" 29 | "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS;Default]") 30 | 31 | find_path(NSIS_ROOT_PATH 32 | NAMES 33 | Include/Library.nsh 34 | PATHS 35 | ${_NSIS_ROOT_PATHS} 36 | ) 37 | mark_as_advanced(NSIS_ROOT_PATH) 38 | endif (WIN32) 39 | 40 | find_program(NSIS_MAKE 41 | NAMES 42 | makensis 43 | PATHS 44 | ${NSIS_ROOT_PATH} 45 | ) 46 | 47 | include(FindPackageHandleStandardArgs) 48 | find_package_handle_standard_args(NSIS DEFAULT_MSG NSIS_MAKE) 49 | 50 | if (NSIS_MAKE) 51 | set(NSIS_FOUND TRUE) 52 | endif (NSIS_MAKE) 53 | 54 | mark_as_advanced(NSIS_MAKE) 55 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake: -------------------------------------------------------------------------------- 1 | # - MACRO_ENSURE_OUT_OF_SOURCE_BUILD() 2 | # MACRO_ENSURE_OUT_OF_SOURCE_BUILD() 3 | 4 | # Copyright (c) 2006, Alexander Neundorf, 5 | # 6 | # Redistribution and use is allowed according to the terms of the BSD license. 7 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 8 | 9 | macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage) 10 | 11 | string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource) 12 | if (_insource) 13 | message(SEND_ERROR "${_errorMessage}") 14 | message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.") 15 | endif (_insource) 16 | 17 | endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD) 18 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Toolchain-Debian-mips.cmake: -------------------------------------------------------------------------------- 1 | include(CMakeForceCompiler) 2 | 3 | set(TOOLCHAIN_PREFIX mips-linux-gnu) 4 | 5 | set(CMAKE_SYSTEM_NAME Linux) 6 | set(CMAKE_SYSTEM_VERSION 1) 7 | set(CMAKE_SYSTEM_PROCESSOR mips) 8 | 9 | # This is the location of the mips toolchain 10 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) 11 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) 12 | 13 | # This is the file system root of the target 14 | set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) 15 | 16 | # Search for programs in the build host directories 17 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 18 | 19 | # For libraries and headers in the target directories 20 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 21 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 22 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmake/Toolchain-cross-m32.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_FLAGS "-m32" CACHE STRING "C compiler flags" FORCE) 2 | set(CMAKE_CXX_FLAGS "-m32" CACHE STRING "C++ compiler flags" FORCE) 3 | 4 | set(LIB32 /usr/lib) # Fedora 5 | 6 | if(EXISTS /usr/lib32) 7 | set(LIB32 /usr/lib32) # Arch, Solus 8 | endif() 9 | 10 | set(CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE) 11 | set(CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE) 12 | 13 | # this is probably unlikely to be needed, but just in case 14 | set(CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE) 15 | set(CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE) 16 | set(CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE) 17 | 18 | # on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have 19 | # to include the regular system .pc files as well (at the end), because some 20 | # are not always present in the 32 bit directory 21 | if(EXISTS ${LIB32}/pkgconfig) 22 | set(ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig) 23 | endiF() 24 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmocka-build-tree-settings.cmake.in: -------------------------------------------------------------------------------- 1 | set(CMOCKA_INLUDE_DIR @PROJECT_SOURCE_DIR@/include) 2 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmocka-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | get_filename_component(CMOCKA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 4 | 5 | if (EXISTS "${CMOCKA_CMAKE_DIR}/CMakeCache.txt") 6 | # In build tree 7 | include(${CMOCKA_CMAKE_DIR}/cmocka-build-tree-settings.cmake) 8 | else() 9 | set(CMOCKA_INCLUDE_DIR @PACKAGE_INCLUDE_INSTALL_DIR@) 10 | endif() 11 | 12 | set(CMOCKA_LIBRARY @PACKAGE_LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@) 13 | set(CMOCKA_LIBRARIES @PACKAGE_LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@) 14 | 15 | mark_as_advanced(CMOCKA_LIBRARY CMOCKA_INCLUDE_DIR) 16 | -------------------------------------------------------------------------------- /test/framework/cmocka/cmocka.pc.cmake: -------------------------------------------------------------------------------- 1 | Name: ${PROJECT_NAME} 2 | Description: The cmocka unit testing library 3 | Version: ${PROJECT_VERSION} 4 | Libs: -L${CMAKE_INSTALL_FULL_LIBDIR} -lcmocka 5 | Cflags: -I${CMAKE_INSTALL_FULL_INCLUDEDIR} 6 | -------------------------------------------------------------------------------- /test/framework/cmocka/coverity/README: -------------------------------------------------------------------------------- 1 | coverity_assert_model.c: 2 | 3 | This file is a Coverity Modeling file for projects using CMocka for unit 4 | testing. The assert functiions could create false positives, to avoid that you 5 | can load this modeling file in the Coverity web interface. 6 | 7 | coverity_internal_model.c: 8 | 9 | This file is for the CMocka source code itself. 10 | -------------------------------------------------------------------------------- /test/framework/cmocka/coverity/coverity_internal_model.c: -------------------------------------------------------------------------------- 1 | /* Functions to help coverity do static analysis on cmocka */ 2 | void exit_test(const int quit_application) 3 | { 4 | __coverity_panic__(); 5 | } 6 | -------------------------------------------------------------------------------- /test/framework/cmocka/doc/that_style/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jan-Lukas Wynen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/framework/cmocka/doc/that_style/README.md: -------------------------------------------------------------------------------- 1 | # that style 2 | A plain, more modern HTML style for Doxygen 3 | 4 | ## Requirements 5 | - Doxygen (tested with version 1.8.13) 6 | - *optional*: a sass/scss compiler if you want to modify the style 7 | 8 | ## Simple usage 9 | Tell Doxygen about the files for that style as shown in [doxyfile.conf](doxyfile.conf). You might need to adjust the 10 | paths depending on where you installed that style. 11 | When you run Doxygen, all files are copied into to generated HTML folder. So you don't need to keep the originals around 12 | unless you want to re-generate the documentation. 13 | 14 | ## Advanced 15 | that style uses a custom javascript to hack some nice stripes into some tables. It has to be loaded from HTML. Hence you need 16 | to use the provided custom header. Since its default content may change when Doxygen is updated, there might be syntax error in 17 | the generated HTML. If this is the case, you can remove the custom header (adjust your doxyfile.conf). This has no 18 | disadvantages other than removing the stripes. 19 | 20 | [that_style.css](that_style.css) was generated from the scss files in the folder [sass](sass). If you want to change the style, 21 | use those files in order to have better control. For instance, you can easily change most colors by modifying the variables 22 | in the beginning of [that_style.scss](sass/that_style.scss). 23 | -------------------------------------------------------------------------------- /test/framework/cmocka/doc/that_style/img/sync_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/test/framework/cmocka/doc/that_style/img/sync_off.png -------------------------------------------------------------------------------- /test/framework/cmocka/doc/that_style/img/sync_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/test/framework/cmocka/doc/that_style/img/sync_on.png -------------------------------------------------------------------------------- /test/framework/cmocka/doc/that_style/js/striped_bg.js: -------------------------------------------------------------------------------- 1 | // Adds extra CSS classes "even" and "odd" to .memberdecls to allow 2 | // striped backgrounds. 3 | function MemberDeclsStriper () { 4 | var counter = 0; 5 | 6 | this.stripe = function() { 7 | $(".memberdecls tbody").children().each(function(i) { 8 | 9 | // reset counter at every heading -> always start with even 10 | if ($(this).is(".heading")) { 11 | counter = 0; 12 | } 13 | 14 | // add extra classes 15 | if (counter % 2 == 1) { 16 | $(this).addClass("odd"); 17 | } 18 | else { 19 | $(this).addClass("even"); 20 | } 21 | 22 | // advance counter at every separator 23 | // this is the only way to reliably detect which table rows belong together 24 | if ($(this).is('[class^="separator"]')) { 25 | counter++; 26 | } 27 | }); 28 | } 29 | } 30 | 31 | // execute the function 32 | $(document).ready(new MemberDeclsStriper().stripe); 33 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/allocate_module.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifdef HAVE_CONFIG_H 17 | #include "config.h" 18 | #endif 19 | #ifdef HAVE_MALLOC_H 20 | #include 21 | #endif 22 | #include 23 | #include 24 | 25 | #ifdef UNIT_TESTING 26 | extern void* _test_malloc(const size_t size, const char* file, const int line); 27 | extern void* _test_calloc(const size_t number_of_elements, const size_t size, 28 | const char* file, const int line); 29 | extern void _test_free(void* const ptr, const char* file, const int line); 30 | 31 | #define malloc(size) _test_malloc(size, __FILE__, __LINE__) 32 | #define calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__) 33 | #define free(ptr) _test_free(ptr, __FILE__, __LINE__) 34 | #endif // UNIT_TESTING 35 | 36 | void leak_memory(void); 37 | void buffer_overflow(void); 38 | void buffer_underflow(void); 39 | 40 | void leak_memory(void) { 41 | int * const temporary = (int*)malloc(sizeof(int)); 42 | *temporary = 0; 43 | } 44 | 45 | void buffer_overflow(void) { 46 | char * const memory = (char*)malloc(sizeof(int)); 47 | memory[sizeof(int)] = '!'; 48 | free(memory); 49 | } 50 | 51 | void buffer_underflow(void) { 52 | char * const memory = (char*)malloc(sizeof(int)); 53 | memory[-1] = '!'; 54 | free(memory); 55 | } 56 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/allocate_module_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | extern void leak_memory(void); 22 | extern void buffer_overflow(void); 23 | extern void buffer_underflow(void); 24 | 25 | /* Test case that fails as leak_memory() leaks a dynamically allocated block. */ 26 | static void leak_memory_test(void **state) { 27 | (void) state; /* unused */ 28 | 29 | leak_memory(); 30 | } 31 | 32 | /* Test case that fails as buffer_overflow() corrupts an allocated block. */ 33 | static void buffer_overflow_test(void **state) { 34 | (void) state; /* unused */ 35 | 36 | buffer_overflow(); 37 | } 38 | 39 | /* Test case that fails as buffer_underflow() corrupts an allocated block. */ 40 | static void buffer_underflow_test(void **state) { 41 | (void) state; /* unused */ 42 | 43 | buffer_underflow(); 44 | } 45 | 46 | int main(void) { 47 | const struct CMUnitTest tests[] = { 48 | cmocka_unit_test(leak_memory_test), 49 | cmocka_unit_test(buffer_overflow_test), 50 | cmocka_unit_test(buffer_underflow_test), 51 | }; 52 | return cmocka_run_group_tests(tests, NULL, NULL); 53 | } 54 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/assert_macro.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "assert_macro.h" 19 | 20 | static const char* status_code_strings[] = { 21 | "Address not found", 22 | "Connection dropped", 23 | "Connection timed out", 24 | }; 25 | 26 | const char* get_status_code_string(const unsigned int status_code) { 27 | return status_code_strings[status_code]; 28 | } 29 | 30 | unsigned int string_to_status_code(const char* const status_code_string) { 31 | unsigned int i; 32 | for (i = 0; i < sizeof(status_code_strings) / 33 | sizeof(status_code_strings[0]); i++) { 34 | if (strcmp(status_code_strings[i], status_code_string) == 0) { 35 | return i; 36 | } 37 | } 38 | return ~0U; 39 | } 40 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/assert_macro.h: -------------------------------------------------------------------------------- 1 | const char* get_status_code_string(const unsigned int status_code); 2 | unsigned int string_to_status_code(const char* const status_code_string); 3 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/assert_macro_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "assert_macro.h" 22 | 23 | /* This test will fail since the string returned by get_status_code_string(0) 24 | * doesn't match "Connection timed out". */ 25 | static void get_status_code_string_test(void **state) { 26 | (void) state; /* unused */ 27 | 28 | assert_string_equal(get_status_code_string(0), "Address not found"); 29 | assert_string_equal(get_status_code_string(1), "Connection timed out"); 30 | } 31 | 32 | /* This test will fail since the status code of "Connection timed out" isn't 1 */ 33 | static void string_to_status_code_test(void **state) { 34 | (void) state; /* unused */ 35 | 36 | assert_int_equal(string_to_status_code("Address not found"), 0); 37 | assert_int_equal(string_to_status_code("Connection timed out"), 1); 38 | } 39 | 40 | int main(void) { 41 | const struct CMUnitTest tests[] = { 42 | cmocka_unit_test(get_status_code_string_test), 43 | cmocka_unit_test(string_to_status_code_test), 44 | }; 45 | return cmocka_run_group_tests(tests, NULL, NULL); 46 | } 47 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/assert_module.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | #include "assert_module.h" 19 | 20 | /* If unit testing is enabled override assert with mock_assert(). */ 21 | #ifdef UNIT_TESTING 22 | extern void mock_assert(const int result, const char* const expression, 23 | const char * const file, const int line); 24 | #undef assert 25 | #define assert(expression) \ 26 | mock_assert(((expression) ? 1 : 0), #expression, __FILE__, __LINE__); 27 | #endif /* UNIT_TESTING */ 28 | 29 | void increment_value(int * const value) { 30 | assert(value); 31 | (*value) ++; 32 | } 33 | 34 | void decrement_value(int * const value) { 35 | if (value) { 36 | (*value) --; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/assert_module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | void increment_value(int * const value); 18 | void decrement_value(int * const value); 19 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/assert_module_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "assert_module.h" 22 | 23 | extern void increment_value(int * const value); 24 | 25 | /* This test case will fail but the assert is caught by run_tests() and the 26 | * next test is executed. */ 27 | static void increment_value_fail(void **state) { 28 | (void) state; 29 | 30 | increment_value(NULL); 31 | } 32 | 33 | /* This test case succeeds since increment_value() asserts on the NULL 34 | * pointer. */ 35 | static void increment_value_assert(void **state) { 36 | (void) state; 37 | 38 | expect_assert_failure(increment_value(NULL)); 39 | } 40 | 41 | /* This test case fails since decrement_value() doesn't assert on a NULL 42 | * pointer. */ 43 | static void decrement_value_fail(void **state) { 44 | (void) state; 45 | 46 | expect_assert_failure(decrement_value(NULL)); 47 | } 48 | 49 | int main(void) { 50 | const struct CMUnitTest tests[] = { 51 | cmocka_unit_test(increment_value_fail), 52 | cmocka_unit_test(increment_value_assert), 53 | cmocka_unit_test(decrement_value_fail), 54 | }; 55 | return cmocka_run_group_tests(tests, NULL, NULL); 56 | } 57 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/database.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | typedef struct DatabaseConnection DatabaseConnection; 17 | 18 | /* Function that takes an SQL query string and sets results to an array of 19 | * pointers with the result of the query. The value returned specifies the 20 | * number of items in the returned array of results. The returned array of 21 | * results are statically allocated and should not be deallocated using free() 22 | */ 23 | typedef unsigned int (*QueryDatabase)( 24 | DatabaseConnection* const connection, const char * const query_string, 25 | void *** const results); 26 | 27 | /* Connection to a database. */ 28 | struct DatabaseConnection { 29 | const char *url; 30 | unsigned int port; 31 | QueryDatabase query_database; 32 | }; 33 | 34 | /* Connect to a database. */ 35 | DatabaseConnection* connect_to_database(const char * const url, 36 | const unsigned int port); 37 | 38 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/mock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # TODO Execute "$CMAKE_LINKER --help" and check for --wrap 2 | if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)" AND NOT APPLE) 3 | add_subdirectory(chef_wrap) 4 | add_subdirectory(uptime) 5 | endif() 6 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/mock/chef_wrap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cmocka-wrap-examples C) 2 | 3 | include_directories( 4 | ${CMAKE_BINARY_DIR} 5 | ${CMAKE_CURRENT_SOURCE_DIR} 6 | ${CMOCKA_PUBLIC_INCLUDE_DIRS} 7 | ) 8 | 9 | add_executable(waiter_test_wrap waiter_test_wrap.c chef.c) 10 | target_link_libraries(waiter_test_wrap ${CMOCKA_SHARED_LIBRARY}) 11 | 12 | add_test(waiter_test_wrap ${CMAKE_CURRENT_BINARY_DIR}/waiter_test_wrap) 13 | 14 | set_target_properties(waiter_test_wrap 15 | PROPERTIES 16 | LINK_FLAGS "-Wl,--wrap=chef_cook" 17 | ) 18 | if (WIN32 OR MINGW OR CYGWIN) 19 | set_tests_properties(waiter_test_wrap PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}") 20 | endif (WIN32 OR MINGW OR CYGWIN) 21 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/mock/chef_wrap/chef.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 (c) Andreas Schneider 3 | * Jakub Hrozek 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "chef.h" 28 | 29 | 30 | /* This is the real chef, just not implemented yet, currently it always 31 | * returns ENOSYS 32 | */ 33 | int chef_cook(const char *order, char **dish_out) 34 | { 35 | if (order == NULL || dish_out == NULL) return EINVAL; 36 | 37 | return -ENOSYS; 38 | } 39 | 40 | /* Print chef return codes as string */ 41 | const char *chef_strerror(int error) 42 | { 43 | switch (error) { 44 | case 0: 45 | return "Success"; 46 | case -1: 47 | return "Unknown dish"; 48 | case -2: 49 | return "Not enough ingredients for the dish"; 50 | } 51 | 52 | return "Unknown error!"; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/mock/chef_wrap/chef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 (c) Andreas Schneider 3 | * Jakub Hrozek 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | int chef_cook(const char *order, char **dish_out); 19 | const char *chef_strerror(int error); 20 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/mock/chef_wrap/waiter_test_wrap.h: -------------------------------------------------------------------------------- 1 | 2 | int __wrap_chef_cook(const char *order, char **dish_out); 3 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/mock/uptime/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(proc_uptime proc_uptime.c) 2 | 3 | add_executable(uptime uptime.c) 4 | target_compile_options(uptime PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) 5 | target_link_libraries(uptime proc_uptime) 6 | set_property(TARGET 7 | uptime 8 | PROPERTY 9 | LINK_FLAGS 10 | "${DEFAULT_LINK_FLAGS}") 11 | 12 | add_cmocka_test(test_uptime 13 | SOURCES test_uptime.c 14 | COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} 15 | LINK_LIBRARIES ${CMOCKA_SHARED_LIBRARY}) 16 | set_property(TARGET 17 | test_uptime 18 | PROPERTY 19 | LINK_FLAGS 20 | "${DEFAULT_LINK_FLAGS} -Wl,--wrap=uptime") 21 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/mock/uptime/proc_uptime.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Andreas Scheider 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "proc_uptime.h" 28 | 29 | #define UPTIME_FILE "/proc/uptime" 30 | 31 | int uptime(const char *uptime_path, double *uptime_secs, double *idle_secs) 32 | { 33 | double up = 0; 34 | double idle = 0; 35 | char *savelocale = NULL; 36 | char buf[1024] = {0}; 37 | ssize_t nread; 38 | int fd = -1; 39 | int rc; 40 | 41 | if (uptime_path == NULL) { 42 | uptime_path = UPTIME_FILE; 43 | } 44 | 45 | fd = open(uptime_path, O_RDONLY); 46 | if (fd < 0) { 47 | return 0; 48 | } 49 | 50 | nread = read(fd, buf, sizeof(buf)); 51 | close(fd); 52 | if (nread < 0) { 53 | return 0; 54 | } 55 | 56 | savelocale = strdup(setlocale(LC_NUMERIC, NULL)); 57 | if (savelocale == NULL) { 58 | return 0; 59 | } 60 | 61 | setlocale(LC_NUMERIC, "C"); 62 | rc = sscanf(buf, "%lf %lf", &up, &idle); 63 | setlocale(LC_NUMERIC, savelocale); 64 | free(savelocale); 65 | if (rc < 2) { 66 | errno = EFAULT; 67 | return 0; 68 | } 69 | 70 | if (uptime_secs != NULL) { 71 | *uptime_secs = up; 72 | } 73 | if (idle_secs != NULL) { 74 | *idle_secs = idle; 75 | } 76 | 77 | return (int)up; 78 | } 79 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/mock/uptime/proc_uptime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Andreas Scheider 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _PROC_UPTIME_H 18 | #define _PROC_UPTIME_H 19 | 20 | int uptime(const char *uptime_path, double *uptime_secs, double *idle_secs); 21 | 22 | #endif /* _PROC_UPTIME_H */ 23 | -------------------------------------------------------------------------------- /test/framework/cmocka/example/simple_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /* A test case that does nothing and succeeds. */ 8 | static void null_test_success(void **state) { 9 | (void) state; /* unused */ 10 | } 11 | 12 | int main(void) { 13 | const struct CMUnitTest tests[] = { 14 | cmocka_unit_test(null_test_success), 15 | }; 16 | 17 | return cmocka_run_group_tests(tests, NULL, NULL); 18 | } 19 | -------------------------------------------------------------------------------- /test/framework/cmocka/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cmocka-header C) 2 | 3 | install(FILES 4 | cmocka.h 5 | cmocka_pbc.h 6 | DESTINATION 7 | ${CMAKE_INSTALL_INCLUDEDIR} 8 | COMPONENT 9 | ${PROJECT_NAME}) 10 | 11 | if (WITH_CMOCKERY_SUPPORT) 12 | install(FILES 13 | cmockery/cmockery.h 14 | cmockery/pbc.h 15 | DESTINATION 16 | ${CMAKE_INSTALL_INCLUDEDIR}/cmockery 17 | COMPONENT 18 | ${PROJECT_NAME}) 19 | endif() 20 | -------------------------------------------------------------------------------- /test/framework/cmocka/include/cmocka_pbc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Luis Pabon, Jr. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * Programming by Contract is a programming methodology 19 | * which binds the caller and the function called to a 20 | * contract. The contract is represented using Hoare Triple: 21 | * {P} C {Q} 22 | * where {P} is the precondition before executing command C, 23 | * and {Q} is the postcondition. 24 | * 25 | * See also: 26 | * http://en.wikipedia.org/wiki/Design_by_contract 27 | * http://en.wikipedia.org/wiki/Hoare_logic 28 | * http://dlang.org/dbc.html 29 | */ 30 | #ifndef CMOCKA_PBC_H_ 31 | #define CMOCKA_PBC_H_ 32 | 33 | #if defined(UNIT_TESTING) || defined (DEBUG) 34 | 35 | #include 36 | 37 | /* 38 | * Checks caller responsibility against contract 39 | */ 40 | #define REQUIRE(cond) assert(cond) 41 | 42 | /* 43 | * Checks function reponsability against contract. 44 | */ 45 | #define ENSURE(cond) assert(cond) 46 | 47 | /* 48 | * While REQUIRE and ENSURE apply to functions, INVARIANT 49 | * applies to classes/structs. It ensures that intances 50 | * of the class/struct are consistent. In other words, 51 | * that the instance has not been corrupted. 52 | */ 53 | #define INVARIANT(invariant_fnc) do{ (invariant_fnc) } while (0); 54 | 55 | #else 56 | #define REQUIRE(cond) do { } while (0); 57 | #define ENSURE(cond) do { } while (0); 58 | #define INVARIANT(invariant_fnc) do{ } while (0); 59 | 60 | #endif /* defined(UNIT_TESTING) || defined (DEBUG) */ 61 | #endif /* CMOCKA_PBC_H_ */ 62 | 63 | -------------------------------------------------------------------------------- /test/framework/cmocka/include/cmockery/cmockery.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /test/framework/cmocka/include/cmockery/pbc.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /test/framework/cmocka/src/cmocka.def: -------------------------------------------------------------------------------- 1 | LIBRARY cmocka 2 | EXPORTS 3 | _assert_float_equal 4 | _assert_float_not_equal 5 | _assert_in_range 6 | _assert_in_set 7 | _assert_int_equal 8 | _assert_int_not_equal 9 | _assert_memory_equal 10 | _assert_memory_not_equal 11 | _assert_not_in_range 12 | _assert_not_in_set 13 | _assert_return_code 14 | _assert_string_equal 15 | _assert_string_not_equal 16 | _assert_true 17 | _check_expected 18 | _cmocka_run_group_tests 19 | _expect_any 20 | _expect_check 21 | _expect_function_call 22 | _expect_in_range 23 | _expect_in_set 24 | _expect_memory 25 | _expect_not_in_range 26 | _expect_not_in_set 27 | _expect_not_memory 28 | _expect_not_string 29 | _expect_not_value 30 | _expect_string 31 | _expect_value 32 | _fail 33 | _function_called 34 | _mock 35 | _run_test 36 | _run_tests 37 | _skip 38 | _test_calloc 39 | _test_free 40 | _test_malloc 41 | _test_realloc 42 | _will_return 43 | cm_print_error 44 | cmocka_set_message_output 45 | cmocka_set_test_filter 46 | cmocka_set_skip_filter 47 | global_expect_assert_env 48 | global_expecting_assert 49 | global_last_failed_assert 50 | mock_assert 51 | print_error 52 | print_message 53 | vprint_error 54 | vprint_message 55 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_assert_macros.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #ifdef HAVE_UNISTD_H 13 | #include 14 | #endif 15 | #include 16 | 17 | /************************************** 18 | *** assert_return_code 19 | **************************************/ 20 | static void test_assert_return_code(void **state) 21 | { 22 | struct stat sb; 23 | int rc; 24 | 25 | (void)state; /* unused */ 26 | 27 | rc = stat(".", &sb); 28 | assert_return_code(rc, 0); 29 | 30 | #ifndef _MSC_VER 31 | assert_true(S_ISDIR(sb.st_mode)); 32 | #endif 33 | } 34 | 35 | int main(void) { 36 | const struct CMUnitTest tests[] = { 37 | cmocka_unit_test(test_assert_return_code), 38 | }; 39 | 40 | return cmocka_run_group_tests(tests, NULL, NULL); 41 | } 42 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_assert_macros_fail.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #ifdef HAVE_UNISTD_H 13 | #include 14 | #endif 15 | #ifdef HAVE_IO_H 16 | #include 17 | #endif 18 | #include 19 | 20 | /************************************** 21 | *** assert_return_code 22 | **************************************/ 23 | static void test_assert_return_code_fail(void **state) 24 | { 25 | int fd; 26 | 27 | (void)state; /* unused */ 28 | 29 | fd = open("this_file_doesnt_exist.cmocka", 0); 30 | assert_return_code(fd, errno); 31 | 32 | if (fd >= 0) { 33 | close(fd); 34 | } 35 | } 36 | 37 | int main(void) { 38 | const struct CMUnitTest tests[] = { 39 | cmocka_unit_test(test_assert_return_code_fail), 40 | }; 41 | 42 | return cmocka_run_group_tests(tests, NULL, NULL); 43 | } 44 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_basics.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* Use the unit test allocators */ 18 | #define UNIT_TESTING 1 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | static int setup(void **state) { 26 | int *answer = malloc(sizeof(int)); 27 | 28 | assert_non_null(answer); 29 | *answer = 42; 30 | 31 | *state = answer; 32 | 33 | return 0; 34 | } 35 | 36 | static int teardown(void **state) { 37 | free(*state); 38 | 39 | return 0; 40 | } 41 | 42 | /* A test case that does nothing and succeeds. */ 43 | static void null_test_success(void **state) { 44 | (void) state; 45 | } 46 | 47 | /* A test case that does check if an int is equal. */ 48 | static void int_test_success(void **state) { 49 | int *answer = *state; 50 | 51 | assert_int_equal(*answer, 42); 52 | } 53 | 54 | 55 | int main(void) { 56 | const struct CMUnitTest tests[] = { 57 | cmocka_unit_test(null_test_success), 58 | cmocka_unit_test_setup_teardown(int_test_success, setup, teardown), 59 | }; 60 | 61 | return cmocka_run_group_tests(tests, NULL, NULL); 62 | } 63 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_cmockery.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* A test case that does nothing and succeeds. */ 23 | static void null_test_success(void **state) { 24 | (void) state; /* unused */ 25 | } 26 | 27 | int main(void) { 28 | const UnitTest tests[] = { 29 | unit_test(null_test_success), 30 | }; 31 | return run_tests(tests); 32 | } 33 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_exception_handler.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | struct test_segv { 9 | int x; 10 | int y; 11 | }; 12 | 13 | static void test_segfault_recovery(void **state) 14 | { 15 | struct test_segv *s = NULL; 16 | 17 | (void) state; /* unused */ 18 | 19 | s->x = 1; 20 | } 21 | 22 | static void test_segfault_recovery1(void **state) 23 | { 24 | test_segfault_recovery(state); 25 | } 26 | 27 | static void test_segfault_recovery2(void **state) 28 | { 29 | test_segfault_recovery(state); 30 | } 31 | 32 | static void test_segfault_recovery3(void **state) 33 | { 34 | test_segfault_recovery(state); 35 | } 36 | 37 | int main(void) { 38 | const struct CMUnitTest tests[] = { 39 | cmocka_unit_test(test_segfault_recovery1), 40 | cmocka_unit_test(test_segfault_recovery2), 41 | cmocka_unit_test(test_segfault_recovery3), 42 | }; 43 | 44 | return cmocka_run_group_tests(tests, NULL, NULL); 45 | } 46 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_fixtures.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | static int setup_only(void **state) 9 | { 10 | *state = malloc(1); 11 | 12 | return 0; 13 | } 14 | 15 | static int teardown_only(void **state) 16 | { 17 | free(*state); 18 | 19 | return 0; 20 | } 21 | 22 | static void malloc_setup_test(void **state) 23 | { 24 | assert_non_null(*state); 25 | free(*state); 26 | } 27 | 28 | static void malloc_teardown_test(void **state) 29 | { 30 | *state = malloc(1); 31 | assert_non_null(*state); 32 | } 33 | 34 | static int prestate_setup(void **state) 35 | { 36 | int *val = (int *)*state, *a; 37 | 38 | a = malloc(sizeof(int)); 39 | *a = *val + 1; 40 | *state = a; 41 | 42 | return 0; 43 | } 44 | 45 | static int prestate_teardown(void **state) 46 | { 47 | free(*state); 48 | 49 | return 0; 50 | } 51 | 52 | static void prestate_setup_test(void **state) 53 | { 54 | int *a = (int *)*state; 55 | 56 | assert_non_null(a); 57 | assert_int_equal(*a, 43); 58 | } 59 | 60 | static void prestate_test(void **state) 61 | { 62 | int *a = (int *)*state; 63 | 64 | assert_non_null(a); 65 | assert_int_equal(*a, 42); 66 | } 67 | 68 | int main(void) { 69 | int prestate = 42; 70 | const struct CMUnitTest tests[] = { 71 | cmocka_unit_test_setup(malloc_setup_test, setup_only), 72 | cmocka_unit_test_setup(malloc_setup_test, setup_only), 73 | cmocka_unit_test_teardown(malloc_teardown_test, teardown_only), 74 | cmocka_unit_test_teardown(malloc_teardown_test, teardown_only), 75 | cmocka_unit_test_teardown(malloc_teardown_test, teardown_only), 76 | cmocka_unit_test_teardown(malloc_teardown_test, teardown_only), 77 | cmocka_unit_test_prestate(prestate_test, &prestate), 78 | cmocka_unit_test_prestate_setup_teardown(prestate_setup_test, prestate_setup, prestate_teardown, &prestate), 79 | }; 80 | 81 | return cmocka_run_group_tests(tests, NULL, NULL); 82 | } 83 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_float_macros.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Arnaud Gelas 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* Use the unit test allocators */ 18 | #define UNIT_TESTING 1 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /* A test case that does check if float is equal. */ 26 | static void float_test_success(void **state) 27 | { 28 | (void)state; /* unused */ 29 | 30 | assert_float_equal(0.5f, 1.f / 2.f, 0.000001f); 31 | assert_float_not_equal(0.5, 0.499f, 0.000001f); 32 | } 33 | 34 | int main(void) { 35 | const struct CMUnitTest tests[] = { 36 | cmocka_unit_test(float_test_success), 37 | }; 38 | 39 | return cmocka_run_group_tests(tests, NULL, NULL); 40 | } 41 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_group_fixtures.c: -------------------------------------------------------------------------------- 1 | /* Use the unit test allocators */ 2 | #define UNIT_TESTING 1 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static int group_setup(void **state) 10 | { 11 | int *answer = malloc(sizeof(int)); 12 | assert_non_null(answer); 13 | *answer = 42; 14 | 15 | *state = answer; 16 | return 0; 17 | } 18 | 19 | static int group_teardown(void **state) 20 | { 21 | int *answer = (int *)*state; 22 | 23 | free(answer); 24 | return 0; 25 | } 26 | 27 | static void test_value_equal(void **state) 28 | { 29 | int a = *((int *)*state); 30 | 31 | assert_int_equal(a, 42); 32 | } 33 | 34 | static void test_value_range(void **state) 35 | { 36 | int a = *((int *)*state); 37 | 38 | assert_in_range(a, 0, 100); 39 | } 40 | 41 | int main(void) { 42 | int prestate = 1337; 43 | const struct CMUnitTest tests[] = { 44 | cmocka_unit_test(test_value_equal), 45 | cmocka_unit_test(test_value_range), 46 | cmocka_unit_test_prestate(test_value_equal, &prestate), 47 | }; 48 | 49 | return cmocka_run_group_tests(tests, group_setup, group_teardown); 50 | } 51 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_group_setup_assert.c: -------------------------------------------------------------------------------- 1 | /* Use the unit test allocators */ 2 | #define UNIT_TESTING 1 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static int group_setup_failing(void **state) 10 | { 11 | (void) state; /* unused */ 12 | 13 | assert_int_equal(0, 1); 14 | 15 | return 0; 16 | } 17 | 18 | static void test_true(void **state) 19 | { 20 | (void) state; /* unused */ 21 | assert_true(1); 22 | } 23 | 24 | static void test_false(void **state) 25 | { 26 | (void) state; /* unused */ 27 | assert_false(0); 28 | } 29 | 30 | int main(void) { 31 | const struct CMUnitTest tests[] = { 32 | cmocka_unit_test(test_true), 33 | cmocka_unit_test(test_false), 34 | }; 35 | 36 | return cmocka_run_group_tests(tests, group_setup_failing, NULL); 37 | } 38 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_group_setup_fail.c: -------------------------------------------------------------------------------- 1 | /* Use the unit test allocators */ 2 | #define UNIT_TESTING 1 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static int group_setup_failing(void **state) 10 | { 11 | (void) state; /* unused */ 12 | return 1; /* To indicate the failure */ 13 | } 14 | 15 | static void test_true(void **state) 16 | { 17 | (void) state; /* unused */ 18 | assert_true(1); 19 | } 20 | 21 | static void test_false(void **state) 22 | { 23 | (void) state; /* unused */ 24 | assert_false(0); 25 | } 26 | 27 | int main(void) { 28 | const struct CMUnitTest tests[] = { 29 | cmocka_unit_test(test_true), 30 | cmocka_unit_test(test_false), 31 | }; 32 | 33 | return cmocka_run_group_tests(tests, group_setup_failing, NULL); 34 | } 35 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_groups.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 David Schneider 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* Use the unit test allocators */ 18 | #define UNIT_TESTING 1 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | static int setup(void **state) { 26 | int *answer = malloc(sizeof(int)); 27 | 28 | assert_non_null(answer); 29 | *answer = 42; 30 | 31 | *state = answer; 32 | 33 | return 0; 34 | } 35 | 36 | static int teardown(void **state) { 37 | free(*state); 38 | 39 | return 0; 40 | } 41 | 42 | /* A test case that does nothing and succeeds. */ 43 | static void null_test_success(void **state) { 44 | (void) state; 45 | } 46 | 47 | /* A test case that does check if an int is equal. */ 48 | static void int_test_success(void **state) { 49 | int *answer = *state; 50 | 51 | assert_int_equal(*answer, 42); 52 | } 53 | 54 | 55 | int main(void) { 56 | const struct CMUnitTest test_group1[] = { 57 | cmocka_unit_test(null_test_success), 58 | }; 59 | 60 | const struct CMUnitTest test_group2[] = { 61 | cmocka_unit_test_setup_teardown(int_test_success, setup, teardown), 62 | }; 63 | 64 | int result = 0; 65 | result += cmocka_run_group_tests(test_group1, NULL, NULL); 66 | result += cmocka_run_group_tests(test_group2, NULL, NULL); 67 | 68 | return result; 69 | } 70 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_returns.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | int mock_function(void); 12 | void mock_function_call_times(size_t times, int expectedValue); 13 | 14 | int mock_function(void) 15 | { 16 | return (int) mock(); 17 | } 18 | 19 | void mock_function_call_times(size_t times, int expectedValue) 20 | { 21 | size_t i; 22 | for (i = 0u; i < times; ++i) 23 | { 24 | assert_int_equal(expectedValue, mock_function()); 25 | } 26 | } 27 | 28 | static void test_will_return_maybe_for_no_calls(void **state) 29 | { 30 | (void) state; 31 | 32 | will_return_maybe(mock_function, 32); 33 | } 34 | 35 | static void test_will_return_maybe_for_one_mock_call(void **state) 36 | { 37 | int value; 38 | 39 | (void) state; 40 | 41 | value = rand(); 42 | will_return_maybe(mock_function, value); 43 | mock_function_call_times(1u, value); 44 | } 45 | 46 | static void test_will_return_maybe_for_more_than_one_call(void **state) 47 | { 48 | int value; 49 | size_t numberOfCalls; 50 | (void)state; 51 | 52 | value = rand(); 53 | numberOfCalls = (size_t) ((rand()) % 20 + 2); 54 | will_return_maybe(mock_function, value); 55 | mock_function_call_times(numberOfCalls, value); 56 | } 57 | 58 | int main(int argc, char **argv) { 59 | const struct CMUnitTest alloc_tests[] = { 60 | cmocka_unit_test(test_will_return_maybe_for_no_calls) 61 | ,cmocka_unit_test(test_will_return_maybe_for_one_mock_call) 62 | ,cmocka_unit_test(test_will_return_maybe_for_more_than_one_call) 63 | }; 64 | 65 | (void)argc; 66 | (void)argv; 67 | 68 | return cmocka_run_group_tests(alloc_tests, NULL, NULL); 69 | } 70 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_returns_fail.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | int mock_function(void); 12 | void mock_function_call_times(size_t times, int expectedValue); 13 | 14 | int mock_function(void) 15 | { 16 | return (int) mock(); 17 | } 18 | 19 | void mock_function_call_times(size_t times, int expectedValue) 20 | { 21 | size_t i; 22 | for (i = 0u; i < times; ++i) 23 | { 24 | assert_int_equal(expectedValue, mock_function()); 25 | } 26 | } 27 | 28 | static void test_will_return_fails_for_no_calls(void **state) 29 | { 30 | (void) state; 31 | 32 | will_return(mock_function, 32); 33 | } 34 | 35 | static void test_will_return_count_fails_for_unreturned_items(void **state) 36 | { 37 | int value; 38 | size_t numberOfCalls; 39 | 40 | (void) state; 41 | 42 | value = rand(); 43 | numberOfCalls = (size_t) ((rand()) % 20 + 2); 44 | 45 | will_return_count(mock_function, value, numberOfCalls); 46 | mock_function_call_times(numberOfCalls - 1u, value); 47 | } 48 | 49 | static void test_will_return_always_fails_for_no_calls(void **state) 50 | { 51 | int value; 52 | 53 | (void) state; 54 | 55 | value = rand(); 56 | 57 | will_return_always(mock_function, value); 58 | } 59 | 60 | static int teardown(void **state) { 61 | free(*state); 62 | 63 | return 0; 64 | } 65 | 66 | int main(int argc, char **argv) { 67 | const struct CMUnitTest alloc_tests[] = { 68 | cmocka_unit_test_teardown(test_will_return_fails_for_no_calls, teardown) 69 | ,cmocka_unit_test_teardown(test_will_return_count_fails_for_unreturned_items, teardown) 70 | ,cmocka_unit_test_teardown(test_will_return_always_fails_for_no_calls, teardown) 71 | }; 72 | 73 | (void)argc; 74 | (void)argv; 75 | 76 | return cmocka_run_group_tests(alloc_tests, NULL, NULL); 77 | } 78 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_setup_fail.c: -------------------------------------------------------------------------------- 1 | #define UNIT_TESTING 1 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static int setup_fail(void **state) { 9 | *state = NULL; 10 | 11 | /* We need to fail in setup */ 12 | return -1; 13 | } 14 | 15 | static void int_test_ignored(void **state) { 16 | /* should not be called */ 17 | assert_non_null(*state); 18 | } 19 | 20 | static int setup_ok(void **state) { 21 | int *answer; 22 | 23 | answer = malloc(sizeof(int)); 24 | if (answer == NULL) { 25 | return -1; 26 | } 27 | *answer = 42; 28 | 29 | *state = answer; 30 | 31 | return 0; 32 | } 33 | 34 | /* A test case that does check if an int is equal. */ 35 | static void int_test_success(void **state) { 36 | int *answer = *state; 37 | 38 | assert_int_equal(*answer, 42); 39 | } 40 | 41 | static int teardown(void **state) { 42 | free(*state); 43 | 44 | return 0; 45 | } 46 | 47 | int main(void) { 48 | const struct CMUnitTest tests[] = { 49 | cmocka_unit_test_setup_teardown(int_test_ignored, setup_fail, teardown), 50 | cmocka_unit_test_setup_teardown(int_test_success, setup_ok, teardown), 51 | }; 52 | 53 | return cmocka_run_group_tests(tests, NULL, NULL); 54 | } 55 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_skip.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* A test case that does check if an int is equal. */ 23 | static void test_check_skip(void **state) { 24 | (void)state; /* unused */ 25 | 26 | skip(); 27 | 28 | assert_true(0); 29 | } 30 | 31 | 32 | int main(void) { 33 | const struct CMUnitTest tests[] = { 34 | cmocka_unit_test(test_check_skip), 35 | }; 36 | 37 | return cmocka_run_group_tests(tests, NULL, NULL); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_skip_filter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 by Red Hat, Inc. 3 | * 4 | * Author: Anderson Toshiyuki Sasaki 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | static void test_skip1(void **state) 25 | { 26 | (void)state; 27 | 28 | assert_true(1); 29 | } 30 | 31 | static void test_skip2(void **state) 32 | { 33 | (void)state; 34 | 35 | assert_false(1); 36 | } 37 | 38 | static void test_fail(void **state) 39 | { 40 | (void)state; 41 | 42 | assert_false(1); 43 | } 44 | 45 | int main(void) { 46 | const struct CMUnitTest tests[] = { 47 | cmocka_unit_test(test_skip1), 48 | cmocka_unit_test(test_skip2), 49 | cmocka_unit_test(test_fail), 50 | }; 51 | 52 | cmocka_set_test_filter("test_skip*"); 53 | 54 | cmocka_set_skip_filter("test_skip2"); 55 | 56 | return cmocka_run_group_tests(tests, NULL, NULL); 57 | } 58 | -------------------------------------------------------------------------------- /test/framework/cmocka/tests/test_wildcard.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Andreas Schneider 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | static void test_ok1(void **state) 23 | { 24 | (void)state; 25 | 26 | assert_true(1); 27 | } 28 | 29 | static void test_ok2(void **state) 30 | { 31 | (void)state; 32 | 33 | assert_true(1); 34 | } 35 | 36 | static void test_fail(void **state) 37 | { 38 | (void)state; 39 | 40 | assert_false(1); 41 | } 42 | 43 | int main(void) { 44 | const struct CMUnitTest tests[] = { 45 | cmocka_unit_test(test_ok1), 46 | cmocka_unit_test(test_ok2), 47 | cmocka_unit_test(test_fail), 48 | }; 49 | 50 | cmocka_set_test_filter("test_ok*"); 51 | 52 | return cmocka_run_group_tests(tests, NULL, NULL); 53 | } 54 | -------------------------------------------------------------------------------- /tools/manual_onboarding/res/DevWS_device_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/DevWS_device_profile.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/DevWS_device_serial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/DevWS_device_serial.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/manual_onboarding_choose_device_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/manual_onboarding_choose_device_profile.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/manual_onboarding_choose_location_room.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/manual_onboarding_choose_location_room.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/manual_onboarding_enter_PAT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/manual_onboarding_enter_PAT.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/manual_onboarding_enter_label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/manual_onboarding_enter_label.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/manual_onboarding_enter_serial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/manual_onboarding_enter_serial.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/manual_onboarding_register_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/manual_onboarding_register_result.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/manual_onboarding_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/manual_onboarding_result.png -------------------------------------------------------------------------------- /tools/manual_onboarding/res/manual_onboarding_review_register_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmartThingsCommunity/st-device-sdk-c/87d9bfdd11959e7ed98432572573e6732c97873f/tools/manual_onboarding/res/manual_onboarding_review_register_info.png -------------------------------------------------------------------------------- /tools/qrgen/README.md: -------------------------------------------------------------------------------- 1 | # QR generation tools for Individual and Commercial 2 | 3 | [![License](https://img.shields.io/badge/licence-Apache%202.0-brightgreen.svg?style=flat)](LICENSE) 4 | 5 | ## Summary 6 | 7 | This repository provides a tool to generate QR codes for ST devices. 8 | 9 | ## Prerequisites 10 | 11 | Install qrcode python package 12 | ```sh 13 | pip install qrcode --user 14 | ``` 15 | or for Ubuntu 16 | ```sh 17 | sudo apt-get install python3-qrcode 18 | ``` 19 | 20 | ## Usage 21 | 22 | ```sh 23 | stdk-qrgen.py [-h] [--folder FOLDER] 24 | 25 | --folder FOLDER Folder containing onboarding_config.json and device_info.json (if not supplied uses current folder) 26 | ``` 27 | --------------------------------------------------------------------------------