├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Cartfile
├── Cartfile.resolved
├── LICENSE
├── README.md
├── SECURITY.md
├── SmarTAG.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcuserdata
│ └── giovannivisentini.xcuserdatad
│ └── xcschemes
│ └── xcschememanagement.plist
├── SmarTAG
├── AppDelegate.swift
├── Base.lproj
│ └── Main.storyboard
├── Extreme
│ ├── Extreme.storyboard
│ ├── SmarTagExtremeDataViewCell.swift
│ └── SmarTagExtremeDataViewController.swift
├── Info.plist
├── Model
│ ├── Configuration.swift
│ ├── DateExtreme.swift
│ ├── SensorSample.swift
│ └── Version.swift
├── STTheme.swift
├── Settings
│ ├── CloseKeyboardOnReturn.swift
│ ├── Settings.storyboard
│ ├── SmarTagAccelerationSettingCell.swift
│ ├── SmarTagAccelerometerSettingsView.swift
│ ├── SmarTagAccelerometerSettingsView.xib
│ ├── SmarTagSensorSettingCell.swift
│ ├── SmarTagSensorSettingsView.swift
│ ├── SmarTagSensorSettingsView.xib
│ ├── SmarTagSettingsViewController.swift
│ ├── SmarTagSettingsWriterNFCSession.swift
│ ├── SmarTagThresholdSensorCell.swift
│ └── String+floatOrNil.swift
├── ShowData
│ ├── ShowData.storyboard
│ ├── SmarTagEventSampleViewController.swift
│ ├── SmarTagSensorDetailsViewController.swift
│ ├── SmarTagSensorSampleViewCell.swift
│ ├── SmarTagSensorSampleViewController.swift
│ └── SmarTagShowDataPageViewController.swift
├── SingleShot
│ ├── SmarTagSignleShot.storyboard
│ └── SmarTagSignleShotViewController.swift
├── SmarTAG.entitlements
├── SmarTAGReadNdefViewController.swift
├── SmarTag
│ ├── SmarTagCSVFileExporter.swift
│ ├── SmarTagNDefParserProtocol.swift
│ ├── SmarTagNDefParserProtocolFake.swift
│ └── SmarTagNDefParserV1.swift
├── SmarTagAboutViewController.swift
├── SmarTagContentViewController.swift
├── SmarTagIOISO15693.swift
├── SmarTagMainViewController.swift
├── StarTagObjectWithTag.swift
├── Util
│ ├── SmarTagSensorName.swift
│ └── UIViewControllerExt.swift
├── about.html
├── images.xcassets
│ ├── Contents.json
│ ├── menu_icon.imageset
│ │ ├── Contents.json
│ │ └── demo_menu_icon.pdf
│ └── settings_icon.imageset
│ │ ├── Contents.json
│ │ └── settings_icon.pdf
├── images_svg
│ ├── alert-circle-outline.svg
│ ├── settings.svg
│ └── show_data.svg
├── st_images.xcassets
│ ├── AboutButton.imageset
│ │ ├── AboutButton.pdf
│ │ └── Contents.json
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon-167.png
│ │ ├── Icon-20.png
│ │ ├── Icon-60.png
│ │ ├── Icon-60@2x.png
│ │ ├── Icon-60@3x.png
│ │ ├── Icon-76.png
│ │ ├── Icon-76@2x.png
│ │ ├── Icon-Small-40.png
│ │ ├── Icon-Small-40@2x-1.png
│ │ ├── Icon-Small-40@2x.png
│ │ ├── Icon-Small-40@3x.png
│ │ ├── Icon-Small-41.png
│ │ ├── Icon-Small-42.png
│ │ ├── Icon-Small.png
│ │ ├── Icon-Small@2x-1.png
│ │ ├── Icon-Small@2x.png
│ │ ├── Icon-Small@3x.png
│ │ └── iTunesArtwork@2x.png
│ ├── Contents.json
│ ├── HarverstingButton.imageset
│ │ ├── Contents.json
│ │ └── HarverstingButton.pdf
│ ├── SearchButton.imageset
│ │ ├── Contents.json
│ │ ├── ST_SmarTag_search_button_icon.pdf
│ │ └── SearchButton.pdf
│ ├── about_header.imageset
│ │ ├── Contents.json
│ │ └── st25Nfc.pdf
│ ├── alert_circle.imageset
│ │ ├── Contents.json
│ │ └── alert_circle.pdf
│ ├── event_doubleTap.imageset
│ │ ├── Contents.json
│ │ └── event_doubleTap.pdf
│ ├── event_freefall.imageset
│ │ ├── Contents.json
│ │ └── event_freefall.pdf
│ ├── event_orientation.imageset
│ │ ├── Contents.json
│ │ └── event_orientation.pdf
│ ├── event_singleTap.imageset
│ │ ├── Contents.json
│ │ └── event_singleTap.pdf
│ ├── event_tilt.imageset
│ │ ├── Contents.json
│ │ └── event_tilt.pdf
│ ├── event_wakeUp.imageset
│ │ ├── Contents.json
│ │ └── event_wakeUp.pdf
│ ├── humidity_icon.imageset
│ │ ├── Contents.json
│ │ └── humidity_icon.pdf
│ ├── orientation_bottom_left.imageset
│ │ ├── Contents.json
│ │ └── orientation_bottom_left.pdf
│ ├── orientation_bottom_right.imageset
│ │ ├── Contents.json
│ │ └── orientation_bottom_right.pdf
│ ├── orientation_down.imageset
│ │ ├── Contents.json
│ │ └── orientation_down.pdf
│ ├── orientation_top_left.imageset
│ │ ├── Contents.json
│ │ └── orientation_top_left.pdf
│ ├── orientation_top_right.imageset
│ │ ├── Contents.json
│ │ └── orientation_top_right.pdf
│ ├── orientation_up.imageset
│ │ ├── Contents.json
│ │ └── orientation_up.pdf
│ ├── pressure_icon.imageset
│ │ ├── Contents.json
│ │ └── pressure_icon.pdf
│ ├── show_data.imageset
│ │ ├── Contents.json
│ │ └── show_data.pdf
│ ├── st_accent.colorset
│ │ └── Contents.json
│ ├── st_primary.colorset
│ │ └── Contents.json
│ ├── temperature_icon.imageset
│ │ ├── Contents.json
│ │ └── temperature_icon.pdf
│ └── vibration_icon.imageset
│ │ ├── Contents.json
│ │ └── vibration_icon.pdf
├── st_images_LanchScreen.xcassets
│ ├── Contents.json
│ └── LaunchImage.launchimage
│ │ ├── Contents.json
│ │ ├── Launch_images_iPH6Plus_1242 x 2208 (@3x)_portrait.png
│ │ ├── Launch_images_iPH6Plus_2208 x 1242 (@3x)_landscape.png
│ │ ├── Launch_images_iPH6_750x1334_portrait.png
│ │ ├── Launch_images_iPH_640 x 1136 (@2x)_portrait.png
│ │ ├── Launch_images_iPH_640x960-(@2x)_portrait.png
│ │ └── STLogo.png
└── st_images_svg
│ ├── AboutButton.svg
│ ├── DiscoveryButton.svg
│ ├── SearchButton.svg
│ ├── acc_event_free_fall.svg
│ ├── acc_event_orientation_bottom_left.svg
│ ├── acc_event_orientation_bottom_right.svg
│ ├── acc_event_orientation_down.svg
│ ├── acc_event_orientation_top_left.svg
│ ├── acc_event_orientation_top_right.svg
│ ├── acc_event_orientation_up.svg
│ ├── acc_event_tap_double.svg
│ ├── acc_event_tap_single.svg
│ ├── acc_event_tilt.svg
│ ├── acc_event_wake_up.svg
│ ├── event_orientation.svg
│ ├── humidity_icon.svg
│ ├── pressure_icon.svg
│ ├── st25_nfc.svg
│ ├── temperature_icon.svg
│ └── vibration_icon.svg
├── SmarTAGTests
├── Info.plist
└── SmarTagNDefParserV1Tests.swift
├── SmarTAGUITests
├── Info.plist
└── SmarTAGUITests.swift
├── SmarTagCloudLib
├── SmarTagCloudLib.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── SmarTagCloudLib
│ ├── Config
│ ├── SmarTagCloudConfigViewController.storyboard
│ ├── SmarTagCloudConfigViewController.swift
│ └── storage
│ │ ├── CloudConfigStorageUserSettings.swift
│ │ └── SmarTagCloudConfig.swift
│ ├── Info.plist
│ ├── SmarTagCloudExported.swift
│ ├── SmarTagCloudLib.h
│ └── SmarTagLocationService.swift
├── SmarTagCloudLibCommon
├── SmarTagCloudLibCommon.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── SmarTagCloudLibCommon
│ ├── CloudSyncProvider.swift
│ ├── Info.plist
│ ├── Model
│ ├── DataExtreme+json.swift
│ ├── Date+json.swift
│ ├── Location+json.swift
│ └── SensorSample+json.swift
│ └── SmarTagCloudLibCommon.h
├── SmarTagCloudLibMqtt
├── SmarTagCloudLibMqtt.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── SmarTagCloudLibMqtt
│ ├── Info.plist
│ ├── MqttProvider.swift
│ ├── SmarTagCloudLibMqtt.h
│ └── configViewController
│ ├── MQTTParameterSettings.storyboard
│ ├── MQTTParametersViewController.swift
│ ├── MqttConfigStorage.swift
│ ├── MqttConfigStorageKeychain.swift
│ └── MqttConfigStorageUserSettings.swift
├── SmarTagLib
├── SmarTagLib.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── SmarTagLib
│ ├── Info.plist
│ ├── Model
│ ├── Configuration.swift
│ ├── DateExtreme.swift
│ ├── SensorSample.swift
│ ├── SmarTagStatus.swift
│ └── Version.swift
│ ├── NDEFHeader.swift
│ ├── SmarTagCSVFileExporter.swift
│ ├── SmarTagData.swift
│ ├── SmarTagIOError+String.swift
│ ├── SmarTagIOProtocol.swift
│ ├── SmarTagLib.h
│ ├── SmarTagNDefParserProtocolFake.swift
│ ├── SmarTagSensorName.swift
│ ├── SmarTagV1ISO15693Parser.swift
│ ├── SmarTagV1NDefParser.swift
│ └── SmarTagV1Parser.swift
├── buildDep.sh
└── makeReleaseZip.sh
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/xcode,swift,macos,carthage
3 |
4 | ### Carthage ###
5 | # Carthage
6 | #
7 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
8 | Carthage/Checkouts
9 | Carthage/Build
10 |
11 | ### macOS ###
12 | *.DS_Store
13 | .AppleDouble
14 | .LSOverride
15 |
16 | # Icon must end with two \r
17 | Icon
18 |
19 | # Thumbnails
20 | ._*
21 |
22 | # Files that might appear in the root of a volume
23 | .DocumentRevisions-V100
24 | .fseventsd
25 | .Spotlight-V100
26 | .TemporaryItems
27 | .Trashes
28 | .VolumeIcon.icns
29 | .com.apple.timemachine.donotpresent
30 |
31 | # Directories potentially created on remote AFP share
32 | .AppleDB
33 | .AppleDesktop
34 | Network Trash Folder
35 | Temporary Items
36 | .apdisk
37 |
38 | ### Swift ###
39 | # Xcode
40 | #
41 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
42 |
43 | ## Build generated
44 | build/
45 | DerivedData/
46 |
47 | ## Various settings
48 | *.pbxuser
49 | !default.pbxuser
50 | *.mode1v3
51 | !default.mode1v3
52 | *.mode2v3
53 | !default.mode2v3
54 | *.perspectivev3
55 | !default.perspectivev3
56 | xcuserdata/
57 |
58 | ## Other
59 | *.moved-aside
60 | *.xccheckout
61 | *.xcscmblueprint
62 |
63 | ## Obj-C/Swift specific
64 | *.hmap
65 | *.ipa
66 | *.dSYM.zip
67 | *.dSYM
68 |
69 | ## Playgrounds
70 | timeline.xctimeline
71 | playground.xcworkspace
72 |
73 | # Swift Package Manager
74 | #
75 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
76 | # Packages/
77 | # Package.pins
78 | .build/
79 |
80 | # CocoaPods - Refactored to standalone file
81 |
82 | # Carthage - Refactored to standalone file
83 |
84 | # fastlane
85 | #
86 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
87 | # screenshots whenever they are needed.
88 | # For more information about the recommended setup visit:
89 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
90 |
91 | fastlane/report.xml
92 | fastlane/Preview.html
93 | fastlane/screenshots
94 | fastlane/test_output
95 |
96 | ### Xcode ###
97 | # Xcode
98 | #
99 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
100 |
101 | ## Build generated
102 |
103 | ## Various settings
104 |
105 | ## Other
106 |
107 | ### Xcode Patch ###
108 | *.xcodeproj/*
109 | !*.xcodeproj/project.pbxproj
110 | !*.xcodeproj/xcshareddata/
111 | !*.xcworkspace/contents.xcworkspacedata
112 | /*.gcno
113 |
114 |
115 | # End of https://www.gitignore.io/api/xcode,swift,macos,carthage
116 |
117 | SmarTagCloudLib/Carthage/
118 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team via this [link](https://www.st.com/content/st_com/en/contact-us.html).
59 | All complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4,
71 | available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
72 |
73 | For answers to common questions about this code of conduct, see the [FAQ section](https://www.contributor-covenant.org/faq).
74 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing guide
2 |
3 | This document serves as a checklist before contributing to this repository. It includes links to read up on if topics are unclear to you.
4 |
5 | This guide mainly focuses on the proper use of Git.
6 |
7 | ## 1. Issues
8 |
9 | To report a bug/request please file an issue in the Issues tab of the repository
10 |
11 |
12 | ## 2. Pull Requests
13 |
14 | STMicroelectronics is happy to receive contributions from the community, based on an initial Contributor License Agreement (CLA) procedure.
15 |
16 | * If you are an individual writing original source code and you are sure you own the intellectual property, then you need to sign an Individual CLA (https://cla.st.com).
17 | * If you work for a company that wants also to allow you to contribute your work, your company needs to provide a Corporate CLA (https://cla.st.com) mentioning your GitHub account name.
18 | * If you’re not sure that a CLA (Individual or Corporate) has been signed for your GitHub account you can check here (https://cla.st.com). Please note that Corporate CLA will always take precedence over Individual CLA.
19 |
20 |
21 | Please note that:
22 |
23 | * The Corporate CLA will always take precedence over the Individual CLA.
24 | * One CLA submission is sufficient for any project proposed by STMicroelectronics.
25 |
26 | __How to proceed__
27 |
28 | * We recommend to engage first a communication thru an Issue, in order to present your proposal. Just to confirm that it correspond to STMicroelectronics domain or scope.
29 | * Then fork the project in your GitHub account to further develop your contribution. Please use the latest commit version.
30 | * Please, submit one Pull Request for one new feature or proposal. This will ease the analysis and final merge if accepted
31 |
32 |
--------------------------------------------------------------------------------
/Cartfile:
--------------------------------------------------------------------------------
1 | github "danielgindi/Charts" ~> 3.4.0
2 | github "scalessec/Toast-Swift" ~> 5.0.0
3 | github "emqtt/CocoaMQTT" ~> 1.2
4 | github "SwiftyJSON/SwiftyJSON" ~> 5.0
5 | github "kishikawakatsumi/KeychainAccess" ~> 4.1.0
6 |
--------------------------------------------------------------------------------
/Cartfile.resolved:
--------------------------------------------------------------------------------
1 | github "SwiftyJSON/SwiftyJSON" "5.0.0"
2 | github "danielgindi/Charts" "v3.4.0"
3 | github "emqtt/CocoaMQTT" "1.2.5"
4 | github "kishikawakatsumi/KeychainAccess" "v4.1.0"
5 | github "robbiehanson/CocoaAsyncSocket" "7.6.3"
6 | github "scalessec/Toast-Swift" "5.0.1"
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 STMicroelectronics – All rights reserved
2 | The STMicroelectronics corporate logo is a trademark of STMicroelectronics
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | - Redistributions of source code must retain the above copyright notice, this list of conditions
8 | and the following disclaimer.
9 |
10 | - Redistributions in binary form must reproduce the above copyright notice, this list of
11 | conditions and the following disclaimer in the documentation and/or other materials provided
12 | with the distribution.
13 |
14 | - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
15 | STMicroelectronics company nor the names of its contributors may be used to endorse or
16 | promote products derived from this software without specific prior written permission.
17 |
18 | - All of the icons, pictures, logos and other images that are provided with the source code
19 | in a directory whose title begins with st_images may only be used for internal purposes and
20 | shall not be redistributed to any third party or modified in any way.
21 |
22 | - Any redistributions in binary form shall not include the capability to display any of the
23 | icons, pictures, logos and other images that are provided with the source code in a directory
24 | whose title begins with st_images.
25 |
26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
27 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
28 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
29 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
34 | OF SUCH DAMAGE.
35 |
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ST NFC Sensor
2 |
3 | This repository contains the ST NFC Sensor app source code.
4 |
5 | The ST NFC Sensor application, available for [iOS](https://itunes.apple.com/us/app/st-nfc-sensor/id1377274569?mt=8) and [Android](https://play.google.com/store/apps/details?id=com.st.smartTag), shows the data exported by sensor nodes via the NFC protocol.
6 |
7 | It allows you to configure and read data from any system running the [FP-SNS-SMARTAG1](http://www.st.com/en/product/fp-sns-smartag1) function pack (for example, the [STEVAL-SMARTAG1](http://www.st.com/en/product/steval-smartag1) evaluation board).
8 |
9 | You can configure the app by choosing the sampling intervals, the sensor data logged and the conditions to trigger data logging.
10 |
11 | After configuration, the app shows data in informative plots, identifies significant events, such as high acceleration and changes in orientation, and exports data to a
12 | csv file.
13 |
14 | The embedded [ST25DV](http://www.st.com/st25dv) series Dynamic NFC Tag energy harvesting feature allows
15 | using the [STEVAL-SMARTAG1](http://www.st.com/en/product/steval-smartag1) without a battery and reading sensor data in one shot
16 | mode.
17 |
18 |
19 | ## Download the source
20 | Run the command:
21 | ```Shell
22 | git clone https://github.com/STMicroelectronics/STNFCSensor_iOS
23 | ```
24 |
25 | ## Compile the project
26 | The project use [Carthage](https://github.com/Carthage/Carthage) to manage the library dependency.
27 |
28 | To install Carthage follow [this instrunction](https://github.com/Carthage/Carthage#installing-carthage)
29 |
30 | And before build the project run:
31 | ```Shell
32 | carthage bootstrap --platform iOS
33 | ```
34 |
35 | to downloand and build the project dependency
36 |
37 | ## License
38 |
39 | Copyright (c) 2018 STMicroelectronics – All rights reserved
40 | The STMicroelectronics corporate logo is a trademark of STMicroelectronics
41 |
42 | Redistribution and use in source and binary forms, with or without modification,
43 | are permitted provided that the following conditions are met:
44 |
45 | - Redistributions of source code must retain the above copyright notice, this list of conditions
46 | and the following disclaimer.
47 |
48 | - Redistributions in binary form must reproduce the above copyright notice, this list of
49 | conditions and the following disclaimer in the documentation and/or other materials provided
50 | with the distribution.
51 |
52 | - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
53 | STMicroelectronics company nor the names of its contributors may be used to endorse or
54 | promote products derived from this software without specific prior written permission.
55 |
56 | - All of the icons, pictures, logos and other images that are provided with the source code
57 | in a directory whose title begins with st_images may only be used for internal purposes and
58 | shall not be redistributed to any third party or modified in any way.
59 |
60 | - Any redistributions in binary form shall not include the capability to display any of the
61 | icons, pictures, logos and other images that are provided with the source code in a directory
62 | whose title begins with st_images.
63 |
64 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
65 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
66 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
67 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
68 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
69 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
70 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
71 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
72 | OF SUCH DAMAGE.
73 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Report potential product security vulnerabilities
2 |
3 | ST places a high priority on security, and our Product Security Incident Response Team (PSIRT) is committed to rapidly addressing potential security vulnerabilities affecting our products. PSIRT's long history and vast experience in security allows ST to perform clear analyses and provide appropriate guidance on mitigations and solutions when applicable.
4 |
5 | If you wish to report potential security vulnerabilities regarding our products, **please do not report them through public GitHub issues.** Instead, we encourage you to report them to our ST PSIRT following the process described at: **https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
6 |
7 |
8 |
9 | ### IMPORTANT - READ CAREFULLY:
10 |
11 | STMicroelectronics International N.V., on behalf of itself, its affiliates and subsidiaries, (collectively “ST”) takes all potential security vulnerability reports or other related communications (“Report(s)”) seriously. In order to review Your Report (the terms “You” and “Yours” include your employer, and all affiliates, subsidiaries and related persons or entities) and take actions as deemed appropriate, ST requires that we have the rights and Your permission to do so.
12 |
13 | As such, by submitting Your Report to ST, You agree that You have the right to do so, and You grant to ST the rights to use the Report for purposes related to security vulnerability analysis, testing, correction, patching, reporting and any other related purpose or function.
14 |
15 | By submitting Your Report, You agree that ST’s [Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html) applies to all related communications.
16 |
--------------------------------------------------------------------------------
/SmarTAG.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SmarTAG.xcodeproj/xcuserdata/giovannivisentini.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | SmarTAG.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 | SmarTAG.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 0
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | 6608E835201B3819006AB010
21 |
22 | primary
23 |
24 |
25 | 6608E84B201B381A006AB010
26 |
27 | primary
28 |
29 |
30 | 6608E856201B381A006AB010
31 |
32 | primary
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/SmarTAG/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 | import UIKit
38 |
39 | @UIApplicationMain
40 | class AppDelegate: UIResponder, UIApplicationDelegate {
41 |
42 | var window: UIWindow?
43 |
44 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
45 |
46 | STTheme.applayAll()
47 |
48 | return true
49 | }
50 |
51 | func applicationWillResignActive(_ application: UIApplication) {
52 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
53 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
54 | }
55 |
56 | func applicationDidEnterBackground(_ application: UIApplication) {
57 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
58 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
59 | }
60 |
61 | func applicationWillEnterForeground(_ application: UIApplication) {
62 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
63 | }
64 |
65 | func applicationDidBecomeActive(_ application: UIApplication) {
66 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
67 | }
68 |
69 | func applicationWillTerminate(_ application: UIApplication) {
70 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
71 | }
72 |
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/SmarTAG/Extreme/SmarTagExtremeDataViewCell.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 | import UIKit
40 | import SmarTagLib
41 |
42 | class SmarTagExtremeDataViewCell : UITableViewCell{
43 |
44 | public struct Data{
45 | let name :String
46 | let icon :UIImage
47 | let dataFormat:String
48 | let extremes:DataExtreme
49 | }
50 |
51 |
52 | @IBOutlet weak var mIcon: UIImageView!
53 |
54 | @IBOutlet weak var mSensorName: UILabel!
55 | @IBOutlet weak var mMaxDateLablel: UILabel!
56 | @IBOutlet weak var mMaxValueLabel: UILabel!
57 | @IBOutlet weak var mMinValueLabel: UILabel!
58 | @IBOutlet weak var mMinDateLabel: UILabel!
59 | @IBOutlet weak var mMinView: UIView!
60 | @IBOutlet weak var mMaxView: UIView!
61 |
62 |
63 | public func setData(_ data:Data){
64 | mIcon.image = data.icon
65 | mSensorName.text = data.name
66 |
67 | if let max = data.extremes.maxValue,
68 | let maxDate = data.extremes.maxDate{
69 | mMaxValueLabel.text = String(format: data.dataFormat, max)
70 | mMaxDateLablel.text = SmarTagExtremeDataViewCell.DATE_FORMAT.string(for: maxDate)
71 |
72 | mMaxView.isHidden=false;
73 | }else{
74 | mMaxView.isHidden=true;
75 | }
76 |
77 | if let min = data.extremes.minValue,
78 | let minDate = data.extremes.minDate{
79 | mMinValueLabel.text = String(format: data.dataFormat, min)
80 | mMinDateLabel.text = SmarTagExtremeDataViewCell.DATE_FORMAT.string(for: minDate)
81 | mMinView.isHidden=false;
82 | }else{
83 | mMinView.isHidden=true;
84 | }
85 | }
86 |
87 | static let DATE_FORMAT : DateFormatter = {
88 | let formatter = DateFormatter();
89 | formatter.dateFormat = "HH:mm:ss dd/MMM"
90 | return formatter;
91 | }();
92 | }
93 |
--------------------------------------------------------------------------------
/SmarTAG/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | ST NFC Sensor
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(MARKETING_VERSION)
21 | CFBundleURLTypes
22 |
23 |
24 | CFBundleURLSchemes
25 |
26 | STNFCSensor
27 |
28 |
29 |
30 | CFBundleVersion
31 | $(CURRENT_PROJECT_VERSION)
32 | LSRequiresIPhoneOS
33 |
34 | NFCReaderUsageDescription
35 | NFC is needed to read the SmarTAG contents
36 | NSLocationWhenInUseUsageDescription
37 | Required to send the current tag position
38 | UIMainStoryboardFile
39 | Main
40 | UIRequiredDeviceCapabilities
41 |
42 | armv7
43 |
44 | UIRequiresFullScreen
45 |
46 | UIStatusBarTintParameters
47 |
48 | UINavigationBar
49 |
50 | Style
51 | UIBarStyleDefault
52 | Translucent
53 |
54 |
55 |
56 | UISupportedInterfaceOrientations
57 |
58 | UIInterfaceOrientationPortrait
59 | UIInterfaceOrientationLandscapeLeft
60 | UIInterfaceOrientationLandscapeRight
61 |
62 | UISupportedInterfaceOrientations~ipad
63 |
64 | UIInterfaceOrientationPortrait
65 | UIInterfaceOrientationPortraitUpsideDown
66 | UIInterfaceOrientationLandscapeLeft
67 | UIInterfaceOrientationLandscapeRight
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/SmarTAG/Model/Configuration.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 | import Foundation
38 |
39 | public struct Configuration{
40 |
41 | public enum SamplingMode:UInt8{
42 | case Inactive=0x00
43 | case Sampling=0x01
44 | case SingleShot=0x02
45 | case SamplingWithThreshold = 0x03
46 | case StoreNextSample = 0x04
47 | }
48 |
49 | public let samplingInterval_s:UInt16
50 | public let mode:SamplingMode
51 | public let temperatureConf:SensorConfiguration
52 | public let humidityConf:SensorConfiguration
53 | public let pressureConf:SensorConfiguration
54 | public let accelerometerConf:SensorConfiguration
55 | public let orientationConf:SensorConfiguration
56 | public let wakeUpConf:SensorConfiguration
57 |
58 |
59 | init(samplingInteval:UInt16,mode:SamplingMode,
60 | temperatureConf:SensorConfiguration,
61 | humidityConf:SensorConfiguration,
62 | pressureConf:SensorConfiguration,
63 | accelerometerConf:SensorConfiguration,
64 | orientationConf:SensorConfiguration,
65 | wakeUpConf:SensorConfiguration
66 | ) {
67 | samplingInterval_s = samplingInteval;
68 | self.mode = mode;
69 | self.temperatureConf = temperatureConf
70 | self.humidityConf = humidityConf
71 | self.pressureConf = pressureConf
72 | self.accelerometerConf = accelerometerConf
73 | self.orientationConf = orientationConf
74 | self.wakeUpConf = wakeUpConf
75 | }
76 | }
77 |
78 | public struct Threshold{
79 | public let max:Float?
80 | public let min:Float?
81 |
82 | init(max:Float?,min:Float?) {
83 | self.max = max;
84 | self.min = min;
85 | }
86 | }
87 |
88 | public struct SensorConfiguration{
89 | public let isEnable:Bool
90 | public let threshold:Threshold
91 |
92 | init(isEnable:Bool, threshold:Threshold) {
93 | self.isEnable=isEnable
94 | self.threshold = threshold
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/SmarTAG/Model/DateExtreme.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 |
40 | public struct DataExtreme{
41 | public let minDate:Date?
42 | public let minValue:Float?
43 | public let maxDate:Date?
44 | public let maxValue:Float?
45 |
46 | init(maxDate:Date?,maxValue:Float?,minDate:Date?,minValue:Float?) {
47 | self.maxDate = maxDate
48 | self.maxValue = maxValue
49 | self.minDate = minDate
50 | self.minValue = minValue
51 | }
52 |
53 | }
54 |
55 | public struct TagExtreme{
56 | public let acquisitionStart:Date
57 | public let temperature:DataExtreme?
58 | public let pressure:DataExtreme?
59 | public let humidity:DataExtreme?
60 | public let acceleration:DataExtreme?
61 |
62 | init(acquisitionStart:Date, temperature:DataExtreme?,
63 | pressure:DataExtreme?, humidity:DataExtreme?, acceleration:DataExtreme?) {
64 | self.acquisitionStart = acquisitionStart
65 | self.temperature = temperature
66 | self.pressure = pressure
67 | self.humidity = humidity
68 | self.acceleration = acceleration
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/SmarTAG/Model/SensorSample.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 |
40 | public enum AccelerationEvent : UInt8 {
41 | case wakeUp = 0x01
42 | case orientation = 0x02
43 | case singleTap = 0x04
44 | case doubleTap = 0x08
45 | case freeFall = 0x10
46 | case tilt = 0x20
47 |
48 | }
49 |
50 | extension UInt8 {
51 | public func toAccelerationEvents()->[AccelerationEvent]{
52 | var events:[AccelerationEvent] = [];
53 | for i in 0...7 {
54 | let mask = UInt8(1<Orientation{
76 | return Orientation(rawValue:self) ?? .unknown;
77 | }
78 | }
79 |
80 | public struct EventDataSample{
81 | public let date:Date
82 | public let acceleration:Float?
83 | public let accelerationEvents:[AccelerationEvent]
84 | public let currentOrientation:Orientation
85 | }
86 |
87 | public struct SensorDataSample{
88 | public let date:Date
89 | public let temperature:Float?
90 | public let humidity:Float?
91 | public let pressure:Float?
92 | public let acceleration:Float?
93 |
94 | init(date:Date,temperature:Float?, humidity:Float?, pressure:Float?, acceleration:Float?) {
95 | self.date = date
96 | self.temperature = temperature
97 | self.humidity = humidity
98 | self.pressure = pressure
99 | self.acceleration = acceleration
100 | }
101 | }
102 |
103 | public enum DataSample{
104 | case sensor(data:SensorDataSample)
105 | case event(data:EventDataSample)
106 | }
107 |
--------------------------------------------------------------------------------
/SmarTAG/Model/Version.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 | import Foundation
38 |
39 | public struct Version{
40 | public let majour:UInt8
41 | public let minor:UInt8
42 | public let patch:UInt8
43 |
44 | init(majour:UInt8,minor:UInt8,patch:UInt8){
45 | self.majour = majour;
46 | self.minor = minor;
47 | self.patch = patch;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/SmarTAG/STTheme.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 | import Foundation
38 |
39 | import UIKit
40 |
41 | class STTheme{
42 |
43 | //0x39A9DC
44 | static let primaryColor = UIColor(red: 0x39/255.0, green: 0xA9/255.0, blue: 0xDC/255.0, alpha: 1.0)
45 | //0x002052
46 | static let primaryDarkColor = UIColor(red: 0x00/255.0, green: 0x20/255.0, blue: 0x52/255.0, alpha: 1.0)
47 | //D4007A
48 | static let accentColor = UIColor(red: 0xD4/255.0, green: 0x00/255.0, blue: 0x7A/255.0, alpha: 1.0)
49 |
50 | static func applayAll(){
51 | applyUINavigatorBarTheme(UINavigationBar.appearance())
52 | applyTabBarTheme(UITabBar.appearance())
53 | applyButtonTheme(UIButton.appearance())
54 | }
55 |
56 | public static func applyUINavigatorBarTheme(_ navigatiorBar: UINavigationBar){
57 | navigatiorBar.barTintColor = primaryColor
58 | navigatiorBar.tintColor = primaryDarkColor
59 |
60 | navigatiorBar.titleTextAttributes = [
61 | .foregroundColor : [primaryColor]
62 | ]
63 |
64 | let navigationBarButton = UIButton.appearance(whenContainedInInstancesOf: [UINavigationBar.self] )
65 | navigationBarButton.tintColor = primaryDarkColor
66 | navigationBarButton.setTitleColor(primaryDarkColor, for: .normal)
67 | }
68 |
69 | public static func applyTabBarTheme(_ tabBar: UITabBar){
70 | tabBar.barTintColor = primaryColor
71 | tabBar.tintColor = primaryDarkColor
72 | tabBar.unselectedItemTintColor = UIColor.white
73 | }
74 |
75 | public static func applyButtonTheme(_ button: UIButton ){
76 | button.tintColor = accentColor
77 | button.setTitleColor(accentColor, for: .normal)
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/SmarTAG/Settings/CloseKeyboardOnReturn.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 | import UIKit
40 |
41 | internal class CloseKeyboardOnReturn : NSObject, UITextFieldDelegate{
42 |
43 | public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
44 | textField.resignFirstResponder()
45 | return false
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/SmarTAG/Settings/SmarTagAccelerationSettingCell.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 | import UIKit
40 | import SmarTagLib
41 |
42 | class SmarTagAccelerationSettingCell : SmarTagThresholdSensorCell{
43 |
44 | public struct Data : SmarTagThresholdSensorCellData{
45 | public let name: String
46 | public let unit: String
47 | public let dataFormat: String
48 | public let image: UIImage
49 | public let sensorConf: SensorConfiguration
50 | public let orientationEnabled:Bool
51 | public let wakeUpEnabled:Bool
52 | }
53 |
54 | @IBOutlet weak var mWakeUpSwitch: UISwitch!
55 | @IBOutlet weak var mOrientaitonSwitch: UISwitch!
56 | @IBOutlet weak var mOrientationView: UIView!
57 | @IBOutlet weak var mWakeUpView: UIView!
58 |
59 | public func setData(data:SmarTagAccelerationSettingCell.Data, isEditable:Bool){
60 | super.setData(data: data,isEditable: isEditable)
61 | mOrientaitonSwitch.isOn = data.orientationEnabled
62 | mOrientaitonSwitch.isEnabled = isEditable
63 | mWakeUpSwitch.isOn = data.wakeUpEnabled
64 | mWakeUpSwitch.isEnabled = isEditable
65 | }
66 |
67 | public override func hideThreshold(_ isHide:Bool){
68 | super.hideThreshold(isHide)
69 | mOrientationView.isHidden = isHide
70 | mWakeUpView.isHidden = isHide
71 | }
72 |
73 | @IBAction func onOrientationEnableStatusChange(switch:UISwitch){
74 | onSettingsChange?(self)
75 | }
76 |
77 | @IBAction func onWakeUpEnableStatusChange(switch:UISwitch){
78 | onSettingsChange?(self)
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/SmarTAG/Settings/SmarTagSensorSettingCell.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 | import UIKit
40 | import SmarTagLib
41 |
42 | class SmarTagSensorSettingCell : SmarTagThresholdSensorCell{
43 |
44 | @IBOutlet weak var mMinView: UIStackView!
45 | @IBOutlet weak var mMinThText: UITextField!
46 | @IBOutlet weak var mMinUnitText: UILabel!
47 |
48 | public struct Data: SmarTagThresholdSensorCellData{
49 | public let name: String
50 | public let unit: String
51 | public let dataFormat: String
52 | public let image: UIImage
53 | public let sensorConf: SensorConfiguration
54 | }
55 |
56 | public func setData(data:SmarTagSensorSettingCell.Data, isEditable:Bool){
57 | super.setData(data:data,isEditable: isEditable)
58 | mMinUnitText.text = data.unit
59 | if let min = data.sensorConf.threshold.min{
60 | mMinThText.text=String(format: data.dataFormat, min)
61 | mMinThText.isEnabled = isEditable
62 | }else{
63 | mMinView.isHidden=true
64 | }
65 | }
66 |
67 | public override func hideThreshold(_ isHide:Bool){
68 | super.hideThreshold(isHide)
69 | mMinView.isHidden=isHide
70 | }
71 |
72 | @IBAction func onMinThChange( text:UITextField){
73 | onSettingsChange?(self)
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/SmarTAG/Settings/SmarTagThresholdSensorCell.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import UIKit
39 | import SmarTagLib
40 |
41 | public protocol SmarTagThresholdSensorCellData{
42 | var name:String {get}
43 | var unit:String {get}
44 | var dataFormat:String {get}
45 | var image:UIImage {get}
46 | var sensorConf:SensorConfiguration {get}
47 | }
48 |
49 | open class SmarTagThresholdSensorCell : UITableViewCell{
50 |
51 | @IBOutlet weak var mImage: UIImageView!
52 | @IBOutlet weak var mName: UILabel!
53 | @IBOutlet weak var mEnable: UISwitch!
54 |
55 | @IBOutlet weak var mMaxThText: UITextField!
56 | @IBOutlet weak var mMaxUnitText: UILabel!
57 | @IBOutlet weak var mMaxView: UIStackView!
58 |
59 | public var showThresholdDelegate: (() -> Bool)?;
60 | public var onSettingsChange:((SmarTagThresholdSensorCell)->Void)?
61 |
62 | public func setData(data:SmarTagThresholdSensorCellData, isEditable:Bool){
63 | mName.text = data.name
64 | mImage.image = data.image
65 | mEnable.isOn = data.sensorConf.isEnable
66 | mEnable.isEnabled = isEditable
67 | mMaxUnitText.text = data.unit
68 | hideThreshold(!((showThresholdDelegate?() ?? false) && data.sensorConf.isEnable))
69 |
70 | if let max = data.sensorConf.threshold.max{
71 | mMaxThText.text=String(format: data.dataFormat, max)
72 | mEnable.isEnabled = isEditable
73 | }else{
74 | mMaxView.isHidden=true
75 | }
76 |
77 | }
78 |
79 | public func hideThreshold(_ isHide:Bool){
80 | mMaxView.isHidden=isHide
81 | }
82 |
83 | @IBAction func onEnableStatusChange( switch:UISwitch){
84 | onSettingsChange?(self)
85 | }
86 |
87 | @IBAction func onMaxThChange( text:UITextField){
88 | onSettingsChange?(self)
89 | }
90 |
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/SmarTAG/Settings/String+floatOrNil.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 | // MARK: String?
40 |
41 | internal extension Optional where Wrapped == String {
42 |
43 | /// convert the string value to float or return nil
44 | var floatOrNil:Float?{
45 | guard let value = self else{
46 | return nil
47 | }
48 | return Float(value)
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/SmarTAG/ShowData/SmarTagSensorDetailsViewController.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 | import Foundation
38 | import UIKit
39 | import Charts
40 |
41 | /// <#Description#>
42 | public class SmarTagSensorDetailsViewController : UIViewController {
43 |
44 | public struct Data{
45 | let title:String
46 | let dataFormat:String
47 | let samples:[ChartDataEntry]
48 | }
49 |
50 | public var data:Data?=nil;
51 |
52 | @IBOutlet weak var mTitle: UILabel!
53 | @IBOutlet weak var mDetailsTable: UITableView!
54 |
55 | public override func viewDidLoad() {
56 | mDetailsTable.dataSource = self;
57 | }
58 |
59 | public override func viewWillAppear(_ animated: Bool) {
60 | mTitle.text = data?.title
61 | mDetailsTable.reloadData()
62 | }
63 |
64 | }
65 |
66 |
67 | extension SmarTagSensorDetailsViewController : UITableViewDataSource{
68 | private static let CELL_ID = "SmarTagSensorDetailsViewCell"
69 | static let DATE_FORMAT : DateFormatter = {
70 | let formatter = DateFormatter();
71 | formatter.dateFormat = "HH:mm:ss dd/MMM/YY"
72 | return formatter;
73 | }();
74 |
75 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
76 | return data?.samples.count ?? 0
77 | }
78 |
79 | public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
80 | let cell = tableView.dequeueReusableCell(withIdentifier:SmarTagSensorDetailsViewController.CELL_ID)!
81 |
82 | if let entry = data?.samples[indexPath.row],
83 | let format = data?.dataFormat{
84 | cell.detailTextLabel?.text = String(format:format,entry.y)
85 | let date = Date(timeIntervalSinceReferenceDate: entry.x)
86 | cell.textLabel?.text = SmarTagSensorDetailsViewController.DATE_FORMAT.string(from: date)
87 | }
88 |
89 | return cell
90 |
91 | }
92 |
93 |
94 |
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/SmarTAG/SmarTAG.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.developer.nfc.readersession.formats
6 |
7 | NDEF
8 | TAG
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/SmarTAG/SmarTag/SmarTagNDefParserProtocol.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 |
40 | public enum SmarTagError : Error{
41 | case InvalidVersion
42 | }
43 |
44 | public protocol SmarTagNdefParserPotocol{
45 |
46 | var version:Version { get }
47 | var configuration:Configuration { get }
48 | var samples:[DataSample] { get }
49 | var dataExtreme:TagExtreme { get }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/SmarTAG/StarTagObjectWithTag.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import SmarTagLib
39 |
40 | protocol SmarTagObjectWithTag {
41 | var tagContent:SmarTagData? {get set}
42 | }
43 |
44 | extension SmarTagObjectWithTag{
45 | public func propagateTagContentTo(_ object:Any){
46 | if var objectWithTag = object as? SmarTagObjectWithTag{
47 | objectWithTag.tagContent = tagContent;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/SmarTAG/Util/UIViewControllerExt.swift:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018 STMicroelectronics – All rights reserved
3 | * The STMicroelectronics corporate logo is a trademark of STMicroelectronics
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * - Redistributions of source code must retain the above copyright notice, this list of conditions
9 | * and the following disclaimer.
10 | *
11 | * - Redistributions in binary form must reproduce the above copyright notice, this list of
12 | * conditions and the following disclaimer in the documentation and/or other materials provided
13 | * with the distribution.
14 | *
15 | * - Neither the name nor trademarks of STMicroelectronics International N.V. nor any other
16 | * STMicroelectronics company nor the names of its contributors may be used to endorse or
17 | * promote products derived from this software without specific prior written permission.
18 | *
19 | * - All of the icons, pictures, logos and other images that are provided with the source code
20 | * in a directory whose title begins with st_images may only be used for internal purposes and
21 | * shall not be redistributed to any third party or modified in any way.
22 | *
23 | * - Any redistributions in binary form shall not include the capability to display any of the
24 | * icons, pictures, logos and other images that are provided with the source code in a directory
25 | * whose title begins with st_images.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
28 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
30 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 | * OF SUCH DAMAGE.
36 | */
37 |
38 | import Foundation
39 | import UIKit
40 |
41 | extension UIViewController{
42 |
43 | public func showErrorMessage(title:String, message:String, onButtonPressed:((UIAlertController)->Void)?=nil){
44 |
45 | let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
46 |
47 | let defaultAction = UIAlertAction(title: "Ok", style: .destructive){ action in
48 | if(onButtonPressed != nil){
49 | onButtonPressed!(alertController)
50 | }else{
51 | alertController.dismiss(animated: true, completion: nil)
52 | }
53 | }
54 | alertController.addAction(defaultAction)
55 | present(alertController, animated: true, completion: nil)
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/SmarTAG/about.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
37 |
38 |
39 |
ST SmarTag application to be used with STMicroelectronics FP-SNS-SMARTAG1 compatible firmware.
40 |