|
| 1 | + |
| 2 | +== Getting started |
| 3 | +=== Description |
| 4 | + |
| 5 | +This is link:https://github.com/facebook/react-native[react-native] wrapper for link:https://github.com/EspressifApp[ESP8266 ESPTOUCH Smart config] |
| 6 | + |
| 7 | +=== Featues |
| 8 | +* Support both IOS and Android |
| 9 | +* React Native Promise support |
| 10 | +* Fast way to do configure wifi network for IOT device |
| 11 | + |
| 12 | +=== Mostly automatic install |
| 13 | +1. `npm install rnpm --global` |
| 14 | +2. `npm install react-native-smartconfig@latest --save` |
| 15 | +3. `rnpm link react-native-smartconfig` |
| 16 | + |
| 17 | +=== Manual install |
| 18 | +==== iOS |
| 19 | +1. `npm install react-native-smartconfig@latest --save` |
| 20 | +2. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` |
| 21 | +3. Go to `node_modules` ➜ `react-native-smartconfig` and add `RCTSmartconfig.xcodeproj` |
| 22 | +4. In XCode, in the project navigator, select your project. Add `libRCTSmartconfig.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` |
| 23 | +5. Click `RCTSmartconfig.xcodeproj` in the project navigator and go the `Build Settings` tab. Make sure 'All' is toggled on (instead of 'Basic'). In the `Search Paths` section, look for `Header Search Paths` and make sure it contains both `$(SRCROOT)/../../react-native/React` - mark as `recursive`. |
| 24 | +5. Run your project (`Cmd+R`) |
| 25 | + |
| 26 | + |
| 27 | +==== Android |
| 28 | + |
| 29 | +1. `npm install react-native-smartconfig@latest --save` |
| 30 | +2. Modify the ReactInstanceManager.builder() calls chain in `android/app/main/java/.../MainActivity.java` to include: |
| 31 | + |
| 32 | +[source, javascript] |
| 33 | +---- |
| 34 | +import com.tuanpm.RCTSmartconfig; // import |
| 35 | +
|
| 36 | +
|
| 37 | +.addPackage(new RCTSmartconfigPackage()) //for older version |
| 38 | +
|
| 39 | +new RCTSmartconfigPackage() // for newest version of react-native |
| 40 | +---- |
| 41 | + |
| 42 | +3. Append the following lines to `android/settings.gradle` before `include ':app'`: |
| 43 | + |
| 44 | +[source, java] |
| 45 | +---- |
| 46 | +include ':react-native-smartconfig' |
| 47 | +project(':react-native-smartconfig').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-smartconfig/android') |
| 48 | +---- |
| 49 | + |
| 50 | +4. Insert the following lines inside the dependencies block in `android/app/build.gradle`, don't missing `apply plugin:'java'` on top: |
| 51 | + |
| 52 | +[source, java] |
| 53 | +---- |
| 54 | +
|
| 55 | +compile project(':react-native-smartconfig') |
| 56 | +---- |
| 57 | + |
| 58 | +Notes: |
| 59 | +[source, java] |
| 60 | +---- |
| 61 | +dependencies { |
| 62 | + compile project(':react-native-smartconfig') |
| 63 | +} |
| 64 | +---- |
| 65 | + |
| 66 | +[WARNING] |
| 67 | +But not like this |
| 68 | +[source, java] |
| 69 | +---- |
| 70 | +buildscript { |
| 71 | + ... |
| 72 | + dependencies { |
| 73 | + compile project(':react-native-smartconfig') |
| 74 | + } |
| 75 | +} |
| 76 | +---- |
| 77 | + |
| 78 | +== Usage |
| 79 | + |
| 80 | +* Normal |
| 81 | +[source, javascript] |
| 82 | +---- |
| 83 | +var Smartconfig = require('react-native').NativeModules.Smartconfig; |
| 84 | +Smartconfig.start({ |
| 85 | + type: 'esptouch', //or airkiss, now doesn't not effect |
| 86 | + ssid: 'wifi-network-ssid', |
| 87 | + bssid: 'filter-device', //null if not need to filter |
| 88 | + password: 'wifi-password', |
| 89 | + timeout: 50000 //now doesn't not effect |
| 90 | +}).then(results) { |
| 91 | + //Array of device success do smartconfig |
| 92 | + console.log(results); |
| 93 | + /*[ |
| 94 | + { |
| 95 | + 'bssid': 'device-bssi1', //device bssid |
| 96 | + 'ipv4': '192.168.1.11' //local ip address |
| 97 | + }, |
| 98 | + { |
| 99 | + 'bssid': 'device-bssi2', //device bssid |
| 100 | + 'ipv4': '192.168.1.12' //local ip address |
| 101 | + }, |
| 102 | + ... |
| 103 | + ]*/ |
| 104 | +}.catch(error) { |
| 105 | +
|
| 106 | +}; |
| 107 | +
|
| 108 | +Smartconfig.stop(); //interrupt task |
| 109 | +---- |
| 110 | + |
| 111 | +=== Todo |
| 112 | + |
| 113 | +* [ ] Support automatic get current wifi network ssid |
| 114 | +* [ ] Set timeout effect |
| 115 | +* [ ] Support airkiss |
| 116 | + |
| 117 | +=== LICENSE |
| 118 | + |
| 119 | +``` |
| 120 | + The MIT License (MIT) |
| 121 | + |
| 122 | + Copyright (c) 2015 <TuanPM> https://twitter.com/tuanpmt |
| 123 | + |
| 124 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 125 | + of this software and associated documentation files (the "Software"), to deal |
| 126 | + in the Software without restriction, including without limitation the rights |
| 127 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 128 | + copies of the Software, and to permit persons to whom the Software is |
| 129 | + furnished to do so, subject to the following conditions: |
| 130 | + |
| 131 | + The above copyright notice and this permission notice shall be included in all |
| 132 | + copies or substantial portions of the Software. |
| 133 | + |
| 134 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 135 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 136 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 137 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 138 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 139 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 140 | + SOFTWARE. |
| 141 | +``` |
0 commit comments