├── .gitignore ├── LICENSE.md ├── README.md ├── examples ├── SmsHomeStackApp │ ├── .idea │ │ ├── codeStyles │ │ │ ├── Project.xml │ │ │ └── codeStyleConfig.xml │ │ ├── encodings.xml │ │ ├── gradle.xml │ │ ├── misc.xml │ │ ├── render.experimental.xml │ │ ├── runConfigurations.xml │ │ └── vcs.xml │ ├── README.md │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── telefonica │ │ │ │ └── lucferbux │ │ │ │ └── homestacksms │ │ │ │ └── ExampleInstrumentedTest.kt │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── telefonica │ │ │ │ │ └── lucferbux │ │ │ │ │ └── homestacksms │ │ │ │ │ ├── MainActivity.kt │ │ │ │ │ └── smsstack │ │ │ │ │ ├── SmsStackRaspController.kt │ │ │ │ │ └── SmsStackRaspLayer.kt │ │ │ └── res │ │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ ├── drawable │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ └── ic_lightbulb_outline_black_24dp.xml │ │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── telefonica │ │ │ └── lucferbux │ │ │ └── homestacksms │ │ │ └── ExampleUnitTest.kt │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle └── sms-home-stack │ ├── README.md │ ├── requirements.txt │ ├── sms_broadcaster.py │ ├── sms_layer_rasp.py │ ├── sms_stack_controller.py │ └── stack_sms_base.py ├── paper ├── StackSMSPaper_v7.pdf └── StackSMSPaper_v7_eng.pdf ├── sms-stack-android ├── .gitignore ├── .idea │ ├── caches │ │ └── build_file_checksums.ser │ ├── encodings.xml │ ├── gradle.xml │ ├── misc.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── LICENSE ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── lucferbux │ │ │ └── smstcpsdk │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── lucferbux │ │ │ │ └── smstcpsdk │ │ │ │ ├── MainActivity.java │ │ │ │ ├── SMSTCPMessageApp.java │ │ │ │ └── SMSTCPMessageLayer.java │ │ └── res │ │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── drawable │ │ │ └── ic_launcher_background.xml │ │ │ ├── layout │ │ │ ├── activity_main.xml │ │ │ └── content_main.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── lucferbux │ │ └── smstcpsdk │ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── smstcplibrary │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── smstcplibrary │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── smstcplibrary │ │ │ ├── AESCipher.java │ │ │ ├── BadKeyException.java │ │ │ ├── SMSTCP.java │ │ │ ├── SMSTCPAppLayer.java │ │ │ ├── SMSTCPController.java │ │ │ ├── SMSTCPLayer.java │ │ │ ├── SMSTCPReceiver.java │ │ │ ├── SMSTCPSender.java │ │ │ └── SmsBroadcastReceiver.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── example │ └── smstcplibrary │ └── ExampleUnitTest.java ├── sms-stack-python ├── .gitignore ├── LICENSE ├── README.md ├── __init__.py ├── setup.py └── sms_stack │ ├── __init__.py │ ├── cipher.py │ ├── debug │ ├── __init__.py │ ├── sms_broadcast_im.py │ ├── sms_mt_controller.py │ └── sms_mt_layer.py │ ├── sms_broadcaster.py │ ├── sms_controller_observer.py │ ├── sms_tcp.py │ ├── sms_tcp_controller.py │ ├── sms_tcp_layer.py │ ├── sms_tcp_layer_formatter.py │ ├── sms_tcp_receiver.py │ ├── sms_tcp_sender.py │ └── test │ ├── __init__.py │ ├── test_main.py │ ├── test_sms_tcp_layer.py │ └── test_sms_tcp_receiver.py └── sms-stack-typescript ├── .gitignore ├── .prettierrc ├── README.md ├── jestconfig.json ├── package-lock.json ├── package.json ├── src ├── __tests__ │ └── Main.test.ts ├── arrayExt.ts ├── index.ts ├── smsTcp.ts ├── smsTcpAppLayer.ts ├── smsTcpController.ts ├── smsTcpControllerObserver.ts ├── smsTcpLayer.ts ├── smsTcpReceiver.ts └── smsTcpSender.ts ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | 47 | # Translations 48 | *.mo 49 | *.pot 50 | 51 | # Django stuff: 52 | *.log 53 | 54 | # Sphinx documentation 55 | docs/_build/ 56 | 57 | # PyBuilder 58 | target/ 59 | 60 | *.vscode 61 | 62 | # Logs 63 | logs 64 | *.log 65 | npm-debug.log* 66 | yarn-debug.log* 67 | yarn-error.log* 68 | 69 | # Runtime data 70 | pids 71 | *.pid 72 | *.seed 73 | *.pid.lock 74 | 75 | # Directory for instrumented libs generated by jscoverage/JSCover 76 | lib-cov 77 | 78 | # Coverage directory used by tools like istanbul 79 | coverage 80 | 81 | # nyc test coverage 82 | .nyc_output 83 | 84 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 85 | .grunt 86 | 87 | # Bower dependency directory (https://bower.io/) 88 | bower_components 89 | 90 | # node-waf configuration 91 | .lock-wscript 92 | 93 | # Compiled binary addons (https://nodejs.org/api/addons.html) 94 | build/Release 95 | 96 | # Dependency directories 97 | node_modules/ 98 | jspm_packages/ 99 | 100 | # TypeScript v1 declaration files 101 | typings/ 102 | 103 | # Optional npm cache directory 104 | .npm 105 | 106 | # Optional eslint cache 107 | .eslintcache 108 | 109 | # Optional REPL history 110 | .node_repl_history 111 | 112 | # Output of 'npm pack' 113 | *.tgz 114 | 115 | # Yarn Integrity file 116 | .yarn-integrity 117 | 118 | # dotenv environment variables file 119 | .env 120 | .env.test 121 | 122 | # parcel-bundler cache (https://parceljs.org/) 123 | .cache 124 | 125 | # next.js build output 126 | .next 127 | 128 | # nuxt.js build output 129 | .nuxt 130 | 131 | # vuepress build output 132 | .vuepress/dist 133 | 134 | # Serverless directories 135 | .serverless/ 136 | 137 | # FuseBox cache 138 | .fusebox/ 139 | 140 | # DynamoDB Local files 141 | .dynamodb/ 142 | \.vscode/ 143 | 144 | lib/ 145 | 146 | \.DS_Store 147 | 148 | 149 | 150 | *.iml 151 | .gradle 152 | /local.properties 153 | /.idea/libraries 154 | /.idea/modules.xml 155 | /.idea/workspace.xml 156 | /.DS_Store 157 | /build 158 | /captures 159 | /.externalNativeBuild 160 | 161 | 162 | /examples/SmsHomeStackApp/local.properties 163 | /examples/SmsHomeStackApp/.idea/caches 164 | /examples/SmsHomeStackApp/.idea/libraries 165 | /examples/SmsHomeStackApp/.idea/modules.xml 166 | /examples/SmsHomeStackApp/.idea/workspace.xml 167 | /examples/SmsHomeStackApp/.idea/navEditor.xml 168 | /examples/SmsHomeStackApp/.idea/assetWizardSettings.xml 169 | /examples/SmsHomeStackApp//build 170 | /examples/SmsHomeStackApp//captures 171 | /examples/SmsHomeStackApp//.externalNativeBuild 172 | 173 | 174 | paper/~\$ackSMSPaper\.docx 175 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![License](https://img.shields.io/badge/license-GNU-green.svg?style=flat-square) 2 | 3 | # **SMS Stack** 4 | Sms Stack is a Framework to provide TPC/IP based characteristics to the GSM Short Message Service. 5 | 6 | This framework works in multiple environments to provide a full stack integration in a service. 7 | 8 | The main layer features techniques to control the order and the number of sms for a given stream, and a layer of security with AES + CTR cypher. 9 | 10 | You can easily implement your own protocol on the top of the stack of Sms Stack and add new features to an sms based communication between devices. 11 | 12 | # Prerequisites 13 | You can download and use sms-stack in multiple environments in order to implement it in multiple scenarios. 14 | 15 | ## Typescript 16 | Npm - https://www.npmjs.com 17 | 18 | Nodejs - https://nodejs.org/en/ 19 | 20 | Typescript - https://www.typescriptlang.org/#download-links 21 | 22 | ## Python 23 | Python 3.4 or higher - https://www.python.org/downloads/ 24 | 25 | Pip - https://pypi.org/project/pip/ 26 | 27 | ## Android 28 | Android API 23 (6.0) or higher - https://developer.android.com/about/versions/marshmallow/android-6.0 29 | 30 | Android Studio + Gradle (With JUnit) - https://developer.android.com/studio/install 31 | 32 | # Usage 33 | Simply add the framework in one of each repositories given in your repository. 34 | 35 | ## Typescript 36 | ```npm install sms-stack 1.x.x``` 37 | 38 | ## Python 39 | ```pip install sms-stack 1.x.x``` 40 | 41 | ## Android 42 | Add in the gradle app file 43 | ```implementation 'com.example.smstcplibrary:smsstack:1.x.x'``` 44 | 45 | For further implementation, please use the given wiki 46 | 47 | # SMS Stack scheme 48 | Stack Sms Layer 49 | 50 | Stack Sms Communication 51 | 52 | # License 53 | 54 | This project is licensed under the GNU General Public License - see the LICENSE file for details 55 | 56 | # Contact 57 | 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 59 | 60 | This software doesn't have a QA Process. This software is a Proof of Concept. 61 | 62 | If you have any problems, you can contact: 63 | 64 | - *Ideas Locas CDO - Telefónica* 65 | 66 | - *Ideas Locas CDO - Telefónica* 67 | 68 | - *Ideas Locas CDO - Telefónica* 69 | 70 | For more information please visit [https://www.elevenpaths.com](https://www.elevenpaths.com). 71 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 | 116 | 118 |
119 |
-------------------------------------------------------------------------------- /examples/SmsHomeStackApp/.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/.idea/render.experimental.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/README.md: -------------------------------------------------------------------------------- 1 | # Home Stack Python 2 | 3 | 4 | ``` 5 | _ _ _____ _ _ 6 | | | | | / ____| | | | /\ 7 | | |__| | ___ _ __ ___ ___ | (___ | |_ __ _ ___| | __ / \ _ __ _ __ 8 | | __ |/ _ \| '_ ` _ \ / _ \ \___ \| __/ _` |/ __| |/ / / /\ \ | '_ \| '_ \ 9 | | | | | (_) | | | | | | __/ ____) | || (_| | (__| < / ____ \| |_) | |_) | 10 | |_| |_|\___/|_| |_| |_|\___| |_____/ \__\__,_|\___|_|\_\ /_/ \_\ .__/| .__/ 11 | | | | | 12 | |_| |_| 13 | 14 | Created with ♥ by: 'Ideas Locas (CDO Telefonica)' 15 | ``` 16 | 17 | Home Stack App is the companion app to comunicate to sms-home-stack server for Raspberry 18 | 19 | 20 | # Prerequisite 21 | 22 | * [Android Studio](https://developer.android.com/studio) 23 | * [Kotlin](https://kotlinlang.org) 24 | * [Sms Stack Sdk](https://mvnrepository.com/artifact/com.example.smstcplibrary/smsstack) 25 | 26 | # Authors 27 | 28 | This project has been developed by the team of 'Ideas Locas' (CDO - Telefónica). To contact the authors: 29 | 30 | * **Pablo Gonzázlez Perez** -- [@pablogonzalezpe](https://twitter.com/pablogonzalezpe) -- pablo.gonzalezperez@telefonica.com 31 | * **Fran Ramirez** -- [@Cybercaronte](https://twitter.com/Cybercaronte) -- franciscojose.ramirezvicente@telefonica.com 32 | * **Lucas Fernández Aragón** -- [@lucferbux](https://twitter.com/lucferbux) -- lucas.fernandezaragon@telefonica.com 33 | 34 | 35 | # Disclaimer! 36 | 37 | THE SOFTWARE (for educational purpose only) IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 38 | 39 | This software doesn't have a QA Process. 40 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 27 9 | defaultConfig { 10 | applicationId "com.telefonica.lucferbux.homestacksms" 11 | minSdkVersion 24 12 | targetSdkVersion 27 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility 1.8 25 | targetCompatibility 1.8 26 | } 27 | } 28 | 29 | dependencies { 30 | implementation fileTree(dir: 'libs', include: ['*.jar']) 31 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 32 | implementation 'com.android.support:appcompat-v7:27.1.1' 33 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 34 | testImplementation 'junit:junit:4.12' 35 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 36 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 37 | 38 | // SMS STACK 39 | implementation 'com.example.smstcplibrary:smsstack:0.1.4' 40 | 41 | // Anko 42 | implementation "org.jetbrains.anko:anko:$anko_version" 43 | 44 | // Appcompat-v7 (Anko Layouts) 45 | implementation "org.jetbrains.anko:anko-appcompat-v7:$anko_version" 46 | implementation "org.jetbrains.anko:anko-coroutines:$anko_version" 47 | 48 | // CardView-v7 49 | implementation "org.jetbrains.anko:anko-cardview-v7:$anko_version" 50 | 51 | // Design 52 | implementation "org.jetbrains.anko:anko-design:$anko_version" 53 | implementation "org.jetbrains.anko:anko-design-coroutines:$anko_version" 54 | implementation "org.jetbrains.anko:anko-commons:$anko_version" 55 | 56 | // RecyclerView-v7 57 | implementation "org.jetbrains.anko:anko-recyclerview-v7:$anko_version" 58 | implementation "org.jetbrains.anko:anko-recyclerview-v7-coroutines:$anko_version" 59 | 60 | // Support-v4 (only Anko Commons) 61 | implementation "org.jetbrains.anko:anko-support-v4-commons:$anko_version" 62 | 63 | // Support-v4 (Anko Layouts) 64 | implementation "org.jetbrains.anko:anko-support-v4:$anko_version" 65 | 66 | // ConstraintLayout 67 | implementation "org.jetbrains.anko:anko-constraint-layout:$anko_version" 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/androidTest/java/com/telefonica/lucferbux/homestacksms/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.telefonica.lucferbux.homestacksms 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.telefonica.lucferbux.homestacksms", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/java/com/telefonica/lucferbux/homestacksms/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.telefonica.lucferbux.homestacksms 2 | 3 | import android.support.v7.app.AppCompatActivity 4 | import android.os.Bundle 5 | import android.os.Handler 6 | import android.view.View 7 | import com.telefonica.lucferbux.homestacksms.smsstack.SmsStackRaspController 8 | import kotlinx.android.synthetic.main.activity_main.* 9 | import org.jetbrains.anko.sdk27.coroutines.onClick 10 | import org.jetbrains.anko.toast 11 | 12 | class MainActivity : AppCompatActivity() { 13 | 14 | private lateinit var smsStackController: SmsStackRaspController 15 | 16 | override fun onCreate(savedInstanceState: Bundle?) { 17 | super.onCreate(savedInstanceState) 18 | setContentView(R.layout.activity_main) 19 | 20 | smsStackController = SmsStackRaspController(this) { 21 | toast("Action performed") 22 | } 23 | 24 | bt_yellow_led.onClick { 25 | changeButton(16) 26 | } 27 | 28 | bt_green_led.onClick { 29 | changeButton(18) 30 | } 31 | 32 | bt_red_led.onClick { 33 | changeButton(17) 34 | } 35 | } 36 | 37 | fun changeButton(port: Int) { 38 | smsStackController.sendMessage(port) 39 | 40 | when(port) { 41 | 16 -> { 42 | toast("Message sent to Yellow led") 43 | pb_yellow.visibility = View.VISIBLE 44 | bt_yellow_led.isEnabled = false 45 | Handler().postDelayed( 46 | { 47 | changeStatusText(port) 48 | }, 49 | 9000 // value in milliseconds 50 | ) 51 | } 52 | 53 | 17 -> { 54 | toast("Message sent to Red led") 55 | pb_red.visibility = View.VISIBLE 56 | bt_red_led.isEnabled = false 57 | Handler().postDelayed( 58 | { 59 | changeStatusText(port) 60 | }, 61 | 9000 // value in milliseconds 62 | ) 63 | } 64 | 65 | 18 -> { 66 | toast("Message sent to Green led") 67 | pb_green.visibility = View.VISIBLE 68 | bt_green_led.isEnabled = false 69 | Handler().postDelayed( 70 | { 71 | changeStatusText(port) 72 | }, 73 | 9000 // value in milliseconds 74 | ) 75 | } 76 | 77 | else -> { 78 | 79 | } 80 | } 81 | } 82 | 83 | fun changeStatusText(port: Int) { 84 | 85 | 86 | when(port) { 87 | 16 -> { 88 | tv_yellow.text = if(tv_yellow.text.equals("ON")) "OFF" else "ON" 89 | pb_yellow.visibility = View.INVISIBLE 90 | bt_yellow_led.isEnabled = true 91 | } 92 | 93 | 17 -> { 94 | tv_red.text = if(tv_red.text.equals("ON")) "OFF" else "ON" 95 | pb_red.visibility = View.INVISIBLE 96 | bt_red_led.isEnabled = true 97 | } 98 | 99 | 18 -> { 100 | tv_green.text = if(tv_green.text.equals("ON")) "OFF" else "ON" 101 | pb_green.visibility = View.INVISIBLE 102 | bt_green_led.isEnabled = true 103 | } 104 | 105 | } 106 | } 107 | 108 | fun messageReceived(port: Int) { 109 | 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/java/com/telefonica/lucferbux/homestacksms/smsstack/SmsStackRaspController.kt: -------------------------------------------------------------------------------- 1 | package com.telefonica.lucferbux.homestacksms.smsstack 2 | 3 | import android.support.v7.app.AppCompatActivity 4 | import android.util.Log 5 | import com.example.smstcplibrary.SMSTCPController 6 | import com.example.smstcplibrary.SMSTCPLayer 7 | import java.util.ArrayList 8 | 9 | class SmsStackRaspController (appCompatActivity: AppCompatActivity, val messageReceive: (SmsStackRaspLayer) -> Unit) { 10 | 11 | companion object { 12 | // Phone numbers to send the message 13 | val PHONE_NUMBERS = arrayOf("34646980422") 14 | } 15 | 16 | // Instantiation of the controller with AES CBC and Cipher key 17 | val smsStackController = SMSTCPController(appCompatActivity, 1 , "PATATA") 18 | 19 | init { 20 | val completionHandler = object: SMSTCPController.CompletionHandler { 21 | override fun handleMessageSent() { 22 | 23 | } 24 | 25 | // Methods handling the messages 26 | override fun handleFinalMessageReceived(p0: ArrayList?, p1: Array?) { 27 | val smsAppLayer = p0?.let { 28 | SmsStackRaspLayer(smsStackController.processMessages(p0)) 29 | } ?: run { 30 | return 31 | } 32 | 33 | messageReceive(smsAppLayer) 34 | Log.d("SMSSent", smsAppLayer.toString()) 35 | } 36 | 37 | override fun handleFinalMessageSent() { 38 | 39 | } 40 | 41 | override fun handleMessageReceived(p0: SMSTCPLayer?, p1: Array?) { 42 | 43 | } 44 | 45 | } 46 | 47 | smsStackController.setCompletionHandler(completionHandler) 48 | } 49 | 50 | /** 51 | * Send Message to the device 52 | * 53 | * @param device Device to target 54 | */ 55 | fun sendMessage(device: Int) { 56 | val smsLayer = SmsStackRaspLayer(100, device, 0, 0, "") 57 | smsStackController.sendMessage(smsLayer.encodeSMSApp(), PHONE_NUMBERS) 58 | } 59 | 60 | 61 | } -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/java/com/telefonica/lucferbux/homestacksms/smsstack/SmsStackRaspLayer.kt: -------------------------------------------------------------------------------- 1 | package com.telefonica.lucferbux.homestacksms.smsstack 2 | 3 | import com.example.smstcplibrary.SMSTCPAppLayer 4 | import com.example.smstcplibrary.SMSTCPLayer 5 | 6 | import java.math.BigInteger 7 | 8 | class SmsStackRaspLayer : SMSTCPAppLayer { 9 | 10 | companion object { 11 | val HEADER_SIZE = 6 12 | val HEADER_SIZE_BIN = HEADER_SIZE * 4 13 | } 14 | 15 | var idOrigin = 0b0 16 | var idTarget = 0b0 17 | var mod = 0b0 18 | var status = 0b0 19 | var data = "" 20 | 21 | constructor(idOrigin: Int, idTarget: Int, mod: Int, status: Int, data: String) { 22 | this.idOrigin = idOrigin 23 | this.idTarget = idTarget 24 | this.mod = mod 25 | this.status = status 26 | this.data = data 27 | } 28 | 29 | constructor(sms: String) { 30 | decodeSMSApp(sms) 31 | } 32 | 33 | override fun decodeSMSApp(s: String) { 34 | val headerMessage = SMSTCPLayer.fillHeader(hexToBinary(s.substring(0, HEADER_SIZE)), HEADER_SIZE_BIN) 35 | val dataMessage = s.substring(HEADER_SIZE, s.length) 36 | this.idOrigin = Integer.parseInt(headerMessage.substring(0, 8), 2) 37 | this.idTarget = Integer.parseInt(headerMessage.substring(8, 16), 2) 38 | this.mod = Integer.parseInt(headerMessage.substring(16, 21), 2) 39 | this.data = dataMessage 40 | } 41 | 42 | override fun encodeSMSApp(): String { 43 | val idOriginMessage = SMSTCPLayer.fillHeader(this.idOrigin, 8) 44 | val idTargetMessage = SMSTCPLayer.fillHeader(this.idTarget, 8) 45 | val modMessage = SMSTCPLayer.fillHeader(this.mod, 5) 46 | val statusMessage = SMSTCPLayer.fillHeader(this.status, 3) 47 | 48 | val headersBinary = idOriginMessage + idTargetMessage + modMessage + statusMessage 49 | val headersHexa = 50 | SMSTCPLayer.fillHeader(java.lang.Long.toHexString(java.lang.Long.parseLong(headersBinary, 2)), HEADER_SIZE) 51 | 52 | return headersHexa + this.data 53 | } 54 | 55 | override fun hexToBinary(s: String): String { 56 | return BigInteger(s, 16).toString(2) 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/drawable/ic_lightbulb_outline_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #00A9E0 4 | #007AAE 5 | #5BC500 6 | #EC6839 7 | #F59C00 8 | #ffffff 9 | #fcfcfc 10 | #000000 11 | #50535a 12 | #86888C 13 | #F8EC03 14 | #2C8D1D 15 | #E91414 16 | 17 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | HomeStackSms 3 | 4 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/app/src/test/java/com/telefonica/lucferbux/homestacksms/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.telefonica.lucferbux.homestacksms 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.3.21' 5 | ext.anko_version='0.10.8' 6 | repositories { 7 | google() 8 | jcenter() 9 | 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:3.5.0' 13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | google() 22 | jcenter() 23 | 24 | } 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # Kotlin code style for this project: "official" or "obsolete": 15 | kotlin.code.style=official 16 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/examples/SmsHomeStackApp/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 20 08:53:24 CET 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /examples/SmsHomeStackApp/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /examples/sms-home-stack/README.md: -------------------------------------------------------------------------------- 1 | # Home Stack Python 2 | 3 | 4 | ``` 5 | _ _ _____ _ _ ______ _ _ 6 | | | | | / ___|| | | | | ___ \ | | | | 7 | | |_| | ___ _ __ ___ ___ \ `--. | |_ __ _ ___ | | __ | |_/ / _ _ | |_ | |__ ___ _ __ 8 | | _ | / _ \ | '_ ` _ \ / _ \ `--. \| __| / _` | / __|| |/ / | __/ | | | || __|| '_ \ / _ \ | '_ \ 9 | | | | || (_) || | | | | || __/ /\__/ /| |_ | (_| || (__ | < | | | |_| || |_ | | | || (_) || | | | 10 | \_| |_/ \___/ |_| |_| |_| \___| \____/ \__| \__,_| \___||_|\_\ \_| \__, | \__||_| |_| \___/ |_| |_| 11 | __/ | 12 | |___/ 13 | 14 | Created with ♥ by: 'Ideas Locas (CDO Telefonica)' 15 | ``` 16 | 17 | Home Stack for Python is a tool that enables a second communication channel in any IoT device thanks to Sms Stack and a GSM Socket for Raspberry Pi. 18 | 19 | 20 | # Prerequisite 21 | 22 | * [GPIO board](https://sourceforge.net/projects/raspberry-gpio-python/) 23 | * [Python 3](https://www.python.org/download/releases/3.0/) 24 | * [Sms Stack Python](https://github.com/ElevenPaths/SDK-SMS-Stack) 25 | 26 | 27 | # Install 28 | 29 | * ```pip install -r requirements.txt``` 30 | 31 | 32 | # Authors 33 | 34 | This project has been developed by the team of 'Ideas Locas' (CDO - Telefónica). To contact the authors: 35 | 36 | * **Pablo Gonzázlez Perez** -- [@pablogonzalezpe](https://twitter.com/pablogonzalezpe) -- pablo.gonzalezperez@telefonica.com 37 | * **Fran Ramirez** -- [@Cybercaronte](https://twitter.com/Cybercaronte) -- franciscojose.ramirezvicente@telefonica.com 38 | * **Lucas Fernández Aragón** -- [@lucferbux](https://twitter.com/lucferbux) -- lucas.fernandezaragon@telefonica.com 39 | 40 | 41 | 42 | 43 | 44 | # Disclaimer! 45 | 46 | THE SOFTWARE (for educational purpose only) IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 47 | 48 | This software doesn't have a QA Process. 49 | -------------------------------------------------------------------------------- /examples/sms-home-stack/requirements.txt: -------------------------------------------------------------------------------- 1 | RPi.GPIO==0.7.0 2 | sms-stack -------------------------------------------------------------------------------- /examples/sms-home-stack/sms_broadcaster.py: -------------------------------------------------------------------------------- 1 | from sms_stack.sms_broadcaster import SmsBroadcaster 2 | import time, sys 3 | 4 | class SmsBroadcast(SmsBroadcaster): 5 | 6 | def __init__(self, serial): 7 | """Implementation class of broadcaster, it sends the message through serial port encoding 8 | 9 | Args: 10 | serial (int): Serial code used to send the message 11 | """ 12 | 13 | self.serial_port = serial 14 | self.send_message = 'AT+CMGS="{}"\r' 15 | 16 | 17 | def send_sms(self, sms, recipient): 18 | """Send and sms to a given recipient 19 | 20 | Args: 21 | sms (string): Sms Stack encoded sms 22 | recipient (string): Recipient of the sms 23 | """ 24 | 25 | self.serial_port.write(str.encode(self.send_message.format(recipient))) 26 | time.sleep(1) 27 | self.serial_port.write(str.encode(sms + chr(26))) 28 | time.sleep(1) 29 | 30 | -------------------------------------------------------------------------------- /examples/sms-home-stack/sms_layer_rasp.py: -------------------------------------------------------------------------------- 1 | from sms_stack.sms_tcp_layer_formatter import SmsTcpLayerFormatter 2 | 3 | class SmsTcpLayerRasp: 4 | 5 | def __init__(self, sms='', id_origin=None, id_target=None, mod=None, status=None, data=""): 6 | """Sms Stack Layer implementation 7 | sms (str, optional): Defaults to ''. Sms to decoded 8 | id_origin (int, optional): Defaults to None. Identifier of the origin device 9 | id_target (int, optional): Defaults to None. Identifier of the targeted device 10 | mod (int, optional): Defaults to None. ??? 11 | status (int, optional): Defaults to None. [description] 12 | data (str, optional): Defaults to "". Data to send, currently unavailable 13 | """ 14 | 15 | if(sms != ''): 16 | self._decode_sms(sms) 17 | elif(id_origin != None, id_target != None, mod != None, status != None,): 18 | self.id_origin = id_origin 19 | self.id_target = id_target 20 | self.mod = mod 21 | self.status = status 22 | self.data = data 23 | 24 | 25 | def _decode_sms(self, sms): 26 | """Decodes the sms received 27 | 28 | Args: 29 | sms (string): Encoded sms 30 | """ 31 | 32 | try: 33 | header_sms = SmsTcpLayerFormatter.fill_header_string(SmsTcpLayerFormatter.hex_to_binary(sms[0:6]), 24) 34 | self.data = sms[6:] 35 | self.id_origin = int(header_sms[0:8], 2) 36 | self.id_target = int(header_sms[8:16], 2) 37 | self.mod = int(header_sms[16:21], 2) 38 | self.status = int(header_sms[21:], 2) 39 | except Exception as e: 40 | print("Bad length exception --->" + e) 41 | 42 | 43 | def enconde_sms(self): 44 | """Encode the Sms Stack Layer into a string sms 45 | 46 | Returns: 47 | str: Sms Encoded 48 | """ 49 | 50 | id_origin = SmsTcpLayerFormatter.fill_header_binary(self.id_origin, 8) 51 | id_target = SmsTcpLayerFormatter.fill_header_binary(self.id_target, 8) 52 | mod = SmsTcpLayerFormatter.fill_header_binary(self.mod, 5) 53 | status = SmsTcpLayerFormatter.fill_header_binary(self.status, 3) 54 | 55 | headers_binary = id_origin + id_target + mod + status 56 | headers_hexa = SmsTcpLayerFormatter.fill_header_string(SmsTcpLayerFormatter.binary_to_hex(headers_binary), 6) 57 | 58 | return headers_hexa + self.data 59 | 60 | -------------------------------------------------------------------------------- /examples/sms-home-stack/sms_stack_controller.py: -------------------------------------------------------------------------------- 1 | from sms_stack.sms_controller_observer import SmsControllerObserver 2 | from sms_stack.sms_tcp_controller import SmsTcpController 3 | from sms_stack.sms_tcp_layer import SmsTcpLayer 4 | 5 | class SmsStackController(SmsControllerObserver): 6 | 7 | def __init__(self, broadcast_send, callback_message): 8 | """Implementation of Sms Stack Controller 9 | 10 | Args: 11 | broadcast_send (BroadcastSender): The broadcast object to send sms 12 | callback_message (function): Callback function to retrieve the message 13 | """ 14 | 15 | super().__init__() 16 | # Initialize the controller with the chipher key PATATA in AES CBC 17 | self.controller = SmsTcpController(self, broadcast_send, cipher_mode=1, cipher_key='PATATA') 18 | self.callback_message = callback_message 19 | 20 | # Handler message methods 21 | def handle_final_message_received(self, messages, sender): 22 | message = self.controller.process_message(messages) 23 | self.callback_message(message) 24 | 25 | 26 | def handle_message_received(self, layer, sender): 27 | return 28 | 29 | 30 | def handle_final_message_sent(self, messages, recipient): 31 | return 32 | 33 | 34 | def handle_message_sent(self, layer, recipient): 35 | return 36 | 37 | def send_message(self, sms, recipient="", recipients=[]): 38 | """Send message to a number 39 | 40 | Args: 41 | sms (string): Sms Stack encoded sms 42 | recipient (str, optional): Defaults to "". Recipient to send the message 43 | recipients (list, optional): Defaults to []. List of recipients to send the message 44 | """ 45 | sms_layer = SmsTcpLayer(sms=sms) 46 | message = sms_layer.enconde_sms() 47 | 48 | recipients.append(recipient) 49 | for rec in recipients: 50 | self.controller.send_message(message, rec) 51 | 52 | def message_received(self, sms, sender): 53 | """Method to control a new message received 54 | 55 | Args: 56 | sms (string): Message encoded 57 | sender (string): Number of the sender 58 | """ 59 | self.controller.receive_message(sms, sender) 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /examples/sms-home-stack/stack_sms_base.py: -------------------------------------------------------------------------------- 1 | # Ideas Locas CDO 2 | # SMS Stack test server 3 | # Based on SIMSMS1.py 4 | # http://www.python-exemplary.com/ 5 | 6 | import RPi.GPIO as GPIO 7 | import serial 8 | import time, sys 9 | import datetime 10 | import re 11 | 12 | from sms_stack_controller import SmsStackController 13 | from sms_broadcaster import SmsBroadcast 14 | from sms_layer_rasp import SmsTcpLayerRasp 15 | 16 | # GPIO management 17 | P_BUTTON = 24 # Example, response wiring button GPIO 18 | 19 | # Serial port 20 | #SERIAL_PORT = "/dev/ttyAMA0" # Raspberry Pi 2 21 | SERIAL_PORT = "/dev/ttyS0" # Raspberry Pi 3 22 | 23 | class StackServerSMS(object): 24 | 25 | def __init__(self): 26 | self.text_mode = 'AT+CMGF=1\r' 27 | self.read_first_message = 'AT+CMGR=1\r' 28 | self.del_all_message = 'AT+CMGDA="DEL ALL"\r' 29 | self.read_unread_messages = 'AT+CMGL="REC UNREAD"\r' 30 | self.del_read_messages = 'AT+CMGD=0,1\r' 31 | self.lightbull = False 32 | self.serial_port = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) 33 | self.sender = SmsBroadcast(self.serial_port) 34 | self.sms_stack_controller = SmsStackController(self.sender, self.message_processed) 35 | self.enable_sms() 36 | 37 | # GPIO initialization and definitions 38 | def setup_gpio(self): 39 | GPIO.setmode(GPIO.BOARD) 40 | GPIO.setup(P_BUTTON, GPIO.IN, GPIO.PUD_UP) 41 | 42 | def enable_sms(self): 43 | """Enables all the sms capabilities in the GPIO base 44 | """ 45 | 46 | # GPIO Initialization 47 | self.setup_gpio() # init 48 | self.serial_port.write(str.encode(self.text_mode)) # set to text mode 49 | time.sleep(1) 50 | self.serial_port.write(str.encode(self.del_all_message)) 51 | time.sleep(1) 52 | self.serial_port.read(self.serial_port.inWaiting()) # Clean buf 53 | 54 | def receive_sms(self): 55 | print("Listening for incomming Stack SMS...") 56 | while True: 57 | try: 58 | self.serial_port.write(str.encode(self.read_unread_messages)) 59 | time.sleep(1) 60 | reply = self.serial_port.read(self.serial_port.inWaiting()).decode() 61 | 62 | if "CMGL:" in reply: 63 | self.process_messages(reply) 64 | self.delete_messages() 65 | 66 | time.sleep(1) 67 | except KeyboardInterrupt: 68 | break 69 | 70 | def process_messages(self, reply): 71 | response_list = self.parse_sms(reply) 72 | for response in response_list: 73 | self.sms_stack_controller.message_received(response[0], response[1]) 74 | 75 | 76 | @staticmethod 77 | def message_processed(message): 78 | """Process message received 79 | 80 | Args: 81 | message (str): Message received 82 | """ 83 | 84 | stack_layer = SmsTcpLayerRasp(sms=message) 85 | print("Hemos recibido id_origin: {}".format(stack_layer.id_origin)) 86 | print("Hemos recibido id_sender: {}".format(stack_layer.id_target)) 87 | print("Hemos recibido mod: {}".format(stack_layer.mod)) 88 | print("Hemos recibido status: {}".format(stack_layer.status)) 89 | 90 | 91 | def delete_messages(self): 92 | """Delete a message once is read 93 | """ 94 | 95 | self.serial_port.write(str.encode(self.del_read_messages)) # delete read nessages 96 | time.sleep(1) 97 | self.serial_port.read(self.serial_port.inWaiting()) # Clear buf 98 | 99 | 100 | def parse_sms(self, sms): 101 | """Due to bad formatting in GPIO, parsing method to retrieve the actual message 102 | 103 | Args: 104 | sms (str): Bad formatted messsage 105 | 106 | Returns: 107 | str: Message retrieved 108 | """ 109 | 110 | res = [] 111 | match = re.findall("\+CMGL: (\d+),""(.+)"",""(.+)"",(.*),""(.+)""\n(.+)\n", sms) 112 | 113 | for each in match: 114 | res.append((each[5], each[2][1:-1])) 115 | return res 116 | 117 | if __name__ == "__main__": 118 | print("Stack SMS server, initializing ...") 119 | stacksms=StackServerSMS() 120 | 121 | stacksms.receive_sms() 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /paper/StackSMSPaper_v7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/paper/StackSMSPaper_v7.pdf -------------------------------------------------------------------------------- /paper/StackSMSPaper_v7_eng.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/paper/StackSMSPaper_v7_eng.pdf -------------------------------------------------------------------------------- /sms-stack-android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | 12 | \.idea/caches/gradle_models\.ser 13 | -------------------------------------------------------------------------------- /sms-stack-android/.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /sms-stack-android/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /sms-stack-android/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /sms-stack-android/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /sms-stack-android/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /sms-stack-android/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sms-stack-android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sms-stack-android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | defaultConfig { 6 | applicationId "com.example.lucferbux.smstcpsdk" 7 | minSdkVersion 24 8 | targetSdkVersion 27 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | testOptions { 20 | unitTests.returnDefaultValues = true 21 | } 22 | compileOptions { 23 | sourceCompatibility JavaVersion.VERSION_1_8 24 | targetCompatibility JavaVersion.VERSION_1_8 25 | } 26 | } 27 | 28 | dependencies { 29 | implementation fileTree(dir: 'libs', include: ['*.jar']) 30 | implementation 'com.android.support:appcompat-v7:27.1.1' 31 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 32 | implementation 'com.android.support:design:27.1.1' 33 | testImplementation 'junit:junit:4.12' 34 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 35 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 36 | implementation project(path: ':smstcplibrary') 37 | } 38 | -------------------------------------------------------------------------------- /sms-stack-android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/androidTest/java/com/example/lucferbux/smstcpsdk/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.lucferbux.smstcpsdk; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.lucferbux.smstcpsdk", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/java/com/example/lucferbux/smstcpsdk/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.lucferbux.smstcpsdk; 2 | 3 | import android.content.pm.PackageManager; 4 | import android.os.Bundle; 5 | import android.os.Handler; 6 | import android.os.Looper; 7 | import android.support.design.widget.FloatingActionButton; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.support.v7.widget.Toolbar; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | import android.view.View; 13 | import android.widget.Switch; 14 | import android.widget.TextView; 15 | import android.widget.Toast; 16 | 17 | import com.example.smstcplibrary.SMSTCPController; 18 | import com.example.smstcplibrary.SMSTCPLayer; 19 | 20 | public class MainActivity extends AppCompatActivity { 21 | 22 | String message; 23 | TextView mSMSTextView; 24 | TextView mSMSTextDestinataryView; 25 | 26 | SMSTCPMessageApp smsListener; 27 | TextView mSMSDisplayID; 28 | TextView mSMSDisplayKey; 29 | 30 | TextView mSMSDisplaySyn; 31 | TextView mSMSDisplayAck; 32 | TextView mSMSDisplayPsh; 33 | TextView mSMSDisplayFin; 34 | TextView mSMSDisplaySbegin; 35 | TextView mSMSDisplayCipher; 36 | 37 | Switch mAckSWitch; 38 | 39 | 40 | TextView mSMSDisplayData; 41 | 42 | 43 | @Override 44 | protected void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | setContentView(R.layout.activity_main); 47 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 48 | setSupportActionBar(toolbar); 49 | 50 | mSMSTextView = (TextView) findViewById(R.id.tv_sms_content); 51 | mSMSTextDestinataryView = (TextView) findViewById(R.id.tv_sms_dest); 52 | mSMSDisplayID = (TextView) findViewById(R.id.tv_id_display); 53 | mSMSDisplayKey = (TextView) findViewById(R.id.tv_key_display); 54 | mSMSDisplayData = (TextView) findViewById(R.id.tv_data_app_display); 55 | mSMSDisplaySyn = (TextView) findViewById(R.id.tv_syn_display); 56 | mSMSDisplayAck = (TextView) findViewById(R.id.tv_ack_display); 57 | mSMSDisplayPsh = (TextView) findViewById(R.id.tv_psh_display); 58 | mSMSDisplayFin = (TextView) findViewById(R.id.tv_fin_display); 59 | mSMSDisplaySbegin = (TextView) findViewById(R.id.tv_sBegin_display); 60 | mSMSDisplayCipher = (TextView) findViewById(R.id.tv_cipher_display); 61 | mAckSWitch = findViewById((R.id.response_switch)); 62 | 63 | 64 | String[] phoneNo = {mSMSTextDestinataryView.getText().toString()}; 65 | 66 | smsListener = new SMSTCPMessageApp(this,0); 67 | 68 | smsListener.setListener(new SMSTCPMessageApp.ListenerApp() { 69 | @Override 70 | public void onTextProcessed(final String message) { 71 | new Handler(Looper.getMainLooper()).post(new Runnable() { 72 | @Override 73 | public void run() { 74 | mSMSDisplayData.setText(message); 75 | } 76 | }); 77 | 78 | } 79 | @Override 80 | public void onSMSRecived(SMSTCPLayer smstcpLayer) { 81 | mSMSDisplayID.setText(Integer.toString(smstcpLayer.id)); 82 | mSMSDisplayKey.setText(Integer.toString(smstcpLayer.key)); 83 | mSMSDisplaySyn.setText(Integer.toString(smstcpLayer.syn)); 84 | mSMSDisplayAck.setText(Integer.toString(smstcpLayer.ack)); 85 | mSMSDisplayPsh.setText(Integer.toString(smstcpLayer.psh)); 86 | mSMSDisplayFin.setText(Integer.toString(smstcpLayer.fin)); 87 | mSMSDisplaySbegin.setText(Integer.toString(smstcpLayer.sBegin)); 88 | mSMSDisplayCipher.setText(Integer.toString(smstcpLayer.cipher)); 89 | } 90 | }); 91 | 92 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 93 | fab.setOnClickListener(new View.OnClickListener() { 94 | @Override 95 | public void onClick(View view) { 96 | sendSMS(); 97 | } 98 | }); 99 | } 100 | 101 | private void sendSMS() { 102 | String[] phoneNo = {mSMSTextDestinataryView.getText().toString()}; 103 | smsListener.sendNewMessage(mSMSTextView.getText().toString(), phoneNo, mAckSWitch.isChecked()); 104 | } 105 | 106 | @Override 107 | public void onRequestPermissionsResult(int requestCode,String permissions[], int[] grantResults) { 108 | switch (requestCode) { 109 | case 0: { 110 | if (grantResults.length > 0 111 | && grantResults[0] == PackageManager.PERMISSION_GRANTED) { 112 | Toast.makeText(getApplicationContext(), 113 | "Permission Granted", Toast.LENGTH_LONG).show(); 114 | } else { 115 | Toast.makeText(getApplicationContext(), 116 | "Request failed, please accept to make the app work", Toast.LENGTH_LONG).show(); 117 | 118 | } 119 | return; 120 | } 121 | } 122 | 123 | } 124 | 125 | 126 | } 127 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/java/com/example/lucferbux/smstcpsdk/SMSTCPMessageApp.java: -------------------------------------------------------------------------------- 1 | package com.example.lucferbux.smstcpsdk; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.widget.Toast; 5 | 6 | import com.example.smstcplibrary.SMSTCPController; 7 | import com.example.smstcplibrary.SMSTCPLayer; 8 | 9 | import java.util.ArrayList; 10 | 11 | public class SMSTCPMessageApp { 12 | 13 | private String[] phoneNumbers; 14 | private ListenerApp listener; 15 | private SMSTCPController smsTCPController; 16 | private AppCompatActivity activity; 17 | 18 | public SMSTCPMessageApp(AppCompatActivity activitySms, int cipherMode){ 19 | this.activity = activitySms; 20 | this.smsTCPController = new SMSTCPController(activitySms, 1, "PATATA"); 21 | 22 | smsTCPController.setCompletionHandler(new SMSTCPController.CompletionHandler() { 23 | 24 | @Override 25 | public void handleFinalMessageReceived(ArrayList messages, String[] senderNumber) { 26 | try{ 27 | String message = smsTCPController.processMessages(messages); 28 | listener.onTextProcessed(message); 29 | } catch (Exception e) { 30 | 31 | } 32 | 33 | } 34 | 35 | @Override 36 | public void handleMessageReceived(SMSTCPLayer smsTCP, String[] senderNumber) { 37 | try { 38 | listener.onSMSRecived(smsTCP); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | @Override 45 | public void handleFinalMessageSent() { 46 | try { 47 | onMessageSent(); 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | } 51 | 52 | } 53 | 54 | @Override 55 | public void handleMessageSent() { 56 | 57 | } 58 | }); 59 | } 60 | 61 | 62 | public void sendNewMessage(String text, String[] phoneNo, Boolean ackBack) { 63 | smsTCPController.sendMessage(text, phoneNo, ackBack); 64 | } 65 | 66 | public void onMessageSent() { 67 | Toast.makeText(this.activity.getApplicationContext(), "SMS sent.", 68 | Toast.LENGTH_LONG).show(); 69 | } 70 | 71 | public void setListener(ListenerApp listener) { 72 | this.listener = listener; 73 | } 74 | 75 | public interface ListenerApp { 76 | void onTextProcessed(String message); 77 | void onSMSRecived(SMSTCPLayer smstcpLayer); 78 | } 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/java/com/example/lucferbux/smstcpsdk/SMSTCPMessageLayer.java: -------------------------------------------------------------------------------- 1 | package com.example.lucferbux.smstcpsdk; 2 | 3 | import com.example.smstcplibrary.SMSTCPAppLayer; 4 | import com.example.smstcplibrary.SMSTCPLayer; 5 | 6 | import java.math.BigInteger; 7 | 8 | public class SMSTCPMessageLayer implements SMSTCPAppLayer { 9 | 10 | public int mode = 0b0; 11 | public int ack = 0b0; 12 | public int status = 0b0; 13 | public int sBegin = 0b0; 14 | public int id = 0b0; 15 | public String data; 16 | 17 | public SMSTCPMessageLayer(int mode, int ack, int status, int sBegin, int id, String data) { 18 | this.mode = mode; 19 | this.ack = ack; 20 | this.status = status; 21 | this.sBegin = sBegin; 22 | this.id = id; 23 | this.data = data; 24 | } 25 | 26 | public SMSTCPMessageLayer(String sms) { 27 | decodeSMSApp(sms); 28 | } 29 | 30 | @Override 31 | public void decodeSMSApp(String s) { 32 | String headerMessage = SMSTCPLayer.fillHeader(hexToBinary(s.substring(0, 4)), 16); 33 | String dataMessage = s.substring(4, s.length()); 34 | this.mode = Integer.parseInt(headerMessage.substring(0,4), 2); 35 | this.ack = Integer.parseInt(headerMessage.substring(4,5), 2); 36 | this.status = Integer.parseInt(headerMessage.substring(5,6), 2); 37 | this.sBegin = Integer.parseInt(headerMessage.substring(6,12), 2); 38 | this.id = Integer.parseInt(headerMessage.substring(12,16), 2); 39 | this.data = dataMessage; 40 | } 41 | 42 | 43 | @Override 44 | public String encodeSMSApp() { 45 | String modeMessage = SMSTCPLayer.fillHeader(this.mode, 4); 46 | String ackMessage = SMSTCPLayer.fillHeader(this.ack, 1); 47 | String statusMessage = SMSTCPLayer.fillHeader(this.status, 1); 48 | String sBeginMessage = SMSTCPLayer.fillHeader(this.sBegin, 6); 49 | String idMessage = SMSTCPLayer.fillHeader(this.id, 4); 50 | 51 | String headersBinary = modeMessage + ackMessage + statusMessage + sBeginMessage + idMessage; 52 | String headersHexa = SMSTCPLayer.fillHeader(Long.toHexString(Long.parseLong(headersBinary, 2)), 4); 53 | 54 | return headersHexa + this.data; 55 | } 56 | 57 | @Override 58 | public String hexToBinary(String s) { 59 | return new BigInteger(s, 16).toString(2); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 32 | 33 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Telefonica/SDK-SMS-Stack/05aa8bc99152b163dd38d9db3597efb8f9496034/sms-stack-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 4 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SmsTcpSDK 3 | MainActivity 4 | 5 | -------------------------------------------------------------------------------- /sms-stack-android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |