├── .gitignore ├── README.md ├── angular.json ├── config.xml ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── ionic.config.json ├── package.json ├── resources ├── android │ ├── icon │ │ ├── drawable-hdpi-icon.png │ │ ├── drawable-ldpi-icon.png │ │ ├── drawable-mdpi-icon.png │ │ ├── drawable-xhdpi-icon.png │ │ ├── drawable-xxhdpi-icon.png │ │ └── drawable-xxxhdpi-icon.png │ └── splash │ │ ├── drawable-land-hdpi-screen.png │ │ ├── drawable-land-ldpi-screen.png │ │ ├── drawable-land-mdpi-screen.png │ │ ├── drawable-land-xhdpi-screen.png │ │ ├── drawable-land-xxhdpi-screen.png │ │ ├── drawable-land-xxxhdpi-screen.png │ │ ├── drawable-port-hdpi-screen.png │ │ ├── drawable-port-ldpi-screen.png │ │ ├── drawable-port-mdpi-screen.png │ │ ├── drawable-port-xhdpi-screen.png │ │ ├── drawable-port-xxhdpi-screen.png │ │ └── drawable-port-xxxhdpi-screen.png ├── icon.png ├── ios │ ├── icon │ │ ├── icon-1024.png │ │ ├── icon-40.png │ │ ├── icon-40@2x.png │ │ ├── icon-40@3x.png │ │ ├── icon-50.png │ │ ├── icon-50@2x.png │ │ ├── icon-60.png │ │ ├── icon-60@2x.png │ │ ├── icon-60@3x.png │ │ ├── icon-72.png │ │ ├── icon-72@2x.png │ │ ├── icon-76.png │ │ ├── icon-76@2x.png │ │ ├── icon-83.5@2x.png │ │ ├── icon-small.png │ │ ├── icon-small@2x.png │ │ ├── icon-small@3x.png │ │ ├── icon.png │ │ └── icon@2x.png │ └── splash │ │ ├── Default-568h@2x~iphone.png │ │ ├── Default-667h.png │ │ ├── Default-736h.png │ │ ├── Default-Landscape-736h.png │ │ ├── Default-Landscape@2x~ipad.png │ │ ├── Default-Landscape@~ipadpro.png │ │ ├── Default-Landscape~ipad.png │ │ ├── Default-Portrait@2x~ipad.png │ │ ├── Default-Portrait@~ipadpro.png │ │ ├── Default-Portrait~ipad.png │ │ ├── Default@2x~iphone.png │ │ ├── Default@2x~universal~anyany.png │ │ └── Default~iphone.png └── splash.png ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── dashboard │ │ ├── dashboard.module.ts │ │ ├── dashboard.page.html │ │ ├── dashboard.page.scss │ │ ├── dashboard.page.spec.ts │ │ └── dashboard.page.ts │ ├── device-manager.service.spec.ts │ ├── device-manager.service.ts │ └── home │ │ ├── home.module.ts │ │ ├── home.page.html │ │ ├── home.page.scss │ │ ├── home.page.spec.ts │ │ └── home.page.ts ├── assets │ └── icon │ │ └── favicon.png ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── global.scss ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── test.ts ├── theme │ └── variables.scss ├── tsconfig.app.json └── tsconfig.spec.json ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | package-lock.json 15 | .idea/ 16 | .ionic/ 17 | .sourcemaps/ 18 | .sass-cache/ 19 | .tmp/ 20 | .versions/ 21 | coverage/ 22 | www/ 23 | node_modules/ 24 | tmp/ 25 | temp/ 26 | platforms/ 27 | plugins/ 28 | plugins/android.json 29 | plugins/ios.json 30 | $RECYCLE.BIN/ 31 | 32 | .DS_Store 33 | Thumbs.db 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # blinker-simple-app 2 | 本项目是blinker app端的单设备版本 3 | 支持蓝牙Ble、WiFi设备连接 4 | 使用ionic4 + angular6开发 5 | 需配合设备端blinker库使用 6 | 本项目仅供学习,不提供任何技术支持 7 | ## 使用方法: 8 | ``` 9 | $ npm i ionic cordova -g 10 | $ cd blinker-simple-app 11 | $ npm i 12 | ``` 13 | 14 | android: 15 | ``` 16 | $ ionic cordova build android 17 | ``` 18 | ios: 19 | ``` 20 | $ ionic cordova build ios 21 | ``` 22 | 23 | ## 配置方法: 24 | 在src/home中变量device负责存储设备信息,其形式如下: 25 | ```json 26 | device = { 27 | "type": "DiyArduino", 28 | "name": "D43639DF71A3", 29 | "config": { 30 | "mode": "ble", 31 | "customName": "blinker DIY device", 32 | }, 33 | "data": { 34 | "state": "", 35 | "counter": 0 36 | } 37 | } 38 | ``` 39 | 可修改配置如下: 40 | **type**根据设备类型选填:DiyArduino\DiyLiunx 41 | **name**填写设备mac地址(去掉冒号) 42 | **mode**根据接入方式选填:ble\net 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json", 3 | "version": 1, 4 | "defaultProject": "app", 5 | "projects": { 6 | "app": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "progress": false, 17 | "outputPath": "www", 18 | "index": "src/index.html", 19 | "main": "src/main.ts", 20 | "polyfills": "src/polyfills.ts", 21 | "tsConfig": "src/tsconfig.app.json", 22 | "assets": [ 23 | { 24 | "glob": "**/*", 25 | "input": "src/assets", 26 | "output": "assets" 27 | }, 28 | { 29 | "glob": "**/*.svg", 30 | "input": "node_modules/@ionic/angular/dist/ionic/svg", 31 | "output": "./svg" 32 | } 33 | ], 34 | "styles": [ 35 | { 36 | "input": "src/theme/variables.scss" 37 | }, 38 | { 39 | "input": "src/global.scss" 40 | } 41 | ], 42 | "scripts": [] 43 | }, 44 | "configurations": { 45 | "production": { 46 | "fileReplacements": [ 47 | { 48 | "replace": "src/environments/environment.ts", 49 | "with": "src/environments/environment.prod.ts" 50 | } 51 | ], 52 | "optimization": true, 53 | "outputHashing": "all", 54 | "sourceMap": false, 55 | "extractCss": true, 56 | "namedChunks": false, 57 | "aot": true, 58 | "extractLicenses": true, 59 | "vendorChunk": false, 60 | "buildOptimizer": true 61 | } 62 | } 63 | }, 64 | "serve": { 65 | "builder": "@angular-devkit/build-angular:dev-server", 66 | "options": { 67 | "browserTarget": "app:build" 68 | }, 69 | "configurations": { 70 | "production": { 71 | "browserTarget": "app:build:production" 72 | } 73 | } 74 | }, 75 | "extract-i18n": { 76 | "builder": "@angular-devkit/build-angular:extract-i18n", 77 | "options": { 78 | "browserTarget": "app:build" 79 | } 80 | }, 81 | "test": { 82 | "builder": "@angular-devkit/build-angular:karma", 83 | "options": { 84 | "main": "src/test.ts", 85 | "polyfills": "src/polyfills.ts", 86 | "tsConfig": "src/tsconfig.spec.json", 87 | "karmaConfig": "src/karma.conf.js", 88 | "styles": [ 89 | "styles.css" 90 | ], 91 | "scripts": [], 92 | "assets": [ 93 | { 94 | "glob": "favicon.ico", 95 | "input": "src/", 96 | "output": "/" 97 | }, 98 | { 99 | "glob": "**/*", 100 | "input": "src/assets", 101 | "output": "/assets" 102 | } 103 | ] 104 | } 105 | }, 106 | "lint": { 107 | "builder": "@angular-devkit/build-angular:tslint", 108 | "options": { 109 | "tsConfig": [ 110 | "src/tsconfig.app.json", 111 | "src/tsconfig.spec.json" 112 | ], 113 | "exclude": [ 114 | "**/node_modules/**" 115 | ] 116 | } 117 | }, 118 | "ionic-cordova-build": { 119 | "builder": "@ionic/ng-toolkit:cordova-build", 120 | "options": { 121 | "browserTarget": "app:build" 122 | }, 123 | "configurations": { 124 | "production": { 125 | "browserTarget": "app:build:production" 126 | } 127 | } 128 | }, 129 | "ionic-cordova-serve": { 130 | "builder": "@ionic/ng-toolkit:cordova-serve", 131 | "options": { 132 | "cordovaBuildTarget": "app:ionic-cordova-build", 133 | "devServerTarget": "app:serve" 134 | }, 135 | "configurations": { 136 | "production": { 137 | "cordovaBuildTarget": "app:ionic-cordova-build:production", 138 | "devServerTarget": "app:serve:production" 139 | } 140 | } 141 | } 142 | } 143 | }, 144 | "app-e2e": { 145 | "root": "e2e/", 146 | "projectType": "application", 147 | "architect": { 148 | "e2e": { 149 | "builder": "@angular-devkit/build-angular:protractor", 150 | "options": { 151 | "protractorConfig": "e2e/protractor.conf.js", 152 | "devServerTarget": "app:serve" 153 | } 154 | }, 155 | "lint": { 156 | "builder": "@angular-devkit/build-angular:tslint", 157 | "options": { 158 | "tsConfig": "e2e/tsconfig.e2e.json", 159 | "exclude": [ 160 | "**/node_modules/**" 161 | ] 162 | } 163 | } 164 | } 165 | } 166 | }, 167 | "cli": { 168 | "defaultCollection": "@ionic/schematics-angular" 169 | }, 170 | "schematics": { 171 | "@ionic/schematics-angular:component": { 172 | "styleext": "scss" 173 | }, 174 | "@ionic/schematics-angular:page": { 175 | "styleext": "scss" 176 | } 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | simple-blinker 4 | An awesome Ionic/Cordova app. 5 | Ionic Framework Team 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: 'e2e/tsconfig.e2e.json' 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('new App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toContain('The world is your oyster.'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.deepCss('app-root ion-content')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "simple-blinker", 3 | "integrations": { 4 | "cordova": {} 5 | }, 6 | "type": "angular" 7 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "simple-blinker", 3 | "version": "0.0.1", 4 | "author": "Ionic Framework", 5 | "homepage": "http://ionicframework.com/", 6 | "scripts": { 7 | "ng": "ng", 8 | "start": "ng serve", 9 | "build": "ng build", 10 | "test": "ng test", 11 | "lint": "ng lint", 12 | "e2e": "ng e2e" 13 | }, 14 | "private": true, 15 | "dependencies": { 16 | "@angular/common": "~6.1.1", 17 | "@angular/core": "~6.1.1", 18 | "@angular/forms": "~6.1.1", 19 | "@angular/http": "~6.1.1", 20 | "@angular/platform-browser": "~6.1.1", 21 | "@angular/platform-browser-dynamic": "~6.1.1", 22 | "@angular/router": "~6.1.1", 23 | "@ionic-native/ble": "^4.12.2", 24 | "@ionic-native/core": "5.0.0-beta.15", 25 | "@ionic-native/diagnostic": "^4.12.2", 26 | "@ionic-native/splash-screen": "5.0.0-beta.15", 27 | "@ionic-native/status-bar": "5.0.0-beta.15", 28 | "@ionic-native/zeroconf": "^4.12.2", 29 | "@ionic/angular": "4.0.0-beta.5", 30 | "cordova-android": "7.0.0", 31 | "cordova-plugin-add-swift-support": "^1.7.2", 32 | "cordova-plugin-ble-central": "^1.2.2", 33 | "cordova-plugin-compat": "^1.2.0", 34 | "cordova-plugin-device": "^2.0.2", 35 | "cordova-plugin-ionic-keyboard": "^2.1.2", 36 | "cordova-plugin-ionic-webview": "^2.1.0", 37 | "cordova-plugin-splashscreen": "^5.0.2", 38 | "cordova-plugin-statusbar": "^2.4.2", 39 | "cordova-plugin-whitelist": "^1.3.3", 40 | "cordova-plugin-zeroconf": "^1.3.3", 41 | "cordova.plugins.diagnostic": "^4.0.9", 42 | "core-js": "^2.5.3", 43 | "rxjs": "6.2.2", 44 | "text-encoding": "^0.6.4", 45 | "zone.js": "^0.8.26" 46 | }, 47 | "devDependencies": { 48 | "@angular/cli": "~6.1.1", 49 | "@angular/compiler": "~6.1.1", 50 | "@angular/compiler-cli": "~6.1.1", 51 | "@angular/language-service": "~6.1.1", 52 | "@angular-devkit/architect": "~0.7.2", 53 | "@angular-devkit/build-angular": "~0.7.2", 54 | "@angular-devkit/core": "~0.7.2", 55 | "@angular-devkit/schematics": "~0.7.2", 56 | "@ionic/ng-toolkit": "^1.0.0", 57 | "@ionic/schematics-angular": "^1.0.0", 58 | "@types/jasmine": "~2.8.6", 59 | "@types/jasminewd2": "~2.0.3", 60 | "@types/node": "~10.9.2", 61 | "codelyzer": "~4.4.2", 62 | "jasmine-core": "~2.99.1", 63 | "jasmine-spec-reporter": "~4.2.1", 64 | "karma": "~3.0.0", 65 | "karma-chrome-launcher": "~2.2.0", 66 | "karma-coverage-istanbul-reporter": "~2.0.0", 67 | "karma-jasmine": "~1.1.1", 68 | "karma-jasmine-html-reporter": "^0.2.2", 69 | "protractor": "~5.4.0", 70 | "ts-node": "~7.0.0", 71 | "tslint": "~5.11.0", 72 | "typescript": "~2.9.2" 73 | }, 74 | "description": "An Ionic project", 75 | "cordova": { 76 | "plugins": { 77 | "cordova-plugin-ble-central": {}, 78 | "cordova-plugin-whitelist": {}, 79 | "cordova-plugin-statusbar": {}, 80 | "cordova-plugin-device": {}, 81 | "cordova-plugin-splashscreen": {}, 82 | "cordova-plugin-ionic-webview": {}, 83 | "cordova-plugin-ionic-keyboard": {}, 84 | "cordova-plugin-zeroconf": {}, 85 | "cordova.plugins.diagnostic": {} 86 | }, 87 | "platforms": [ 88 | "android" 89 | ] 90 | } 91 | } -------------------------------------------------------------------------------- /resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/icon.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-1024.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default@2x~universal~anyany.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default@2x~universal~anyany.png -------------------------------------------------------------------------------- /resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/resources/splash.png -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | const routes: Routes = [ 5 | { path: '', redirectTo: 'home', pathMatch: 'full' }, 6 | { path: 'home', loadChildren: './home/home.module#HomePageModule' }, 7 | { path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardPageModule' }, 8 | ]; 9 | 10 | @NgModule({ 11 | imports: [RouterModule.forRoot(routes)], 12 | exports: [RouterModule] 13 | }) 14 | export class AppRoutingModule { } 15 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { TestBed, async } from '@angular/core/testing'; 3 | 4 | import { Platform } from '@ionic/angular'; 5 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 6 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 7 | 8 | import { AppComponent } from './app.component'; 9 | 10 | describe('AppComponent', () => { 11 | 12 | let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; 13 | 14 | beforeEach(async(() => { 15 | statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); 16 | splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); 17 | platformReadySpy = Promise.resolve(); 18 | platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); 19 | 20 | TestBed.configureTestingModule({ 21 | declarations: [AppComponent], 22 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 23 | providers: [ 24 | { provide: StatusBar, useValue: statusBarSpy }, 25 | { provide: SplashScreen, useValue: splashScreenSpy }, 26 | { provide: Platform, useValue: platformSpy }, 27 | ], 28 | }).compileComponents(); 29 | })); 30 | 31 | it('should create the app', () => { 32 | const fixture = TestBed.createComponent(AppComponent); 33 | const app = fixture.debugElement.componentInstance; 34 | expect(app).toBeTruthy(); 35 | }); 36 | 37 | it('should initialize the app', async () => { 38 | TestBed.createComponent(AppComponent); 39 | expect(platformSpy.ready).toHaveBeenCalled(); 40 | await platformReadySpy; 41 | expect(statusBarSpy.styleDefault).toHaveBeenCalled(); 42 | expect(splashScreenSpy.hide).toHaveBeenCalled(); 43 | }); 44 | 45 | // TODO: add more tests! 46 | 47 | }); 48 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { Platform } from '@ionic/angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 5 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 6 | 7 | @Component({ 8 | selector: 'app-root', 9 | templateUrl: 'app.component.html' 10 | }) 11 | export class AppComponent { 12 | constructor( 13 | private platform: Platform, 14 | private splashScreen: SplashScreen, 15 | private statusBar: StatusBar 16 | ) { 17 | this.initializeApp(); 18 | } 19 | 20 | initializeApp() { 21 | this.platform.ready().then(() => { 22 | this.statusBar.styleDefault(); 23 | this.splashScreen.hide(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { RouterModule, RouteReuseStrategy, Routes } from '@angular/router'; 4 | 5 | import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; 6 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 7 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 8 | 9 | import { AppComponent } from './app.component'; 10 | import { AppRoutingModule } from './app-routing.module'; 11 | 12 | import { BLE } from '@ionic-native/ble'; 13 | import { Zeroconf } from '@ionic-native/zeroconf'; 14 | import { Diagnostic } from '@ionic-native/diagnostic'; 15 | 16 | @NgModule({ 17 | declarations: [AppComponent], 18 | entryComponents: [], 19 | imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule], 20 | providers: [ 21 | StatusBar, 22 | SplashScreen, 23 | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, 24 | BLE, 25 | Zeroconf, 26 | Diagnostic 27 | ], 28 | bootstrap: [AppComponent] 29 | }) 30 | export class AppModule {} 31 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { Routes, RouterModule } from '@angular/router'; 5 | 6 | import { IonicModule } from '@ionic/angular'; 7 | 8 | import { DashboardPage } from './dashboard.page'; 9 | 10 | const routes: Routes = [ 11 | { 12 | path: '', 13 | component: DashboardPage 14 | } 15 | ]; 16 | 17 | @NgModule({ 18 | imports: [ 19 | CommonModule, 20 | FormsModule, 21 | IonicModule, 22 | RouterModule.forChild(routes) 23 | ], 24 | declarations: [DashboardPage] 25 | }) 26 | export class DashboardPageModule {} 27 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | dashboard 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard.page.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/src/app/dashboard/dashboard.page.scss -------------------------------------------------------------------------------- /src/app/dashboard/dashboard.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { DashboardPage } from './dashboard.page'; 5 | 6 | describe('DashboardPage', () => { 7 | let component: DashboardPage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ DashboardPage ], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(DashboardPage); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/dashboard/dashboard.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-dashboard', 5 | templateUrl: './dashboard.page.html', 6 | styleUrls: ['./dashboard.page.scss'], 7 | }) 8 | export class DashboardPage implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/device-manager.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { DeviceManagerService } from './device-manager.service'; 4 | 5 | describe('DeviceManagerService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [DeviceManagerService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([DeviceManagerService], (service: DeviceManagerService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /src/app/device-manager.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { BLE } from '@ionic-native/ble'; 3 | import { Zeroconf } from '@ionic-native/zeroconf'; 4 | import { Diagnostic } from '@ionic-native/diagnostic'; 5 | import { Platform, Events } from '@ionic/angular'; 6 | import { TextDecoder } from 'text-encoding'; 7 | 8 | @Injectable({ 9 | providedIn: 'root' 10 | }) 11 | export class DeviceManagerService { 12 | uuid; 13 | bleUUID = ""; 14 | brokers; 15 | devices; 16 | // device 17 | timer = []; 18 | userUrl: string; 19 | deviceList = []; 20 | lanDeviceList = []; 21 | bleDeviceList = []; 22 | mqttCloseCnt = 0; 23 | 24 | mqttClient; 25 | wsClient; 26 | 27 | constructor( 28 | private zeroconf: Zeroconf, 29 | private plt: Platform, 30 | private events: Events, 31 | private ble: BLE, 32 | private diagnostic: Diagnostic, 33 | ) { 34 | 35 | } 36 | 37 | 38 | init() { 39 | } 40 | 41 | connectDeviceTimer; 42 | connectDevice(device: any, mode: string = "show"): Promise { 43 | return new Promise(async (resolve, reject) => { 44 | if (!this.plt.is('cordova')) return resolve(false); 45 | //连接超时6秒。移除连接定时器情况:1.连接成功;2.退出页面 46 | this.connectDeviceTimer = window.setTimeout(() => { 47 | if (mode == "show") this.events.publish("provider:notice", 'timeoutConnect'); 48 | this.disconnectDevice(device); 49 | return resolve(false); 50 | }, 6000); 51 | if (device.data.state != "disconnected") device.data.state = "disconnected"; 52 | // this.events.publish("device:" + device.name, JSON.parse(`{"state":"disconnected"}`)); 53 | if (device.config.mode == "ble") { 54 | if (!this.isBluetoothAvailable()) return resolve(false); 55 | if (mode == "show") this.events.publish("loading:show", 'connect'); 56 | let result = await this.connectBleDevice(device) 57 | return resolve(result); 58 | } else if (device.config.mode == "net") { 59 | if (!this.isWifiAvailable()) return resolve(false); 60 | // if (!(await this.wifiIsConnected())) return resolve(false); 61 | if (mode == "show") this.events.publish("loading:show", 'connect'); 62 | return resolve(await this.connectNetDevice(device)); 63 | } 64 | }) 65 | } 66 | 67 | disconnectDevice(device) { 68 | if (!this.plt.is('cordova')) return; 69 | //清除连接定时器 70 | window.clearTimeout(this.connectDeviceTimer); 71 | if (device.config.mode == "ble") { 72 | this.disconnectBleDevice(device); 73 | } else if (device.config.mode == "net") { 74 | this.disconnectNetDevice(device); 75 | } 76 | } 77 | 78 | //搜索并连接到指定net设备 79 | //zeroconf.close的情况:1.连接成功;2.连接超时;3.还未连接即退出layout页面 80 | // keepalivedInterval; 81 | async connectNetDevice(device): Promise { 82 | return new Promise((resolve, reject) => { 83 | if (this.plt.is('android')) { 84 | this.zeroconf.watchAddressFamily = 'ipv4'; 85 | } 86 | this.zeroconf.watch('_' + device.deviceType + '._tcp.', 'local.').subscribe(result => { 87 | if (result.action == "resolved") { 88 | if (result.service.name == device.name && result.service.ipv4Addresses.length > 0) { 89 | window.clearTimeout(this.connectDeviceTimer); 90 | this.zeroconf.close(); 91 | this.events.publish("loading:hide", 'hide'); 92 | this.disconnectNetDevice(device); 93 | this.wsClient = new WebSocket("ws://" + result.service.ipv4Addresses[0] + ":81"); 94 | this.wsClient.onmessage = (event) => { 95 | // this.lastGetTime = new Date().getTime(); 96 | let message = {}; 97 | message["fromDevice"] = device.name; 98 | try { 99 | message["data"] = JSON.parse(event.data); 100 | } 101 | catch (e) { 102 | message["data"] = event.data; 103 | } 104 | this.processMessage(message); 105 | } 106 | this.wsClient.onopen = (event) => { 107 | console.log("ws open"); 108 | console.log(event); 109 | // this.lastGetTime = new Date().getTime(); 110 | // window.clearInterval(this.keepalivedInterval); 111 | // this.keepalivedInterval = window.setInterval(() => { 112 | // this.queryWsDevice(device); 113 | // }, 3000) 114 | return resolve(true); 115 | }; 116 | this.wsClient.onerror = (event) => { 117 | console.log("ws error"); 118 | console.log(event); 119 | } 120 | this.wsClient.onclose = (event) => { 121 | console.log("ws close"); 122 | console.log(event); 123 | this.events.publish("device:" + device.name, JSON.parse(`{"state":"disconnected"}`)); 124 | } 125 | // return resolve(true); 126 | } 127 | } 128 | }); 129 | }) 130 | } 131 | 132 | disconnectNetDevice(device) { 133 | // console.log('guanguangguan'); 134 | if (typeof (this.wsClient) != "undefined") 135 | this.wsClient.close(); 136 | // this.wsClient. 137 | //处理还未连接上,便退出layout的情况 138 | this.zeroconf.close(); 139 | } 140 | 141 | //发送net数据 142 | send2net(device, message: string) { 143 | // if (this.wsClient.readyState == "OPEN") 144 | // console.log("发送getstate"); 145 | this.wsClient.send(message); 146 | } 147 | 148 | send(device, message: string) { 149 | if (device.config.mode == 'net') { 150 | this.send2net(device, message) 151 | } else { 152 | this.send2ble(device, message) 153 | } 154 | 155 | } 156 | 157 | 158 | //搜索并连接到指定ble设备 159 | lastbuf = new Uint8Array(10240); 160 | lastbufcnt = 0; 161 | connectBleDevice(device): Promise { 162 | return new Promise((resolve, reject) => { 163 | //this.events.publish("loading:show", 'connect'); 164 | // console.log("ble disconnect");log 165 | this.ble.disconnect(this.bleUUID); 166 | console.log("scanBle"); 167 | this.ble.startScan([]).subscribe(result => { 168 | console.log(result); 169 | if (this.plt.is('android') || (typeof (result.advertising.kCBAdvDataManufacturerData) != 'undefined')) { 170 | // if (name2Mac(device.name) == this.mac2name(result)) { 171 | if (device.name == this.mac2name(result)) { 172 | console.log('连接蓝牙设备:' + result.id) 173 | window.clearTimeout(this.connectDeviceTimer); 174 | this.ble.connect(result.id).subscribe( 175 | data => { 176 | this.ble.stopScan(); 177 | this.bleUUID = result.id; 178 | console.log(data); 179 | this.events.publish("loading:hide", 'hide'); 180 | this.events.publish("device:" + device.name, JSON.parse(`{"state":"connected"}`)); 181 | this.lastbuf.fill(0); 182 | this.lastbufcnt = 0; 183 | this.ble.startNotification(result.id, 'ffe0', 'ffe1').subscribe(buffer => { 184 | let buftmp = new Uint8Array(buffer); 185 | this.lastbuf.set(buftmp, this.lastbufcnt); 186 | this.lastbufcnt += buftmp.length; 187 | while (this.lastbuf.indexOf(10) > -1) {//找到/n,转字符串后测试是否能转json 188 | let index = this.lastbuf.indexOf(10); 189 | let fullMessage = transcoding(this.lastbuf); 190 | console.log(fullMessage); 191 | let message = {}; 192 | message["fromDevice"] = device.name; 193 | if (fullMessage.indexOf('{') > -1) { 194 | try { 195 | message["data"] = JSON.parse(fullMessage); 196 | } 197 | catch (e) { 198 | message["data"] = fullMessage; 199 | } 200 | } 201 | else message["data"] = fullMessage; 202 | this.processMessage(message); 203 | let slicetmp = this.lastbuf.slice(index + 1, this.lastbufcnt); 204 | this.lastbuf.fill(0); 205 | this.lastbuf.set(slicetmp); 206 | this.lastbufcnt -= index + 1; 207 | } 208 | }); 209 | return resolve(true); 210 | }, 211 | error => { 212 | this.bleUUID = ""; 213 | if (device.data.state != "disconnected") device.data.state = "disconnected"; 214 | // this.events.publish("device:" + device.name, JSON.parse(`{"state":"disconnected"}`)); 215 | console.log(error); 216 | return resolve(false); 217 | } 218 | ); 219 | } 220 | } 221 | }); 222 | }) 223 | } 224 | 225 | async disconnectBleDevice(device) { 226 | this.ble.stopScan(); 227 | this.ble.stopStateNotifications(); 228 | // window.setTimeout(() => { 229 | // if (await this.ble.isConnected(this.bleUUID)) { 230 | console.log("ble disconnect"); 231 | this.ble.disconnect(this.bleUUID); 232 | if (device.data.state != "disconnected") device.data.state = "disconnected"; 233 | // this.events.publish("device:" + device.name, JSON.parse(`{"state":"disconnected"}`)); 234 | this.bleUUID = ""; 235 | //清空缓存 236 | this.lastbuf.fill(0); 237 | } 238 | 239 | //发送ble数据 240 | lastSendTime = 0; 241 | send2ble(device, message: string) { 242 | if (this.plt.is('android')) { 243 | let t = this.lastSendTime - new Date().getTime(); 244 | this.lastSendTime = new Date().getTime(); 245 | if (t < 0) t = 0; 246 | let i = 0; 247 | for (i = 0; i < message.length; i += 20) { 248 | let tmp = message.slice(i, i + 20); 249 | let delay = i + t; 250 | setTimeout(() => { 251 | this.ble.writeWithoutResponse(this.bleUUID, 'ffe0', 'ffe1', str2ab(tmp)) 252 | }, delay); 253 | } 254 | this.lastSendTime = this.lastSendTime + i + t; 255 | } 256 | else { 257 | this.ble.writeWithoutResponse(this.bleUUID, 'ffe0', 'ffe1', str2ab(message)) 258 | } 259 | 260 | 261 | } 262 | 263 | 264 | //将消息分发到组件上 265 | processMessage(message) { 266 | // window.clearTimeout(this.timer[message.fromDevice]); 267 | // console.log('将消息分发到组件:' + message.fromDevice) 268 | // 如果该fromDevice,不在现有设备列表中,则可能是刚添加的新设备 269 | if (this.deviceList.indexOf(message.fromDevice) > -1) { 270 | this.events.publish('device:' + message.fromDevice, message.data); 271 | } 272 | if (JSON.stringify(message.data) == '{"message":"Registration successful"}') { 273 | this.events.publish('device:new', message); 274 | } 275 | } 276 | 277 | mac2name(result) { 278 | let name = ""; 279 | //android 280 | if (this.plt.is('android')) { 281 | name = result.id.replace(new RegExp(':', 'g'), ''); 282 | } 283 | //ios 284 | else { 285 | let macBytes = new Uint8Array(result.advertising.kCBAdvDataManufacturerData); 286 | for (let i = macBytes.length - 6; i < macBytes.length; i++) { 287 | if (macBytes[i] <= 16) name += '0'; 288 | name += macBytes[i].toString(16); 289 | } 290 | } 291 | return name.toUpperCase(); 292 | } 293 | 294 | async isBluetoothAvailable() { 295 | if (await this.diagnostic.getBluetoothState() == this.diagnostic.bluetoothState.POWERED_ON) { 296 | return true; 297 | } else { 298 | this.events.publish("provider:notice", "openBluetooth"); 299 | return false; 300 | } 301 | } 302 | 303 | async isWifiAvailable() { 304 | if (await this.diagnostic.isWifiAvailable()) { 305 | return true; 306 | } else { 307 | this.events.publish("provider:notice", "openWifi"); 308 | return false; 309 | } 310 | } 311 | } 312 | 313 | 314 | export function transcoding(buf) { 315 | let message; 316 | if (checkCodeUtf8(buf)) 317 | message = new TextDecoder("utf8").decode(new Uint8Array(buf.slice(0, buf.indexOf(10)))); 318 | else 319 | message = new TextDecoder("gb18030").decode(new Uint8Array(buf.slice(0, buf.indexOf(10)))); 320 | return message; 321 | } 322 | 323 | export function checkCodeUtf8(lastbuf): any { 324 | let index = lastbuf.indexOf(10); 325 | let utf8cnt = 0; 326 | let gb18030cnt = 0; 327 | let asciicnt = 0; 328 | for (let i = 0; i < index; i++) {//判断是否utf8编码 329 | if (lastbuf[i] < 0x80) { 330 | asciicnt++; 331 | continue; 332 | } 333 | else { 334 | let p = i; 335 | switch (lastbuf[p] >> 3) { 336 | case 31://1111 0xxx四字节utf8检测 337 | p++; 338 | if ((lastbuf[p] > 0xbf) || (lastbuf[p] < 0x80)) break; 339 | case 29://1110 xxxx三字节utf8检测 340 | case 28: 341 | p++; 342 | if ((lastbuf[p] > 0xbf) || (lastbuf[p] < 0x80)) break; 343 | case 27://110x xxxx两字节utf8检测 344 | case 26: 345 | case 25: 346 | case 24: 347 | p++; 348 | if ((lastbuf[p] > 0xbf) || (lastbuf[p] < 0x80)) break;//10xx xxxx 349 | utf8cnt++; 350 | i = p; 351 | break; 352 | default: 353 | break; 354 | } 355 | } 356 | } 357 | let utf8scale = utf8cnt * 3 / (index - asciicnt); 358 | if (utf8scale > 0.99) return true; 359 | for (let i = 0; i < index; i++) { 360 | if (lastbuf[i] < 0x80) { 361 | continue; 362 | } 363 | else { 364 | let p = i; 365 | if ((lastbuf[p] >= 0x81) && (lastbuf[p] <= 0xfe)) {//判断gb18030第一字节 366 | p++; 367 | if ((lastbuf[p] >= 0x40) && (lastbuf[p] <= 0xfe)) {//判断gb18030第二字节 368 | if (lastbuf[p] != 0x7f) { 369 | gb18030cnt++; 370 | i = p; 371 | } 372 | } 373 | else if ((lastbuf[p] >= 0x30) && (lastbuf[p] <= 0x39)) {//判断gb18030第二字节 374 | p++; 375 | if ((lastbuf[p] >= 0x81) && (lastbuf[p] <= 0xfe)) {//判断gb18030第三字节 376 | p++; 377 | if ((lastbuf[p] >= 0x30) && (lastbuf[p] <= 0x39)) {//判断gb18030第四字节 378 | gb18030cnt++; 379 | i = p; 380 | } 381 | } 382 | } 383 | } 384 | } 385 | } 386 | let gb18030scale = gb18030cnt * 2 / (index - asciicnt); 387 | if (utf8scale >= gb18030scale) return true; 388 | else return false; 389 | } 390 | 391 | export function str2ab(str) { 392 | var buf = new ArrayBuffer(str.length); 393 | var bufView = new Uint8Array(buf); 394 | for (var i = 0, strLen = str.length; i < strLen; i++) { 395 | bufView[i] = str.charCodeAt(i); 396 | } 397 | return buf; 398 | } 399 | -------------------------------------------------------------------------------- /src/app/home/home.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { IonicModule } from '@ionic/angular'; 4 | import { FormsModule } from '@angular/forms'; 5 | import { RouterModule } from '@angular/router'; 6 | 7 | import { HomePage } from './home.page'; 8 | 9 | @NgModule({ 10 | imports: [ 11 | CommonModule, 12 | FormsModule, 13 | IonicModule, 14 | RouterModule.forChild([ 15 | { 16 | path: '', 17 | component: HomePage 18 | } 19 | ]) 20 | ], 21 | declarations: [HomePage] 22 | }) 23 | export class HomePageModule {} 24 | -------------------------------------------------------------------------------- /src/app/home/home.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{device.config.customName}} 5 | 6 | 7 | 8 | 9 | 10 |
{{device.data.counter}}
11 | 点我计数 12 | 点我开关灯 13 |
14 | -------------------------------------------------------------------------------- /src/app/home/home.page.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/home/home.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { HomePage } from './home.page'; 5 | 6 | describe('HomePage', () => { 7 | let component: HomePage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ HomePage ], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(HomePage); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/home/home.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, ChangeDetectorRef } from '@angular/core'; 2 | import { DeviceManagerService } from '../device-manager.service' 3 | import { Events } from '@ionic/angular'; 4 | @Component({ 5 | selector: 'app-home', 6 | templateUrl: 'home.page.html', 7 | styleUrls: ['home.page.scss'], 8 | }) 9 | export class HomePage { 10 | 11 | // type根据设备类型选填:DiyArduino\DiyLiunx 12 | // name填写设备mac地址(去掉冒号) 13 | // mode根据接入方式选填:ble\net 14 | 15 | device = { 16 | type: 'DiyArduino', 17 | name: 'xxxxxxxxxxxxxxx', 18 | config: { 19 | mode: 'ble', 20 | customName: 'blinker DIY device', 21 | }, 22 | data: { 23 | state: '', 24 | counter: 0 25 | } 26 | } 27 | constructor( 28 | private events: Events, 29 | private changeDetectorRef: ChangeDetectorRef, 30 | private deviceManager: DeviceManagerService 31 | ) { } 32 | 33 | ngOnInit() { 34 | 35 | // this.deviceManager.connectDevice(this.device); 36 | } 37 | 38 | tap1() { 39 | this.deviceManager.send(this.device, `{"btn-123":"tap"}`) 40 | } 41 | 42 | tap2() { 43 | this.deviceManager.send(this.device, `{"btn-abc":"tap"}`) 44 | } 45 | 46 | subscribe() { 47 | this.events.subscribe('device:' + this.device.name, data => { 48 | // console.log("分发数据"); 49 | // console.log(data); 50 | //如果不是json对象,就判定为unknownData 51 | if (typeof (data) == 'string' || typeof (data) == "number") { 52 | this.events.publish(this.device.name + ':unknownData', data.toString() + "\n"); 53 | } else { 54 | for (let key in data) { 55 | //保留关键字不允许用户改写 56 | if (key == "config" || key == "name" || key == "device") 57 | break; 58 | //实际通信数据存储 59 | //device.data为临时数据存储位置 60 | this.device.data[key] = data[key]; 61 | this.events.publish(this.device.name + ':' + key, 'loaded'); 62 | } 63 | // 显示到degbug窗口 64 | this.events.publish(this.device.name + ':unknownData', JSON.stringify(data) + "\n"); 65 | } 66 | //通知相关页面,关闭读取状态 67 | this.events.publish('page:device', 'loaded') 68 | this.changeDetectorRef.markForCheck(); 69 | }); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/assets/icon/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coloz/blinker-simple-app/2acc27232d91afb83f12dbb2960e743bc408635b/src/assets/icon/favicon.png -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * In development mode, to ignore zone related error stack frames such as 11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 12 | * import the following file, but please comment it out in production mode 13 | * because it will have performance impact when throw error 14 | */ 15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 16 | -------------------------------------------------------------------------------- /src/global.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/theming/ 2 | @import "~@ionic/angular/css/normalize.css"; 3 | @import "~@ionic/angular/css/structure.css"; 4 | @import "~@ionic/angular/css/typography.css"; 5 | @import "~@ionic/angular/css/colors.css"; 6 | 7 | @import "~@ionic/angular/css/padding.css"; 8 | @import "~@ionic/angular/css/float-elements.css"; 9 | @import "~@ionic/angular/css/text-alignment.css"; 10 | @import "~@ionic/angular/css/text-transformation.css"; 11 | @import "~@ionic/angular/css/flex-utils.css"; 12 | 13 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, 'coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | 44 | /** Evergreen browsers require these. **/ 45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 46 | import 'core-js/es7/reflect'; 47 | 48 | 49 | /** 50 | * Required to support Web Animations `@angular/platform-browser/animations`. 51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 52 | **/ 53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 54 | 55 | 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by Angular itself. 59 | */ 60 | import 'zone.js/dist/zone'; // Included with Angular CLI. 61 | 62 | 63 | 64 | /*************************************************************************************************** 65 | * APPLICATION IMPORTS 66 | */ 67 | 68 | /** 69 | * Date, currency, decimal and percent pipes. 70 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 71 | */ 72 | // import 'intl'; // Run `npm install --save intl`. 73 | /** 74 | * Need to import at least one locale-data with intl. 75 | */ 76 | // import 'intl/locale-data/jsonp/en'; 77 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/theming/ 3 | 4 | /** Ionic CSS Variables **/ 5 | :root { 6 | /** primary **/ 7 | --ion-color-primary: #488aff; 8 | --ion-color-primary-rgb: 72,138,255; 9 | --ion-color-primary-contrast: #fff; 10 | --ion-color-primary-contrast-rgb: 255,255,255; 11 | --ion-color-primary-shade: #3f79e0; 12 | --ion-color-primary-tint: #5a96ff; 13 | 14 | /** secondary **/ 15 | --ion-color-secondary: #32db64; 16 | --ion-color-secondary-rgb: 50,219,100; 17 | --ion-color-secondary-contrast: #fff; 18 | --ion-color-secondary-contrast-rgb: 255,255,255; 19 | --ion-color-secondary-shade: #2cc158; 20 | --ion-color-secondary-tint: #47df74; 21 | 22 | /** tertiary **/ 23 | --ion-color-tertiary: #f4a942; 24 | --ion-color-tertiary-rgb: 244,169,66; 25 | --ion-color-tertiary-contrast: #fff; 26 | --ion-color-tertiary-contrast-rgb: 255,255,255; 27 | --ion-color-tertiary-shade: #d7953a; 28 | --ion-color-tertiary-tint: #f5b255; 29 | 30 | /** success **/ 31 | --ion-color-success: #10dc60; 32 | --ion-color-success-rgb: 16,220,96; 33 | --ion-color-success-contrast: #fff; 34 | --ion-color-success-contrast-rgb: 255,255,255; 35 | --ion-color-success-shade: #0ec254; 36 | --ion-color-success-tint: #28e070; 37 | 38 | /** warning **/ 39 | --ion-color-warning: #ffce00; 40 | --ion-color-warning-rgb: 255,206,0; 41 | --ion-color-warning-contrast: #000; 42 | --ion-color-warning-contrast-rgb: 0,0,0; 43 | --ion-color-warning-shade: #e0b500; 44 | --ion-color-warning-tint: #ffd31a; 45 | 46 | /** danger **/ 47 | --ion-color-danger: #f53d3d; 48 | --ion-color-danger-rgb: 245,61,61; 49 | --ion-color-danger-contrast: #fff; 50 | --ion-color-danger-contrast-rgb: 255,255,255; 51 | --ion-color-danger-shade: #d83636; 52 | --ion-color-danger-tint: #f65050; 53 | 54 | /** light **/ 55 | --ion-color-light: #f4f4f4; 56 | --ion-color-light-rgb: 244,244,244; 57 | --ion-color-light-contrast: #000; 58 | --ion-color-light-contrast-rgb: 0,0,0; 59 | --ion-color-light-shade: #d7d7d7; 60 | --ion-color-light-tint: #f5f5f5; 61 | 62 | /** medium **/ 63 | --ion-color-medium: #989aa2; 64 | --ion-color-medium-rgb: 152,154,162; 65 | --ion-color-medium-contrast: #000; 66 | --ion-color-medium-contrast-rgb: 0,0,0; 67 | --ion-color-medium-shade: #86888f; 68 | --ion-color-medium-tint: #a2a4ab; 69 | 70 | /** dark **/ 71 | --ion-color-dark: #222; 72 | --ion-color-dark-rgb: 34,34,34; 73 | --ion-color-dark-contrast: #fff; 74 | --ion-color-dark-contrast-rgb: 255,255,255; 75 | --ion-color-dark-shade: #1e1e1e; 76 | --ion-color-dark-tint: #383838; 77 | } -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015" 7 | }, 8 | "exclude": [ 9 | "test.ts", 10 | "**/*.spec.ts" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "types": [ 8 | "jasmine", 9 | "node" 10 | ] 11 | }, 12 | "files": [ 13 | "test.ts" 14 | ], 15 | "include": [ 16 | "polyfills.ts", 17 | "**/*.spec.ts", 18 | "**/*.d.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "lib": [ 12 | "es2017", 13 | "dom" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-spacing": true, 20 | "indent": [ 21 | true, 22 | "spaces" 23 | ], 24 | "interface-over-type-literal": true, 25 | "label-position": true, 26 | "max-line-length": [ 27 | true, 28 | 140 29 | ], 30 | "member-access": false, 31 | "member-ordering": [ 32 | true, 33 | { 34 | "order": [ 35 | "static-field", 36 | "instance-field", 37 | "static-method", 38 | "instance-method" 39 | ] 40 | } 41 | ], 42 | "no-arg": true, 43 | "no-bitwise": true, 44 | "no-console": [ 45 | true, 46 | "debug", 47 | "info", 48 | "time", 49 | "timeEnd", 50 | "trace" 51 | ], 52 | "no-construct": true, 53 | "no-debugger": true, 54 | "no-duplicate-super": true, 55 | "no-empty": false, 56 | "no-empty-interface": true, 57 | "no-eval": true, 58 | "no-inferrable-types": [ 59 | true, 60 | "ignore-params" 61 | ], 62 | "no-misused-new": true, 63 | "no-non-null-assertion": true, 64 | "no-shadowed-variable": true, 65 | "no-string-literal": false, 66 | "no-string-throw": true, 67 | "no-switch-case-fall-through": true, 68 | "no-trailing-whitespace": true, 69 | "no-unnecessary-initializer": true, 70 | "no-unused-expression": true, 71 | "no-use-before-declare": true, 72 | "no-var-keyword": true, 73 | "object-literal-sort-keys": false, 74 | "one-line": [ 75 | true, 76 | "check-open-brace", 77 | "check-catch", 78 | "check-else", 79 | "check-whitespace" 80 | ], 81 | "prefer-const": true, 82 | "quotemark": [ 83 | true, 84 | "single" 85 | ], 86 | "radix": true, 87 | "semicolon": [ 88 | true, 89 | "always" 90 | ], 91 | "triple-equals": [ 92 | true, 93 | "allow-null-check" 94 | ], 95 | "typedef-whitespace": [ 96 | true, 97 | { 98 | "call-signature": "nospace", 99 | "index-signature": "nospace", 100 | "parameter": "nospace", 101 | "property-declaration": "nospace", 102 | "variable-declaration": "nospace" 103 | } 104 | ], 105 | "unified-signatures": true, 106 | "variable-name": false, 107 | "whitespace": [ 108 | true, 109 | "check-branch", 110 | "check-decl", 111 | "check-operator", 112 | "check-separator", 113 | "check-type" 114 | ], 115 | "directive-selector": [ 116 | true, 117 | "attribute", 118 | "app", 119 | "camelCase" 120 | ], 121 | "component-selector": [ 122 | true, 123 | "element", 124 | "app", 125 | "page", 126 | "kebab-case" 127 | ], 128 | "no-output-on-prefix": true, 129 | "use-input-property-decorator": true, 130 | "use-output-property-decorator": true, 131 | "use-host-property-decorator": true, 132 | "no-input-rename": true, 133 | "no-output-rename": true, 134 | "use-life-cycle-interface": true, 135 | "use-pipe-transform-interface": true, 136 | "directive-class-suffix": true 137 | } 138 | } 139 | --------------------------------------------------------------------------------