├── WinBle
├── .gitignore
├── WinBleHost
│ ├── .gitignore
│ ├── App.config
│ ├── IWcfCentralCallback.cs
│ ├── IWcfPeripheralCallback.cs
│ ├── IWcfCentralHost.cs
│ ├── IWcfPeripheralHost.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Utils.cs
│ └── WinBleHost.csproj
├── WinBleHandler
│ ├── .gitignore
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── HandlerBase.cs
│ ├── WinBleHandler.csproj
│ ├── CentralHandler.cs
│ └── PeripheralHandler.cs
└── WinBle.sln
├── BleSockPlugin
├── ProjectSettings
│ ├── ProjectVersion.txt
│ ├── ClusterInputManager.asset
│ ├── NetworkManager.asset
│ ├── TimeManager.asset
│ ├── AudioManager.asset
│ ├── TagManager.asset
│ ├── EditorBuildSettings.asset
│ ├── EditorSettings.asset
│ ├── PresetManager.asset
│ ├── UnityConnectSettings.asset
│ ├── DynamicsManager.asset
│ ├── Physics2DSettings.asset
│ ├── NavMeshAreas.asset
│ ├── GraphicsSettings.asset
│ ├── InputManager.asset
│ ├── QualitySettings.asset
│ └── ProjectSettings.asset
├── Externals
│ └── Windows10
│ │ ├── WinBleHost.exe
│ │ └── WinBleHost.exe.config
├── Assets
│ ├── Plugins
│ │ ├── BleSock
│ │ │ ├── Windows
│ │ │ │ ├── WinBleHandler.dll
│ │ │ │ └── WinBleHandler.dll.meta
│ │ │ ├── Android.meta
│ │ │ ├── Windows.meta
│ │ │ ├── iOS.meta
│ │ │ ├── Central.cs.meta
│ │ │ ├── GuestPeer.cs.meta
│ │ │ ├── HostPeer.cs.meta
│ │ │ ├── PeerBase.cs.meta
│ │ │ ├── Player.cs.meta
│ │ │ ├── Android
│ │ │ │ ├── Buffer.java
│ │ │ │ ├── CentralCallback.java
│ │ │ │ ├── PeripheralCallback.java
│ │ │ │ ├── Utils.java.meta
│ │ │ │ ├── Buffer.java.meta
│ │ │ │ ├── CentralCallback.java.meta
│ │ │ │ ├── CentralImpl.java.meta
│ │ │ │ ├── PeripheralImpl.java.meta
│ │ │ │ ├── PeripheralCallback.java.meta
│ │ │ │ └── Utils.java
│ │ │ ├── AndroidUtils.cs.meta
│ │ │ ├── MessageBuffer.cs.meta
│ │ │ ├── Peripheral.cs.meta
│ │ │ ├── Player.cs
│ │ │ ├── AndroidUtils.cs
│ │ │ ├── iOS
│ │ │ │ ├── CentralImpl.swift.meta
│ │ │ │ ├── CentralImpl.mm.meta
│ │ │ │ ├── PeripheralImpl.mm.meta
│ │ │ │ ├── PeripheralImpl.swift.meta
│ │ │ │ ├── CentralImpl.mm
│ │ │ │ └── PeripheralImpl.mm
│ │ │ ├── PeerBase.cs
│ │ │ ├── MessageBuffer.cs
│ │ │ ├── GuestPeer.cs
│ │ │ └── HostPeer.cs
│ │ ├── Android.meta
│ │ ├── Android
│ │ │ ├── AndroidManifest.xml.meta
│ │ │ └── AndroidManifest.xml
│ │ ├── BleSock.meta
│ │ ├── Editor.meta
│ │ └── Editor
│ │ │ ├── BleSockXcodePostProcessBuild.cs.meta
│ │ │ └── BleSockXcodePostProcessBuild.cs
│ ├── Demos
│ │ ├── Start.unity.meta
│ │ ├── ChatTest
│ │ │ ├── ChatTest.unity.meta
│ │ │ ├── ChatTest.cs.meta
│ │ │ └── ChatTest.cs
│ │ ├── GameTest
│ │ │ ├── GameTest.unity.meta
│ │ │ ├── Bullet.cs.meta
│ │ │ ├── GameTest.cs.meta
│ │ │ ├── PlayerCharacter.cs.meta
│ │ │ ├── Bullet.cs
│ │ │ └── PlayerCharacter.cs
│ │ ├── SpeedTest
│ │ │ ├── SpeedTest.unity.meta
│ │ │ ├── SpeedTest.cs.meta
│ │ │ └── SpeedTest.cs
│ │ ├── ChatTest.meta
│ │ ├── GameTest.meta
│ │ ├── SpeedTest.meta
│ │ ├── StartController.cs.meta
│ │ └── StartController.cs
│ ├── Demos.meta
│ └── Plugins.meta
├── .gitattributes
├── .gitignore
└── Packages
│ └── manifest.json
├── LICENSE
└── README.md
/WinBle/.gitignore:
--------------------------------------------------------------------------------
1 | /.vs
2 | /bin
3 | /obj
4 | *.user
5 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/.gitignore:
--------------------------------------------------------------------------------
1 | /.vs
2 | /bin
3 | /obj
4 | *.user
5 |
--------------------------------------------------------------------------------
/WinBle/WinBleHandler/.gitignore:
--------------------------------------------------------------------------------
1 | /.vs
2 | /bin
3 | /obj
4 | *.user
5 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 2018.2.5f1
2 |
--------------------------------------------------------------------------------
/BleSockPlugin/Externals/Windows10/WinBleHost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xflagstudio/blesock-unity-plugin/HEAD/BleSockPlugin/Externals/Windows10/WinBleHost.exe
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Windows/WinBleHandler.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xflagstudio/blesock-unity-plugin/HEAD/BleSockPlugin/Assets/Plugins/BleSock/Windows/WinBleHandler.dll
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!236 &1
4 | ClusterInputManager:
5 | m_ObjectHideFlags: 0
6 | m_Inputs: []
7 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/Start.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 09a7600299322d94b822d5f4ff1abe86
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/BleSockPlugin/.gitattributes:
--------------------------------------------------------------------------------
1 | *.mat eol=lf
2 | *.anim eol=lf
3 | *.unity eol=lf
4 | *.prefab eol=lf
5 | *.physicsMaterial2D eol=lf
6 | *.physicsMaterial eol=lf
7 | *.asset eol=lf
8 | *.meta eol=lf
9 | *.controller eol=lf
10 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/NetworkManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!149 &1
4 | NetworkManager:
5 | m_ObjectHideFlags: 0
6 | m_DebugLevel: 0
7 | m_Sendrate: 15
8 | m_AssetToPrefab: {}
9 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4f704ae4b4f98ae41a0bce26658850c1
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/ChatTest/ChatTest.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 99c9720ab356a0642a771bea13969a05
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/GameTest/GameTest.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 54ec2afd473f4c245ac940c7cd2d8271
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 586f7819154b0aa4b9a64e94d0b2819c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/SpeedTest/SpeedTest.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5e53b148b1985a84dbae1d8515b87bfb
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/ChatTest.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2e24188583c9e5140a795a27bef19c4e
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/GameTest.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4a7040d6267007b4d9a2cc2e4e8a3bd5
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/SpeedTest.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ed6765c36ccce2b498f2dbcc38b7790a
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/Android.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3782f3e78d39d70479d590b9ee0ee57b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/Android/AndroidManifest.xml.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e4ac1abd913500a40a66b29a564f429e
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 66fcaf6745814c24997e916762b09557
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3d4263bf7b8c64e2da3fcc6505e0109f
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b812affbc3354564fad8b72551727e90
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Windows.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e19cbe96506df8c4c8d0acfe67fd2703
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/iOS.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 74964a9d66d2243149d3384f94d7031a
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/BleSockPlugin/Externals/Windows10/WinBleHost.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!5 &1
4 | TimeManager:
5 | m_ObjectHideFlags: 0
6 | Fixed Timestep: 0.02
7 | Maximum Allowed Timestep: 0.1
8 | m_TimeScale: 1
9 | Maximum Particle Timestep: 0.03
10 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/ChatTest/ChatTest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0da53f406830d734fbec0963a5ba086a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/GameTest/Bullet.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f84b180ce27a066449b369d2b57c5a38
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/GameTest/GameTest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2c6c8651c81d23f4ab23acc6b1bb6a45
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/SpeedTest/SpeedTest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3a369261272c42448a99a774029619ae
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/StartController.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a04cf88a99672fc46ab8068ff83cd0ea
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Central.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2ee4f9e04219ae74cbbcfca0bc8f3233
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/GuestPeer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 95bb72bcee3289a4793bb9b618ef4003
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/HostPeer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cdfab594a5590604fb68096fc480ba78
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/PeerBase.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 330d1893c11269d47988caf40275a083
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Player.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9a8957b9420d52e41b21a5329b8a9eb7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/GameTest/PlayerCharacter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1de3cabab38212748a30f350c90e749b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/Buffer.java:
--------------------------------------------------------------------------------
1 | package xflag.plugins.bleSock;
2 |
3 | public final class Buffer {
4 |
5 | private byte[] mBytes;
6 |
7 | public byte[] getBytes() {
8 |
9 | return mBytes;
10 | }
11 |
12 | public Buffer(byte[] bytes) {
13 |
14 | mBytes = bytes;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/AndroidUtils.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a3a97635cfbf74249b98c65e52f65fa1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/MessageBuffer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 041a30ea900f8384fb4016c8f1e2e16b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Peripheral.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4b1498e13703f864b84abf771952ba64
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/.gitignore:
--------------------------------------------------------------------------------
1 | # Unity Project
2 | [Ll]ibrary/
3 | [Tt]emp/
4 | [Bb]uild/
5 | [Oo]bj/
6 | [Ll]og/
7 | *.csproj
8 | *.unityproj
9 | *.sln
10 | *.suo
11 | *.userprefs
12 | *.usertasks
13 |
14 | # OSX
15 | .DS_Store
16 | *.swp
17 |
18 | # Android Build
19 | *.apk
20 |
21 | # iOS Build
22 | *.ipa
23 | *.dSYM.zip
24 |
25 | # Visual Studio
26 | .vs/
27 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/Editor/BleSockXcodePostProcessBuild.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f08dd1e195cbe9e41aaee2eba167bc45
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/CentralCallback.java:
--------------------------------------------------------------------------------
1 | package xflag.plugins.bleSock;
2 |
3 | public interface CentralCallback {
4 |
5 | public void onBluetoothRequire();
6 | public void onReady();
7 | public void onFail();
8 |
9 | public void onDiscover(String deviceName, int deviceId);
10 | public void onConnect();
11 | public void onDisconnect();
12 |
13 | public void onReceive(Buffer message, int from);
14 | }
15 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!11 &1
4 | AudioManager:
5 | m_ObjectHideFlags: 0
6 | m_Volume: 1
7 | Rolloff Scale: 1
8 | Doppler Factor: 1
9 | Default Speaker Mode: 2
10 | m_SampleRate: 0
11 | m_DSPBufferSize: 1024
12 | m_VirtualVoiceCount: 512
13 | m_RealVoiceCount: 32
14 | m_SpatializerPlugin:
15 | m_AmbisonicDecoderPlugin:
16 | m_DisableAudio: 0
17 | m_VirtualizeEffects: 1
18 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/PeripheralCallback.java:
--------------------------------------------------------------------------------
1 | package xflag.plugins.bleSock;
2 |
3 | public interface PeripheralCallback {
4 |
5 | public void onBluetoothRequire();
6 | public void onReady();
7 | public void onFail();
8 |
9 | public void onConnect(int connectionId);
10 | public void onDisconnect(int connectionId);
11 |
12 | public void onReceiveDirect(Buffer message, int connectionId);
13 | public void onReceive(Buffer message, int playerId);
14 | }
15 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!78 &1
4 | TagManager:
5 | serializedVersion: 2
6 | tags: []
7 | layers:
8 | - Default
9 | - TransparentFX
10 | - Ignore Raycast
11 | -
12 | - Water
13 | - UI
14 | -
15 | -
16 | - PostProcessing
17 | -
18 | -
19 | -
20 | -
21 | -
22 | -
23 | -
24 | -
25 | -
26 | -
27 | -
28 | -
29 | -
30 | -
31 | -
32 | -
33 | -
34 | -
35 | -
36 | -
37 | -
38 | -
39 | -
40 | m_SortingLayers:
41 | - name: Default
42 | uniqueID: 0
43 | locked: 0
44 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1045 &1
4 | EditorBuildSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Scenes:
8 | - enabled: 1
9 | path: Assets/Demos/Start.unity
10 | guid: 09a7600299322d94b822d5f4ff1abe86
11 | - enabled: 1
12 | path: Assets/Demos/ChatTest/ChatTest.unity
13 | guid: 99c9720ab356a0642a771bea13969a05
14 | - enabled: 1
15 | path: Assets/Demos/GameTest/GameTest.unity
16 | guid: 54ec2afd473f4c245ac940c7cd2d8271
17 | - enabled: 1
18 | path: Assets/Demos/SpeedTest/SpeedTest.unity
19 | guid: 5e53b148b1985a84dbae1d8515b87bfb
20 | m_configObjects: {}
21 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/StartController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using UnityEngine;
4 | using UnityEngine.SceneManagement;
5 | using UnityEngine.UI;
6 |
7 | public class StartController : MonoBehaviour
8 | {
9 | [Serializable]
10 | public class ButtonInfo
11 | {
12 | public Button button;
13 | public string sceneName;
14 | }
15 |
16 | public ButtonInfo[] buttonInfos;
17 |
18 |
19 | private void Start()
20 | {
21 | foreach (var info in buttonInfos)
22 | {
23 | info.button.onClick.AddListener(() =>
24 | {
25 | SceneManager.LoadScene(info.sceneName);
26 | });
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/Utils.java.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b2240a35479e7824d90406db2351bb7b
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | Android: Android
13 | second:
14 | enabled: 1
15 | settings: {}
16 | - first:
17 | Any:
18 | second:
19 | enabled: 0
20 | settings: {}
21 | - first:
22 | Editor: Editor
23 | second:
24 | enabled: 0
25 | settings:
26 | DefaultValueInitialized: true
27 | userData:
28 | assetBundleName:
29 | assetBundleVariant:
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/Buffer.java.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a6f644cbe3a9b124ea09acc8bec3a41d
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | Android: Android
13 | second:
14 | enabled: 1
15 | settings: {}
16 | - first:
17 | Any:
18 | second:
19 | enabled: 0
20 | settings: {}
21 | - first:
22 | Editor: Editor
23 | second:
24 | enabled: 0
25 | settings:
26 | DefaultValueInitialized: true
27 | userData:
28 | assetBundleName:
29 | assetBundleVariant:
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/CentralCallback.java.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: daa6eb454a0790d4f993c6fdf810aad8
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | Android: Android
13 | second:
14 | enabled: 1
15 | settings: {}
16 | - first:
17 | Any:
18 | second:
19 | enabled: 0
20 | settings: {}
21 | - first:
22 | Editor: Editor
23 | second:
24 | enabled: 0
25 | settings:
26 | DefaultValueInitialized: true
27 | userData:
28 | assetBundleName:
29 | assetBundleVariant:
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/CentralImpl.java.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1c061723428b5eb4b9db4ced95b83ca9
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | Android: Android
13 | second:
14 | enabled: 1
15 | settings: {}
16 | - first:
17 | Any:
18 | second:
19 | enabled: 0
20 | settings: {}
21 | - first:
22 | Editor: Editor
23 | second:
24 | enabled: 0
25 | settings:
26 | DefaultValueInitialized: true
27 | userData:
28 | assetBundleName:
29 | assetBundleVariant:
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/PeripheralImpl.java.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 04ad130e2182abc42a947471f21b5c7c
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | Android: Android
13 | second:
14 | enabled: 1
15 | settings: {}
16 | - first:
17 | Any:
18 | second:
19 | enabled: 0
20 | settings: {}
21 | - first:
22 | Editor: Editor
23 | second:
24 | enabled: 0
25 | settings:
26 | DefaultValueInitialized: true
27 | userData:
28 | assetBundleName:
29 | assetBundleVariant:
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/PeripheralCallback.java.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5841b20c9c7ea7146a2aef661ad64f71
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | Android: Android
13 | second:
14 | enabled: 1
15 | settings: {}
16 | - first:
17 | Any:
18 | second:
19 | enabled: 0
20 | settings: {}
21 | - first:
22 | Editor: Editor
23 | second:
24 | enabled: 0
25 | settings:
26 | DefaultValueInitialized: true
27 | userData:
28 | assetBundleName:
29 | assetBundleVariant:
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!159 &1
4 | EditorSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 7
7 | m_ExternalVersionControlSupport: Visible Meta Files
8 | m_SerializationMode: 2
9 | m_LineEndingsForNewScripts: 2
10 | m_DefaultBehaviorMode: 0
11 | m_SpritePackerMode: 0
12 | m_SpritePackerPaddingPower: 1
13 | m_EtcTextureCompressorBehavior: 1
14 | m_EtcTextureFastCompressor: 1
15 | m_EtcTextureNormalCompressor: 2
16 | m_EtcTextureBestCompressor: 4
17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd
18 | m_ProjectGenerationRootNamespace:
19 | m_UserGeneratedProjectSuffix:
20 | m_CollabEditorSettings:
21 | inProgressEnabled: 1
22 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Player.cs:
--------------------------------------------------------------------------------
1 | namespace BleSock
2 | {
3 | public class Player
4 | {
5 | // Properties
6 |
7 | public int PlayerId
8 | {
9 | get
10 | {
11 | return mPlayerId;
12 | }
13 | }
14 |
15 | public string PlayerName
16 | {
17 | get
18 | {
19 | return mPlayerName;
20 | }
21 | }
22 |
23 | public object LocalData { get; set; }
24 |
25 | // Constructor
26 |
27 | internal Player(int playerId, string playerName)
28 | {
29 | mPlayerId = playerId;
30 | mPlayerName = playerName;
31 | }
32 |
33 | // Internal
34 |
35 | private int mPlayerId;
36 | private string mPlayerName;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/IWcfCentralCallback.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace BleSock.Windows
4 | {
5 | [ServiceContract]
6 | internal interface IWcfCentralCallback
7 | {
8 | [OperationContract(IsOneWay = true)]
9 | void OnBluetoothRequire();
10 |
11 | [OperationContract(IsOneWay = true)]
12 | void OnReady();
13 |
14 | [OperationContract(IsOneWay = true)]
15 | void OnFail();
16 |
17 | [OperationContract(IsOneWay = true)]
18 | void OnDiscover(string deviceName, int deviceId);
19 |
20 | [OperationContract(IsOneWay = true)]
21 | void OnConnect();
22 |
23 | [OperationContract(IsOneWay = true)]
24 | void OnDisconnect();
25 |
26 | [OperationContract(IsOneWay = true)]
27 | void OnReceive(byte[] message, int sender);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/IWcfPeripheralCallback.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace BleSock.Windows
4 | {
5 | [ServiceContract]
6 | internal interface IWcfPeripheralCallback
7 | {
8 | [OperationContract(IsOneWay = true)]
9 | void OnBluetoothRequire();
10 |
11 | [OperationContract(IsOneWay = true)]
12 | void OnReady();
13 |
14 | [OperationContract(IsOneWay = true)]
15 | void OnFail();
16 |
17 | [OperationContract(IsOneWay = true)]
18 | void OnConnect(int connectionId);
19 |
20 | [OperationContract(IsOneWay = true)]
21 | void OnDisconnect(int connectionId);
22 |
23 | [OperationContract(IsOneWay = true)]
24 | void OnReceiveDirect(byte[] message, int connectionId);
25 |
26 | [OperationContract(IsOneWay = true)]
27 | void OnReceive(byte[] message, int sender);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/PresetManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1386491679 &1
4 | PresetManager:
5 | m_ObjectHideFlags: 0
6 | m_DefaultList:
7 | - type:
8 | m_NativeTypeID: 108
9 | m_ManagedTypePPtr: {fileID: 0}
10 | m_ManagedTypeFallback:
11 | defaultPresets:
12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea,
13 | type: 2}
14 | - type:
15 | m_NativeTypeID: 1020
16 | m_ManagedTypePPtr: {fileID: 0}
17 | m_ManagedTypeFallback:
18 | defaultPresets:
19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6,
20 | type: 2}
21 | - type:
22 | m_NativeTypeID: 1006
23 | m_ManagedTypePPtr: {fileID: 0}
24 | m_ManagedTypeFallback:
25 | defaultPresets:
26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9,
27 | type: 2}
28 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!310 &1
4 | UnityConnectSettings:
5 | m_ObjectHideFlags: 0
6 | m_Enabled: 1
7 | m_TestMode: 0
8 | m_TestEventUrl:
9 | m_TestConfigUrl:
10 | m_TestInitMode: 0
11 | CrashReportingSettings:
12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes
13 | m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate
14 | m_Enabled: 0
15 | m_CaptureEditorExceptions: 1
16 | UnityPurchasingSettings:
17 | m_Enabled: 0
18 | m_TestMode: 0
19 | UnityAnalyticsSettings:
20 | m_Enabled: 1
21 | m_InitializeOnStartup: 1
22 | m_TestMode: 0
23 | m_TestEventUrl:
24 | m_TestConfigUrl:
25 | UnityAdsSettings:
26 | m_Enabled: 0
27 | m_InitializeOnStartup: 1
28 | m_TestMode: 0
29 | m_IosGameId:
30 | m_AndroidGameId:
31 | m_GameIds: {}
32 | m_GameId:
33 | PerformanceReportingSettings:
34 | m_Enabled: 0
35 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/IWcfCentralHost.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace BleSock.Windows
4 | {
5 | [ServiceContract(CallbackContract = typeof(IWcfCentralCallback))]
6 | internal interface IWcfCentralHost
7 | {
8 | [OperationContract(IsOneWay = false)]
9 | bool Initialize(string serviceUUID, string uploadUUID, string downloadUUID);
10 |
11 | [OperationContract(IsOneWay = false)]
12 | bool StartScan();
13 |
14 | [OperationContract(IsOneWay = true)]
15 | void StopScan();
16 |
17 | [OperationContract(IsOneWay = false)]
18 | bool Connect(int deviceId);
19 |
20 | [OperationContract(IsOneWay = true)]
21 | void Accept();
22 |
23 | [OperationContract(IsOneWay = true)]
24 | void Disconnect();
25 |
26 | [OperationContract(IsOneWay = true)]
27 | void Send(byte[] message, int messageSize, int receiver);
28 |
29 | [OperationContract(IsOneWay = true)]
30 | void Cleanup();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Android/Utils.java:
--------------------------------------------------------------------------------
1 | package xflag.plugins.bleSock;
2 |
3 | import android.bluetooth.BluetoothAdapter;
4 | import android.util.Log;
5 |
6 | import java.util.Locale;
7 |
8 | public final class Utils {
9 |
10 | public static boolean isBluetoothEnabled() {
11 |
12 | BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
13 | if (adapter == null) {
14 | return false;
15 | }
16 |
17 | return adapter.isEnabled();
18 | }
19 |
20 | public static boolean isPeripheralAvailable() {
21 |
22 | BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
23 | if (adapter == null) {
24 | return false;
25 | }
26 |
27 | return adapter.isMultipleAdvertisementSupported();
28 | }
29 |
30 | public static void info(String format, Object... args) {
31 |
32 | Log.i("BleSock", String.format(Locale.US, format, args));
33 | }
34 |
35 | public static void error(String format, Object... args) {
36 |
37 | Log.e("BleSock", String.format(Locale.US, format, args));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/IWcfPeripheralHost.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceModel;
2 |
3 | namespace BleSock.Windows
4 | {
5 | [ServiceContract(CallbackContract = typeof(IWcfPeripheralCallback))]
6 | internal interface IWcfPeripheralHost
7 | {
8 | [OperationContract(IsOneWay = false)]
9 | bool Initialize(string serviceUUID, string uploadUUID, string downloadUUID);
10 |
11 | [OperationContract(IsOneWay = false)]
12 | bool StartAdvertising(string deviceName);
13 |
14 | [OperationContract(IsOneWay = true)]
15 | void StopAdvertising();
16 |
17 | [OperationContract(IsOneWay = false)]
18 | bool Accept(int connectionId, int playerId);
19 |
20 | [OperationContract(IsOneWay = true)]
21 | void Invalidate(int connectionId);
22 |
23 | [OperationContract(IsOneWay = true)]
24 | void SendDirect(byte[] message, int messageSize, int connectionId);
25 |
26 | [OperationContract(IsOneWay = true)]
27 | void Send(byte[] message, int messageSize, int receiver);
28 |
29 | [OperationContract(IsOneWay = true)]
30 | void Cleanup();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 XFLAG Studio, mixi inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BleSock.Windows
4 | {
5 | class Program
6 | {
7 | static void Main(string[] args)
8 | {
9 | try
10 | {
11 | int portNumber = int.Parse(args[1]);
12 |
13 | if (args[0] == "Central")
14 | {
15 | using (var centralImpl = new CentralImpl())
16 | {
17 | centralImpl.Run(portNumber);
18 | }
19 | }
20 | else if (args[0] == "Peripheral")
21 | {
22 | using (var peripheralImpl = new PeripheralImpl())
23 | {
24 | peripheralImpl.Run(portNumber);
25 | }
26 | }
27 | else
28 | {
29 | Utils.Error("Invalid argument: {0}", args[0]);
30 | }
31 | }
32 | catch (Exception e)
33 | {
34 | Utils.Error(e.ToString());
35 | }
36 |
37 | Console.ReadKey();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/DynamicsManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!55 &1
4 | PhysicsManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 7
7 | m_Gravity: {x: 0, y: -9.81, z: 0}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_BounceThreshold: 2
10 | m_SleepThreshold: 0.005
11 | m_DefaultContactOffset: 0.01
12 | m_DefaultSolverIterations: 6
13 | m_DefaultSolverVelocityIterations: 1
14 | m_QueriesHitBackfaces: 0
15 | m_QueriesHitTriggers: 1
16 | m_EnableAdaptiveForce: 0
17 | m_ClothInterCollisionDistance: 0
18 | m_ClothInterCollisionStiffness: 0
19 | m_ContactsGeneration: 1
20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
21 | m_AutoSimulation: 1
22 | m_AutoSyncTransforms: 1
23 | m_ClothInterCollisionSettingsToggle: 0
24 | m_ContactPairsMode: 0
25 | m_BroadphaseType: 0
26 | m_WorldBounds:
27 | m_Center: {x: 0, y: 0, z: 0}
28 | m_Extent: {x: 250, y: 250, z: 250}
29 | m_WorldSubdivisions: 8
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/GameTest/Bullet.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.UI;
3 |
4 | public class Bullet : MonoBehaviour
5 | {
6 | public const float RADIUS = 10;
7 | public const float VELOCITY = 600;
8 |
9 |
10 | public Image baseImage;
11 |
12 | public int playerId;
13 | public int bulletId;
14 | public Vector2 velocity;
15 |
16 |
17 | public RectTransform rectTransform
18 | {
19 | get
20 | {
21 | return (RectTransform)transform;
22 | }
23 | }
24 |
25 | public Vector2 position
26 | {
27 | get
28 | {
29 | return rectTransform.anchoredPosition;
30 | }
31 | }
32 |
33 |
34 | private void Update()
35 | {
36 | rectTransform.anchoredPosition = position + velocity * Time.deltaTime;
37 | }
38 |
39 | public void Spawn(int playerId, int bulletId, Vector2 position, Vector2 velocity, Color color)
40 | {
41 | this.playerId = playerId;
42 | this.bulletId = bulletId;
43 | rectTransform.anchoredPosition = position;
44 | this.velocity = velocity;
45 | baseImage.color = color;
46 |
47 | gameObject.SetActive(true);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("WinBleHost")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("XFLAG")]
12 | [assembly: AssemblyProduct("WinBleHost")]
13 | [assembly: AssemblyCopyright("Copyright © XFLAG 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
18 | // 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
23 | [assembly: Guid("ba7a0382-c273-4f36-bf71-269668cb1757")]
24 |
25 | // アセンブリのバージョン情報は次の 4 つの値で構成されています:
26 | //
27 | // メジャー バージョン
28 | // マイナー バージョン
29 | // ビルド番号
30 | // Revision
31 | //
32 | // すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
33 | // 既定値にすることができます:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/WinBle/WinBleHandler/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
6 | // アセンブリに関連付けられている情報を変更するには、
7 | // これらの属性値を変更してください。
8 | [assembly: AssemblyTitle("WinBleHandler")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("XFLAG")]
12 | [assembly: AssemblyProduct("WinBleHandler")]
13 | [assembly: AssemblyCopyright("Copyright © XFLAG 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
18 | // 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
19 | // その型の ComVisible 属性を true に設定してください。
20 | [assembly: ComVisible(false)]
21 |
22 | // このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
23 | [assembly: Guid("2076e521-5575-4860-9139-54a487d12ade")]
24 |
25 | // アセンブリのバージョン情報は次の 4 つの値で構成されています:
26 | //
27 | // メジャー バージョン
28 | // マイナー バージョン
29 | // ビルド番号
30 | // Revision
31 | //
32 | // すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
33 | // 以下のように '*' を使用します:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/Physics2DSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!19 &1
4 | Physics2DSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 3
7 | m_Gravity: {x: 0, y: -9.81}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_VelocityIterations: 8
10 | m_PositionIterations: 3
11 | m_VelocityThreshold: 1
12 | m_MaxLinearCorrection: 0.2
13 | m_MaxAngularCorrection: 8
14 | m_MaxTranslationSpeed: 100
15 | m_MaxRotationSpeed: 360
16 | m_BaumgarteScale: 0.2
17 | m_BaumgarteTimeOfImpactScale: 0.75
18 | m_TimeToSleep: 0.5
19 | m_LinearSleepTolerance: 0.01
20 | m_AngularSleepTolerance: 2
21 | m_DefaultContactOffset: 0.01
22 | m_AutoSimulation: 1
23 | m_QueriesHitTriggers: 1
24 | m_QueriesStartInColliders: 1
25 | m_ChangeStopsCallbacks: 0
26 | m_CallbacksOnDisable: 1
27 | m_AutoSyncTransforms: 1
28 | m_AlwaysShowColliders: 0
29 | m_ShowColliderSleep: 1
30 | m_ShowColliderContacts: 0
31 | m_ShowColliderAABB: 0
32 | m_ContactArrowScale: 0.2
33 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412}
34 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
35 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
36 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
37 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
38 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/AndroidUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using UnityEngine;
4 |
5 | namespace BleSock
6 | {
7 |
8 | #if UNITY_ANDROID && !UNITY_EDITOR
9 |
10 | internal static class AndroidUtils
11 | {
12 | // Methods
13 |
14 | public static bool IsBluetoothEnabled
15 | {
16 | get
17 | {
18 | try
19 | {
20 | using (var utils = new AndroidJavaClass(NAME_PREFIX + "Utils"))
21 | {
22 | return utils.CallStatic("isBluetoothEnabled");
23 | }
24 | }
25 | catch (Exception e)
26 | {
27 | Debug.LogException(e);
28 | }
29 |
30 | return false;
31 | }
32 | }
33 |
34 | public static bool IsPeripheralAvailable
35 | {
36 | get
37 | {
38 | try
39 | {
40 | using (var utils = new AndroidJavaClass(NAME_PREFIX + "Utils"))
41 | {
42 | return utils.CallStatic("isPeripheralAvailable");
43 | }
44 | }
45 | catch (Exception e)
46 | {
47 | Debug.LogException(e);
48 | }
49 |
50 | return false;
51 | }
52 | }
53 |
54 | // Internal
55 |
56 | private const string NAME_PREFIX = "xflag.plugins.bleSock.";
57 | }
58 |
59 | #endif
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/BleSockPlugin/Packages/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "com.unity.package-manager-ui": "1.9.11",
4 | "com.unity.textmeshpro": "1.2.4",
5 | "com.unity.modules.ai": "1.0.0",
6 | "com.unity.modules.animation": "1.0.0",
7 | "com.unity.modules.assetbundle": "1.0.0",
8 | "com.unity.modules.audio": "1.0.0",
9 | "com.unity.modules.cloth": "1.0.0",
10 | "com.unity.modules.director": "1.0.0",
11 | "com.unity.modules.imageconversion": "1.0.0",
12 | "com.unity.modules.imgui": "1.0.0",
13 | "com.unity.modules.jsonserialize": "1.0.0",
14 | "com.unity.modules.particlesystem": "1.0.0",
15 | "com.unity.modules.physics": "1.0.0",
16 | "com.unity.modules.physics2d": "1.0.0",
17 | "com.unity.modules.screencapture": "1.0.0",
18 | "com.unity.modules.terrain": "1.0.0",
19 | "com.unity.modules.terrainphysics": "1.0.0",
20 | "com.unity.modules.tilemap": "1.0.0",
21 | "com.unity.modules.ui": "1.0.0",
22 | "com.unity.modules.uielements": "1.0.0",
23 | "com.unity.modules.umbra": "1.0.0",
24 | "com.unity.modules.unityanalytics": "1.0.0",
25 | "com.unity.modules.unitywebrequest": "1.0.0",
26 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
27 | "com.unity.modules.unitywebrequestaudio": "1.0.0",
28 | "com.unity.modules.unitywebrequesttexture": "1.0.0",
29 | "com.unity.modules.unitywebrequestwww": "1.0.0",
30 | "com.unity.modules.vehicles": "1.0.0",
31 | "com.unity.modules.video": "1.0.0",
32 | "com.unity.modules.vr": "1.0.0",
33 | "com.unity.modules.wind": "1.0.0",
34 | "com.unity.modules.xr": "1.0.0"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/WinBle/WinBleHandler/HandlerBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Diagnostics;
4 |
5 | using UnityEngine;
6 |
7 | namespace BleSock.Windows
8 | {
9 | public abstract class HandlerBase : IDisposable
10 | {
11 | // Methods
12 |
13 | public virtual void Cleanup()
14 | {
15 | ShutdownProcess();
16 | }
17 |
18 | public virtual void Dispose()
19 | {
20 | Cleanup();
21 | }
22 |
23 | // Internal
24 |
25 | protected Process mProcess;
26 |
27 | protected void LaunchProcess(string executionFilePath, string arguments)
28 | {
29 | var startInfo = new ProcessStartInfo()
30 | {
31 | FileName = Path.Combine(Application.dataPath, executionFilePath),
32 | Arguments = arguments,
33 | // UseShellExecute = false,
34 | };
35 |
36 | mProcess = Process.Start(startInfo);
37 | mProcess.EnableRaisingEvents = true;
38 | mProcess.Exited += (sender, args) =>
39 | {
40 | OnProcessExited();
41 | };
42 | }
43 |
44 | protected void ShutdownProcess()
45 | {
46 | if (mProcess != null)
47 | {
48 | if (!mProcess.HasExited)
49 | {
50 | mProcess.Kill();
51 | }
52 |
53 | mProcess.Dispose();
54 | mProcess = null;
55 | }
56 | }
57 |
58 | protected virtual void OnProcessExited()
59 | {
60 | mProcess.Dispose();
61 | mProcess = null;
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/NavMeshAreas.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!126 &1
4 | NavMeshProjectSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | areas:
8 | - name: Walkable
9 | cost: 1
10 | - name: Not Walkable
11 | cost: 1
12 | - name: Jump
13 | cost: 2
14 | - name:
15 | cost: 1
16 | - name:
17 | cost: 1
18 | - name:
19 | cost: 1
20 | - name:
21 | cost: 1
22 | - name:
23 | cost: 1
24 | - name:
25 | cost: 1
26 | - name:
27 | cost: 1
28 | - name:
29 | cost: 1
30 | - name:
31 | cost: 1
32 | - name:
33 | cost: 1
34 | - name:
35 | cost: 1
36 | - name:
37 | cost: 1
38 | - name:
39 | cost: 1
40 | - name:
41 | cost: 1
42 | - name:
43 | cost: 1
44 | - name:
45 | cost: 1
46 | - name:
47 | cost: 1
48 | - name:
49 | cost: 1
50 | - name:
51 | cost: 1
52 | - name:
53 | cost: 1
54 | - name:
55 | cost: 1
56 | - name:
57 | cost: 1
58 | - name:
59 | cost: 1
60 | - name:
61 | cost: 1
62 | - name:
63 | cost: 1
64 | - name:
65 | cost: 1
66 | - name:
67 | cost: 1
68 | - name:
69 | cost: 1
70 | - name:
71 | cost: 1
72 | m_LastAgentTypeID: -887442657
73 | m_Settings:
74 | - serializedVersion: 2
75 | agentTypeID: 0
76 | agentRadius: 0.5
77 | agentHeight: 2
78 | agentSlope: 45
79 | agentClimb: 0.75
80 | ledgeDropHeight: 0
81 | maxJumpAcrossDistance: 0
82 | minRegionArea: 2
83 | manualCellSize: 0
84 | cellSize: 0.16666667
85 | manualTileSize: 0
86 | tileSize: 256
87 | accuratePlacement: 0
88 | debug:
89 | m_Flags: 0
90 | m_SettingNames:
91 | - Humanoid
92 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/Editor/BleSockXcodePostProcessBuild.cs:
--------------------------------------------------------------------------------
1 | #if UNITY_IOS
2 |
3 | using System.IO;
4 |
5 | using UnityEditor;
6 | using UnityEditor.Callbacks;
7 | using UnityEditor.iOS.Xcode;
8 |
9 | public static class BleSockXcodePostProcessBuild
10 | {
11 | [PostProcessBuild]
12 | static void OnPostProcessBuild(BuildTarget target, string path)
13 | {
14 | if (target != BuildTarget.iOS)
15 | {
16 | return;
17 | }
18 |
19 | // PBXProject
20 |
21 | string projectPath = PBXProject.GetPBXProjectPath(path);
22 | var project = new PBXProject();
23 | project.ReadFromFile(projectPath);
24 |
25 | string targetGuid = project.TargetGuidByName(PBXProject.GetUnityTargetName());
26 | project.AddCapability(targetGuid, PBXCapabilityType.BackgroundModes);
27 |
28 | project.SetBuildProperty(targetGuid, "SWIFT_OBJC_INTERFACE_HEADER_NAME", "Unity-Swift.h");
29 | project.SetBuildProperty(targetGuid, "SWIFT_VERSION", "4.0");
30 | project.SetBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");
31 |
32 | project.WriteToFile(projectPath);
33 |
34 | // Info.plist
35 |
36 | string plistPath = Path.Combine(path, "Info.plist");
37 | var plist = new PlistDocument();
38 | plist.ReadFromFile(plistPath);
39 |
40 | plist.root.SetString("NSBluetoothPeripheralUsageDescription", "To ad-hoc communicating");
41 |
42 | var backgroundModes = plist.root.CreateArray("UIBackgroundModes");
43 | backgroundModes.AddString("bluetooth-central");
44 | backgroundModes.AddString("bluetooth-peripheral");
45 |
46 | plist.WriteToFile(plistPath);
47 | }
48 | }
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/iOS/CentralImpl.swift.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3ae01a955d69e430d8fb3a43a5d1c9ca
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | '': Any
13 | second:
14 | enabled: 0
15 | settings:
16 | Exclude Android: 1
17 | Exclude Editor: 1
18 | Exclude Linux: 1
19 | Exclude Linux64: 1
20 | Exclude LinuxUniversal: 1
21 | Exclude OSXUniversal: 1
22 | Exclude Win: 1
23 | Exclude Win64: 1
24 | Exclude iOS: 0
25 | - first:
26 | Android: Android
27 | second:
28 | enabled: 0
29 | settings:
30 | CPU: ARMv7
31 | - first:
32 | Any:
33 | second:
34 | enabled: 0
35 | settings: {}
36 | - first:
37 | Editor: Editor
38 | second:
39 | enabled: 0
40 | settings:
41 | CPU: AnyCPU
42 | DefaultValueInitialized: true
43 | OS: AnyOS
44 | - first:
45 | Facebook: Win
46 | second:
47 | enabled: 0
48 | settings:
49 | CPU: AnyCPU
50 | - first:
51 | Facebook: Win64
52 | second:
53 | enabled: 0
54 | settings:
55 | CPU: AnyCPU
56 | - first:
57 | Standalone: Linux
58 | second:
59 | enabled: 0
60 | settings:
61 | CPU: x86
62 | - first:
63 | Standalone: Linux64
64 | second:
65 | enabled: 0
66 | settings:
67 | CPU: x86_64
68 | - first:
69 | Standalone: OSXUniversal
70 | second:
71 | enabled: 0
72 | settings:
73 | CPU: AnyCPU
74 | - first:
75 | Standalone: Win
76 | second:
77 | enabled: 0
78 | settings:
79 | CPU: AnyCPU
80 | - first:
81 | Standalone: Win64
82 | second:
83 | enabled: 0
84 | settings:
85 | CPU: AnyCPU
86 | - first:
87 | iPhone: iOS
88 | second:
89 | enabled: 1
90 | settings:
91 | AddToEmbeddedBinaries: false
92 | CompileFlags:
93 | FrameworkDependencies: CoreBluetooth;
94 | userData:
95 | assetBundleName:
96 | assetBundleVariant:
97 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # blesock-unity-plugin
2 | #### 【概要】
3 |
4 | BluetoothLEを使用してiOS/Android間でアドホック通信を行うためのUnityプラグインです。
5 |
6 | #### 【特徴】
7 |
8 | スマートフォンに搭載されているBluetoothLEを使用して通信を行うので、
9 | WiFiやインターネットが利用できない環境でもアドホック通信を行うことができます。
10 |
11 | 通信やプレイヤーの管理等はプラグイン側で行われるため、本当に簡単なコードを書くだけで使用できます。
12 | シンプルなC#クラスとして実装されており、プラットフォームの差異を気にする必要はありません。
13 |
14 | #### 【動作環境】
15 |
16 | | 開発および動作環境 | バージョン | 補足 |
17 | | ----------------------------------------- | -------------- | ------------------------------------------------------------ |
18 | | Unity | 2018.2 以降 | Javaソースコードを.jar化すれば以前のバージョンでも動作します |
19 | | .NET Framework | 3.5 および 4.X | どちらでも動作します |
20 | | iOS | 9 以降 | |
21 | | Android | 5 以降 | |
22 | | Windows | 10 以降 | Unityエディタ上のみ |
23 | | MacOS | - | 未対応 |
24 |
25 | #### 【注意事項】
26 |
27 | ##### iOSビルド
28 |
29 | Bluetoothを使用するため、PlayerSettings内のLocationUsageDescriptionの設定が必須です。
30 |
31 | またinfo.plistおよびXCodeプロジェクトの設定が必要ですが、デフォルトでは
32 | Assets/Plugins/Editor/BleSockXcodePostProcessBuild.cs により自動設定されますので
33 | 必要に応じ編集してください。
34 |
35 | ##### Androidビルド
36 |
37 | ランタイムで必要な権限の設定などは
38 | Assets/Plugins/Android/AndroidManifest.xml 内に記述されていますので、必要に応じ編集してください。
39 |
40 | なおAndroid 6以降では別途、位置情報の取得権限が必要です。
41 | これはデフォルトではUnityにより自動で要求されるため、明示的に無効化しない限りは対応する必要はありません。
42 |
43 | Android環境においては同一端末上で、同時に複数のホスト(ペリフェラル)を起動した場合の動作は保証されません。
44 | (ペリフェラルを起動する際に古いペリフェラルのサービスも更新されてしまい、通信が途絶してしまうため)
45 |
46 | ##### Windows版Unityエディタ
47 |
48 | Unityエディタの動作環境がWindows10でかつBluetoothアダプタが使用可能な場合
49 | エディタ上でも通信テストが行えます。
50 |
51 | その際Unityプロジェクトの.NET Frameworkバージョンを4.Xに変更する必要があります。
52 |
53 | 安定性の問題により、現状ホスト(ペリフェラル)には対応していません。
54 | またゲスト(セントラル)でもスキャン時にデバイス名を取得できないため、代わりにIDが取得されます。
55 |
56 | ##### 通信量の制約
57 |
58 | BluetoothLEはそもそもの帯域が狭いため(理論上は~1Mbpsだけど実測はもっと下)
59 | 大きなメッセージや大量のメッセージを一度に送受信することはできません。
60 |
61 | コンパクトで最低限のメッセージ通信で完結するようにアプリケーションを設計する必要があります。
62 |
63 | #### 【お願い】
64 |
65 | 現状Android端末での動作検証が十分ではありません。
66 |
67 | 動作条件を満たしていたとしても、すべての機種でプラグインが動作するわけではなく
68 | 古い端末ではホスト(ペリフェラル)に対応していない場合があったり、
69 | どうしても接続や通信が不安定となる端末があります。
70 |
71 | 動作確認ができた、もしくは動作しなかった端末をレポートいただけますと助かります。
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/GraphicsSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!30 &1
4 | GraphicsSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 12
7 | m_Deferred:
8 | m_Mode: 1
9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
10 | m_DeferredReflections:
11 | m_Mode: 1
12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
13 | m_ScreenSpaceShadows:
14 | m_Mode: 1
15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
16 | m_LegacyDeferred:
17 | m_Mode: 1
18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
19 | m_DepthNormals:
20 | m_Mode: 1
21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
22 | m_MotionVectors:
23 | m_Mode: 1
24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
25 | m_LightHalo:
26 | m_Mode: 1
27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
28 | m_LensFlare:
29 | m_Mode: 1
30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
31 | m_AlwaysIncludedShaders:
32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
38 | - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
39 | - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
40 | - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
41 | m_PreloadedShaders: []
42 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
43 | type: 0}
44 | m_CustomRenderPipeline: {fileID: 0}
45 | m_TransparencySortMode: 0
46 | m_TransparencySortAxis: {x: 0, y: 0, z: 1}
47 | m_DefaultRenderingPath: 1
48 | m_DefaultMobileRenderingPath: 1
49 | m_TierSettings: []
50 | m_LightmapStripping: 0
51 | m_FogStripping: 0
52 | m_InstancingStripping: 0
53 | m_LightmapKeepPlain: 1
54 | m_LightmapKeepDirCombined: 1
55 | m_LightmapKeepDynamicPlain: 1
56 | m_LightmapKeepDynamicDirCombined: 1
57 | m_LightmapKeepShadowMask: 1
58 | m_LightmapKeepSubtractive: 1
59 | m_FogKeepLinear: 1
60 | m_FogKeepExp: 1
61 | m_FogKeepExp2: 1
62 | m_AlbedoSwatchInfos: []
63 | m_LightsUseLinearIntensity: 0
64 | m_LightsUseColorTemperature: 0
65 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/iOS/CentralImpl.mm.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2d00966c81476468081123dc43f948b4
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | '': Any
13 | second:
14 | enabled: 0
15 | settings:
16 | Exclude Android: 1
17 | Exclude Editor: 1
18 | Exclude Linux: 1
19 | Exclude Linux64: 1
20 | Exclude LinuxUniversal: 1
21 | Exclude OSXUniversal: 1
22 | Exclude Win: 1
23 | Exclude Win64: 1
24 | Exclude WindowsStoreApps: 1
25 | Exclude iOS: 0
26 | - first:
27 | Android: Android
28 | second:
29 | enabled: 0
30 | settings:
31 | CPU: ARMv7
32 | - first:
33 | Any:
34 | second:
35 | enabled: 0
36 | settings: {}
37 | - first:
38 | Editor: Editor
39 | second:
40 | enabled: 0
41 | settings:
42 | CPU: AnyCPU
43 | DefaultValueInitialized: true
44 | OS: AnyOS
45 | - first:
46 | Facebook: Win
47 | second:
48 | enabled: 0
49 | settings:
50 | CPU: AnyCPU
51 | - first:
52 | Facebook: Win64
53 | second:
54 | enabled: 0
55 | settings:
56 | CPU: AnyCPU
57 | - first:
58 | Standalone: Linux
59 | second:
60 | enabled: 0
61 | settings:
62 | CPU: x86
63 | - first:
64 | Standalone: Linux64
65 | second:
66 | enabled: 0
67 | settings:
68 | CPU: x86_64
69 | - first:
70 | Standalone: OSXUniversal
71 | second:
72 | enabled: 0
73 | settings:
74 | CPU: AnyCPU
75 | - first:
76 | Standalone: Win
77 | second:
78 | enabled: 0
79 | settings:
80 | CPU: AnyCPU
81 | - first:
82 | Standalone: Win64
83 | second:
84 | enabled: 0
85 | settings:
86 | CPU: AnyCPU
87 | - first:
88 | Windows Store Apps: WindowsStoreApps
89 | second:
90 | enabled: 0
91 | settings:
92 | CPU: AnyCPU
93 | DontProcess: false
94 | PlaceholderPath:
95 | SDK: AnySDK
96 | ScriptingBackend: AnyScriptingBackend
97 | - first:
98 | iPhone: iOS
99 | second:
100 | enabled: 1
101 | settings:
102 | AddToEmbeddedBinaries: false
103 | CompileFlags:
104 | FrameworkDependencies: CoreBluetooth;
105 | userData:
106 | assetBundleName:
107 | assetBundleVariant:
108 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/iOS/PeripheralImpl.mm.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5e8739bd16ca34d84aa160f72d565621
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | '': Any
13 | second:
14 | enabled: 0
15 | settings:
16 | Exclude Android: 1
17 | Exclude Editor: 1
18 | Exclude Linux: 1
19 | Exclude Linux64: 1
20 | Exclude LinuxUniversal: 1
21 | Exclude OSXUniversal: 1
22 | Exclude Win: 1
23 | Exclude Win64: 1
24 | Exclude WindowsStoreApps: 1
25 | Exclude iOS: 0
26 | - first:
27 | Android: Android
28 | second:
29 | enabled: 0
30 | settings:
31 | CPU: ARMv7
32 | - first:
33 | Any:
34 | second:
35 | enabled: 0
36 | settings: {}
37 | - first:
38 | Editor: Editor
39 | second:
40 | enabled: 0
41 | settings:
42 | CPU: AnyCPU
43 | DefaultValueInitialized: true
44 | OS: AnyOS
45 | - first:
46 | Facebook: Win
47 | second:
48 | enabled: 0
49 | settings:
50 | CPU: AnyCPU
51 | - first:
52 | Facebook: Win64
53 | second:
54 | enabled: 0
55 | settings:
56 | CPU: AnyCPU
57 | - first:
58 | Standalone: Linux
59 | second:
60 | enabled: 0
61 | settings:
62 | CPU: x86
63 | - first:
64 | Standalone: Linux64
65 | second:
66 | enabled: 0
67 | settings:
68 | CPU: x86_64
69 | - first:
70 | Standalone: OSXUniversal
71 | second:
72 | enabled: 0
73 | settings:
74 | CPU: AnyCPU
75 | - first:
76 | Standalone: Win
77 | second:
78 | enabled: 0
79 | settings:
80 | CPU: AnyCPU
81 | - first:
82 | Standalone: Win64
83 | second:
84 | enabled: 0
85 | settings:
86 | CPU: AnyCPU
87 | - first:
88 | Windows Store Apps: WindowsStoreApps
89 | second:
90 | enabled: 0
91 | settings:
92 | CPU: AnyCPU
93 | DontProcess: false
94 | PlaceholderPath:
95 | SDK: AnySDK
96 | ScriptingBackend: AnyScriptingBackend
97 | - first:
98 | iPhone: iOS
99 | second:
100 | enabled: 1
101 | settings:
102 | AddToEmbeddedBinaries: false
103 | CompileFlags:
104 | FrameworkDependencies: CoreBluetooth;
105 | userData:
106 | assetBundleName:
107 | assetBundleVariant:
108 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/iOS/PeripheralImpl.swift.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: edabbddcbcc7745ef9efb5d9c2242446
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | '': Any
13 | second:
14 | enabled: 0
15 | settings:
16 | Exclude Android: 1
17 | Exclude Editor: 1
18 | Exclude Linux: 1
19 | Exclude Linux64: 1
20 | Exclude LinuxUniversal: 1
21 | Exclude OSXUniversal: 1
22 | Exclude Win: 1
23 | Exclude Win64: 1
24 | Exclude WindowsStoreApps: 1
25 | Exclude iOS: 0
26 | - first:
27 | Android: Android
28 | second:
29 | enabled: 0
30 | settings:
31 | CPU: ARMv7
32 | - first:
33 | Any:
34 | second:
35 | enabled: 0
36 | settings: {}
37 | - first:
38 | Editor: Editor
39 | second:
40 | enabled: 0
41 | settings:
42 | CPU: AnyCPU
43 | DefaultValueInitialized: true
44 | OS: AnyOS
45 | - first:
46 | Facebook: Win
47 | second:
48 | enabled: 0
49 | settings:
50 | CPU: AnyCPU
51 | - first:
52 | Facebook: Win64
53 | second:
54 | enabled: 0
55 | settings:
56 | CPU: AnyCPU
57 | - first:
58 | Standalone: Linux
59 | second:
60 | enabled: 0
61 | settings:
62 | CPU: x86
63 | - first:
64 | Standalone: Linux64
65 | second:
66 | enabled: 0
67 | settings:
68 | CPU: x86_64
69 | - first:
70 | Standalone: OSXUniversal
71 | second:
72 | enabled: 0
73 | settings:
74 | CPU: AnyCPU
75 | - first:
76 | Standalone: Win
77 | second:
78 | enabled: 0
79 | settings:
80 | CPU: AnyCPU
81 | - first:
82 | Standalone: Win64
83 | second:
84 | enabled: 0
85 | settings:
86 | CPU: AnyCPU
87 | - first:
88 | Windows Store Apps: WindowsStoreApps
89 | second:
90 | enabled: 0
91 | settings:
92 | CPU: AnyCPU
93 | DontProcess: false
94 | PlaceholderPath:
95 | SDK: AnySDK
96 | ScriptingBackend: AnyScriptingBackend
97 | - first:
98 | iPhone: iOS
99 | second:
100 | enabled: 1
101 | settings:
102 | AddToEmbeddedBinaries: false
103 | CompileFlags:
104 | FrameworkDependencies: CoreBluetooth;
105 | userData:
106 | assetBundleName:
107 | assetBundleVariant:
108 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/Windows/WinBleHandler.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6fccc48cdfa216741aa7ef5b364c41d1
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | isPreloaded: 0
9 | isOverridable: 0
10 | platformData:
11 | - first:
12 | '': Any
13 | second:
14 | enabled: 0
15 | settings:
16 | Exclude Android: 1
17 | Exclude Editor: 0
18 | Exclude Linux: 1
19 | Exclude Linux64: 1
20 | Exclude LinuxUniversal: 1
21 | Exclude OSXUniversal: 1
22 | Exclude Win: 1
23 | Exclude Win64: 1
24 | Exclude WindowsStoreApps: 1
25 | Exclude iOS: 1
26 | - first:
27 | Android: Android
28 | second:
29 | enabled: 0
30 | settings:
31 | CPU: ARMv7
32 | - first:
33 | Any:
34 | second:
35 | enabled: 0
36 | settings: {}
37 | - first:
38 | Editor: Editor
39 | second:
40 | enabled: 1
41 | settings:
42 | CPU: AnyCPU
43 | DefaultValueInitialized: true
44 | OS: AnyOS
45 | - first:
46 | Facebook: Win
47 | second:
48 | enabled: 0
49 | settings:
50 | CPU: AnyCPU
51 | - first:
52 | Facebook: Win64
53 | second:
54 | enabled: 0
55 | settings:
56 | CPU: AnyCPU
57 | - first:
58 | Standalone: Linux
59 | second:
60 | enabled: 0
61 | settings:
62 | CPU: x86
63 | - first:
64 | Standalone: Linux64
65 | second:
66 | enabled: 0
67 | settings:
68 | CPU: x86_64
69 | - first:
70 | Standalone: LinuxUniversal
71 | second:
72 | enabled: 0
73 | settings:
74 | CPU: None
75 | - first:
76 | Standalone: OSXUniversal
77 | second:
78 | enabled: 0
79 | settings:
80 | CPU: AnyCPU
81 | - first:
82 | Standalone: Win
83 | second:
84 | enabled: 0
85 | settings:
86 | CPU: AnyCPU
87 | - first:
88 | Standalone: Win64
89 | second:
90 | enabled: 0
91 | settings:
92 | CPU: AnyCPU
93 | - first:
94 | Windows Store Apps: WindowsStoreApps
95 | second:
96 | enabled: 0
97 | settings:
98 | CPU: AnyCPU
99 | DontProcess: false
100 | PlaceholderPath:
101 | SDK: AnySDK
102 | ScriptingBackend: AnyScriptingBackend
103 | - first:
104 | iPhone: iOS
105 | second:
106 | enabled: 0
107 | settings:
108 | AddToEmbeddedBinaries: false
109 | CompileFlags:
110 | FrameworkDependencies:
111 | userData:
112 | assetBundleName:
113 | assetBundleVariant:
114 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/Utils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 |
6 | using Windows.Foundation;
7 | using Windows.Storage.Streams;
8 |
9 | namespace BleSock.Windows
10 | {
11 | internal static class Utils
12 | {
13 | public static Task AsTask(this IAsyncOperation operation, CancellationToken cancellationToken)
14 | {
15 | if (cancellationToken.IsCancellationRequested)
16 | {
17 | throw new OperationCanceledException();
18 | }
19 |
20 | cancellationToken.Register(info =>
21 | {
22 | ((IAsyncInfo)info).Cancel();
23 | }, operation);
24 |
25 | return operation.AsTask();
26 | }
27 |
28 | public static Task AsTask(this IAsyncOperation operation)
29 | {
30 | var result = new TaskCompletionSource();
31 |
32 | operation.Completed += (asyncInfo, asyncStatus) =>
33 | {
34 | switch (asyncStatus)
35 | {
36 | case AsyncStatus.Completed:
37 | result.SetResult(operation.GetResults());
38 | break;
39 |
40 | case AsyncStatus.Canceled:
41 | result.SetCanceled();
42 | break;
43 |
44 | case AsyncStatus.Error:
45 | result.SetException(operation.ErrorCode);
46 | break;
47 | }
48 | };
49 |
50 | return result.Task;
51 | }
52 |
53 | public static IBuffer AsBuffer(this byte[] bytes)
54 | {
55 | using (var writer = new DataWriter())
56 | {
57 | writer.WriteBytes(bytes);
58 | return writer.DetachBuffer();
59 | }
60 | }
61 |
62 | public static byte[] AsBytes(this IBuffer buffer)
63 | {
64 | var bytes = new byte[buffer.Length];
65 | using (var reader = DataReader.FromBuffer(buffer))
66 | {
67 | reader.ReadBytes(bytes);
68 | }
69 |
70 | return bytes;
71 | }
72 |
73 | public static void CompactStream(Stream stream)
74 | {
75 | var buff = new byte[stream.Length - stream.Position];
76 | stream.Read(buff, 0, buff.Length);
77 | stream.SetLength(0);
78 | stream.Write(buff, 0, buff.Length);
79 | }
80 |
81 | public static void Info(string format, params object[] args)
82 | {
83 | Console.WriteLine(format, args);
84 | }
85 |
86 | public static void Error(string format, params object[] args)
87 | {
88 | Console.ForegroundColor = ConsoleColor.Red;
89 | Console.WriteLine(format, args);
90 | Console.ResetColor();
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/WinBle/WinBleHandler/WinBleHandler.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {2076E521-5575-4860-9139-54A487D12ADE}
8 | Library
9 | Properties
10 | BleSock.Windows
11 | WinBleHandler
12 | v4.6.2
13 | 512
14 | true
15 |
16 |
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | false
27 |
28 |
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | false
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | ..\..\..\..\..\Program Files\Unity\Editor\Data\Managed\UnityEngine.dll
44 | False
45 |
46 |
47 |
48 |
49 | IWcfCentralCallback.cs
50 |
51 |
52 | IWcfCentralHost.cs
53 |
54 |
55 | IWcfPeripheralCallback.cs
56 |
57 |
58 | IWcfPeripheralHost.cs
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/GameTest/PlayerCharacter.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.UI;
3 |
4 | public class PlayerCharacter : MonoBehaviour
5 | {
6 | public const float RADIUS = 40;
7 | public const float VELOCITY_MAX = 300;
8 | public const float ACCELERATION = 600;
9 | public const float DEACCELERATION = 300;
10 | public const float DEAD_ALPHA = .2f;
11 | public const int KILL_SCORE = 100;
12 |
13 |
14 | public Image baseImage;
15 | public Text nameText;
16 | public Text scoreText;
17 |
18 | public int playerId;
19 |
20 | public Vector2 velocity;
21 | public float rotation;
22 | public bool accelerating;
23 |
24 | public bool alive;
25 | public int score;
26 |
27 |
28 | public RectTransform rectTransform
29 | {
30 | get
31 | {
32 | return (RectTransform)transform;
33 | }
34 | }
35 |
36 | public Vector2 position
37 | {
38 | get
39 | {
40 | return rectTransform.anchoredPosition;
41 | }
42 |
43 | set
44 | {
45 | rectTransform.anchoredPosition = value;
46 | }
47 | }
48 |
49 | public Vector2 forward
50 | {
51 | get
52 | {
53 | return baseImage.rectTransform.up;
54 | }
55 | }
56 |
57 |
58 | private void Update()
59 | {
60 | scoreText.text = score.ToString("n0");
61 | baseImage.rectTransform.localRotation = Quaternion.Euler(0, 0, rotation);
62 |
63 | if (!alive)
64 | {
65 | return;
66 | }
67 |
68 | if (accelerating)
69 | {
70 | velocity += forward * (ACCELERATION * Time.deltaTime);
71 |
72 | float magnitude = velocity.magnitude;
73 | if (magnitude > VELOCITY_MAX)
74 | {
75 | velocity = velocity * (VELOCITY_MAX / magnitude);
76 | }
77 | }
78 | else
79 | {
80 | float magnitude = velocity.magnitude;
81 |
82 | if (magnitude > Mathf.Epsilon)
83 | {
84 | velocity = velocity * (Mathf.Max(magnitude - DEACCELERATION * Time.deltaTime, 0) / magnitude);
85 | }
86 | }
87 |
88 | position = position + velocity * Time.deltaTime;
89 | }
90 |
91 | public void Setup(int playerId, string name, Color color)
92 | {
93 | this.playerId = playerId;
94 | nameText.text = name;
95 |
96 | Color col = color;
97 | col.a = DEAD_ALPHA;
98 | baseImage.color = col;
99 |
100 | velocity = Vector2.zero;
101 | rotation = 0;
102 | accelerating = false;
103 | alive = false;
104 | score = 0;
105 |
106 | gameObject.SetActive(true);
107 | }
108 |
109 | public void Spawn(Vector2 position)
110 | {
111 | this.position = position;
112 |
113 | Color col = baseImage.color;
114 | col.a = 1;
115 | baseImage.color = col;
116 |
117 | alive = true;
118 | }
119 |
120 | public void Die()
121 | {
122 | Color col = baseImage.color;
123 | col.a = DEAD_ALPHA;
124 | baseImage.color = col;
125 |
126 | velocity = Vector2.zero;
127 | accelerating = false;
128 | alive = false;
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/WinBle/WinBle.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28010.2016
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinBleHandler", "WinBleHandler\WinBleHandler.csproj", "{2076E521-5575-4860-9139-54A487D12ADE}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinBleHost", "WinBleHost\WinBleHost.csproj", "{BA7A0382-C273-4F36-BF71-269668CB1757}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|ARM = Debug|ARM
14 | Debug|x64 = Debug|x64
15 | Debug|x86 = Debug|x86
16 | Release|Any CPU = Release|Any CPU
17 | Release|ARM = Release|ARM
18 | Release|x64 = Release|x64
19 | Release|x86 = Release|x86
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {2076E521-5575-4860-9139-54A487D12ADE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {2076E521-5575-4860-9139-54A487D12ADE}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {2076E521-5575-4860-9139-54A487D12ADE}.Debug|ARM.ActiveCfg = Debug|Any CPU
25 | {2076E521-5575-4860-9139-54A487D12ADE}.Debug|ARM.Build.0 = Debug|Any CPU
26 | {2076E521-5575-4860-9139-54A487D12ADE}.Debug|x64.ActiveCfg = Debug|Any CPU
27 | {2076E521-5575-4860-9139-54A487D12ADE}.Debug|x64.Build.0 = Debug|Any CPU
28 | {2076E521-5575-4860-9139-54A487D12ADE}.Debug|x86.ActiveCfg = Debug|Any CPU
29 | {2076E521-5575-4860-9139-54A487D12ADE}.Debug|x86.Build.0 = Debug|Any CPU
30 | {2076E521-5575-4860-9139-54A487D12ADE}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {2076E521-5575-4860-9139-54A487D12ADE}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {2076E521-5575-4860-9139-54A487D12ADE}.Release|ARM.ActiveCfg = Release|Any CPU
33 | {2076E521-5575-4860-9139-54A487D12ADE}.Release|ARM.Build.0 = Release|Any CPU
34 | {2076E521-5575-4860-9139-54A487D12ADE}.Release|x64.ActiveCfg = Release|Any CPU
35 | {2076E521-5575-4860-9139-54A487D12ADE}.Release|x64.Build.0 = Release|Any CPU
36 | {2076E521-5575-4860-9139-54A487D12ADE}.Release|x86.ActiveCfg = Release|Any CPU
37 | {2076E521-5575-4860-9139-54A487D12ADE}.Release|x86.Build.0 = Release|Any CPU
38 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Debug|ARM.ActiveCfg = Debug|Any CPU
41 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Debug|ARM.Build.0 = Debug|Any CPU
42 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Debug|x64.ActiveCfg = Debug|Any CPU
43 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Debug|x64.Build.0 = Debug|Any CPU
44 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Debug|x86.ActiveCfg = Debug|Any CPU
45 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Debug|x86.Build.0 = Debug|Any CPU
46 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Release|Any CPU.Build.0 = Release|Any CPU
48 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Release|ARM.ActiveCfg = Release|Any CPU
49 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Release|ARM.Build.0 = Release|Any CPU
50 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Release|x64.ActiveCfg = Release|Any CPU
51 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Release|x64.Build.0 = Release|Any CPU
52 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Release|x86.ActiveCfg = Release|Any CPU
53 | {BA7A0382-C273-4F36-BF71-269668CB1757}.Release|x86.Build.0 = Release|Any CPU
54 | EndGlobalSection
55 | GlobalSection(SolutionProperties) = preSolution
56 | HideSolutionNode = FALSE
57 | EndGlobalSection
58 | GlobalSection(ExtensibilityGlobals) = postSolution
59 | SolutionGuid = {9C997DF7-B259-4F79-8873-CD2071D3ECE5}
60 | EndGlobalSection
61 | EndGlobal
62 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/iOS/CentralImpl.mm:
--------------------------------------------------------------------------------
1 | #import
2 | #import "Unity-Swift.h"
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | typedef void (* _Nonnull CommonCallback)(void const * _Nonnull);
9 | typedef void (* _Nonnull DiscoverCallback)(void const * _Nonnull, int8_t const * _Nonnull, int32_t);
10 | typedef void (* _Nonnull ReceiveCallback)(void const * _Nonnull, int8_t const * _Nonnull, int32_t, int32_t);
11 |
12 | CentralImpl* _blesock_central_create() {
13 |
14 | CentralImpl* instance = [CentralImpl new];
15 | CFRetain((CFTypeRef)instance);
16 |
17 | return instance;
18 | }
19 |
20 | BOOL _blesock_central_is_bluetooth_enabled(CentralImpl* instance) {
21 |
22 | return [instance isBluetoothEnabled];
23 | }
24 |
25 | BOOL _blesock_central_initialize(CentralImpl* instance,
26 | void* owner,
27 | const char* serviceUUID,
28 | const char* uploadUUID,
29 | const char* downloadUUID,
30 | CommonCallback onBluetoothRequire,
31 | CommonCallback onReady,
32 | CommonCallback onFail,
33 | DiscoverCallback onDiscover,
34 | CommonCallback onConnect,
35 | CommonCallback onDisconnect,
36 | ReceiveCallback onReceive) {
37 |
38 | NSString* serviceUUIDStr = [NSString stringWithUTF8String: serviceUUID];
39 | NSString* uploadUUIDStr = [NSString stringWithUTF8String: uploadUUID];
40 | NSString* downloadUUIDStr = [NSString stringWithUTF8String: downloadUUID];
41 |
42 | return [instance initialize: owner
43 | serviceUUID: serviceUUIDStr
44 | uploadUUID: uploadUUIDStr
45 | downloadUUID: downloadUUIDStr
46 | onBluetoothRequire: onBluetoothRequire
47 | onReady: onReady
48 | onFail: onFail
49 | onDiscover: onDiscover
50 | onConnect: onConnect
51 | onDisconnect: onDisconnect
52 | onReceive: onReceive];
53 | }
54 |
55 | BOOL _blesock_central_start_scan(CentralImpl* instance) {
56 |
57 | return [instance startScan];
58 | }
59 |
60 | void _blesock_central_stop_scan(CentralImpl* instance) {
61 |
62 | [instance stopScan];
63 | }
64 |
65 | BOOL _blesock_central_connect(CentralImpl* instance, int32_t deviceId) {
66 |
67 | return [instance connect: deviceId];
68 | }
69 |
70 | void _blesock_central_accept(CentralImpl* instance) {
71 |
72 | [instance accept];
73 | }
74 |
75 | void _blesock_central_disconnect(CentralImpl* instance) {
76 |
77 | [instance disconnect];
78 | }
79 |
80 | BOOL _blesock_central_send(CentralImpl* instance,
81 | Byte* message,
82 | int32_t messageSize,
83 | int32_t receiver) {
84 |
85 | NSData *buffer = [NSData dataWithBytesNoCopy: message
86 | length: messageSize
87 | freeWhenDone: NO];
88 |
89 | return [instance send: buffer receiver: receiver];
90 | }
91 |
92 | void _blesock_central_cleanup(CentralImpl* instance) {
93 |
94 | [instance cleanup];
95 | }
96 |
97 | void _blesock_central_release(CentralImpl* instance) {
98 |
99 | CFRelease((CFTypeRef)instance);
100 | }
101 |
102 | #ifdef __cplusplus
103 | }
104 | #endif
105 |
--------------------------------------------------------------------------------
/WinBle/WinBleHost/WinBleHost.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BA7A0382-C273-4F36-BF71-269668CB1757}
8 | Exe
9 | BleSock.Windows
10 | WinBleHost
11 | v4.6.2
12 | 512
13 | true
14 | true
15 | publish\
16 | true
17 | Disk
18 | false
19 | Foreground
20 | 7
21 | Days
22 | false
23 | false
24 | true
25 | 0
26 | 1.0.0.%2a
27 | false
28 | false
29 | true
30 |
31 |
32 | AnyCPU
33 | true
34 | full
35 | false
36 | bin\Debug\
37 | DEBUG;TRACE
38 | prompt
39 | 4
40 |
41 |
42 | AnyCPU
43 | pdbonly
44 | true
45 | bin\Release\
46 | TRACE
47 | prompt
48 | 4
49 |
50 |
51 | 10.0
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | False
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | False
86 | Microsoft .NET Framework 4.6.2 %28x86 および x64%29
87 | true
88 |
89 |
90 | False
91 | .NET Framework 3.5 SP1
92 | false
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/iOS/PeripheralImpl.mm:
--------------------------------------------------------------------------------
1 | #import
2 | #import "Unity-Swift.h"
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | typedef void (* _Nonnull CommonCallback)(void const * _Nonnull);
9 | typedef void (* _Nonnull ConnectionCallback)(void const * _Nonnull, int32_t);
10 | typedef void (* _Nonnull ReceiveCallback)(void const * _Nonnull, int8_t const * _Nonnull, int32_t, int32_t);
11 |
12 | PeripheralImpl* _blesock_peripheral_create() {
13 |
14 | PeripheralImpl* instance = [PeripheralImpl new];
15 | CFRetain((CFTypeRef)instance);
16 |
17 | return instance;
18 | }
19 |
20 | BOOL _blesock_peripheral_is_bluetooth_enabled(PeripheralImpl* instance) {
21 |
22 | return [instance isBluetoothEnabled];
23 | }
24 |
25 | BOOL _blesock_peripheral_initialize(PeripheralImpl* instance,
26 | void* owner,
27 | const char* serviceUUID,
28 | const char* uploadUUID,
29 | const char* downloadUUID,
30 | CommonCallback onBluetoothRequire,
31 | CommonCallback onReady,
32 | CommonCallback onFail,
33 | ConnectionCallback onConnect,
34 | ConnectionCallback onDisconnect,
35 | ReceiveCallback onReceiveDirect,
36 | ReceiveCallback onReceive) {
37 |
38 | NSString* serviceUUIDStr = [NSString stringWithUTF8String: serviceUUID];
39 | NSString* uploadUUIDStr = [NSString stringWithUTF8String: uploadUUID];
40 | NSString* downloadUUIDStr = [NSString stringWithUTF8String: downloadUUID];
41 |
42 | return [instance initialize: owner
43 | serviceUUID: serviceUUIDStr
44 | uploadUUID: uploadUUIDStr
45 | downloadUUID: downloadUUIDStr
46 | onBluetoothRequire: onBluetoothRequire
47 | onReady: onReady
48 | onFail: onFail
49 | onConnect: onConnect
50 | onDisconnect: onDisconnect
51 | onReceiveDirect: onReceiveDirect
52 | onReceive: onReceive];
53 | }
54 |
55 | BOOL _blesock_peripheral_start_advertising(PeripheralImpl* instance, const char* deviceName) {
56 |
57 | NSString* deviceNameStr = [NSString stringWithUTF8String: deviceName];
58 |
59 | return [instance startAdvertising: deviceNameStr];
60 | }
61 |
62 | void _blesock_peripheral_stop_advertising(PeripheralImpl* instance) {
63 |
64 | [instance stopAdvertising];
65 | }
66 |
67 | BOOL _blesock_peripheral_accept(PeripheralImpl* instance, int32_t connectionId, int32_t playerId) {
68 |
69 | return [instance accept: connectionId playerId: playerId];
70 | }
71 |
72 | void _blesock_peripheral_invalidate(PeripheralImpl* instance, int32_t connectionId) {
73 |
74 | [instance invalidate: connectionId];
75 | }
76 |
77 | BOOL _blesock_peripheral_send_direct(PeripheralImpl* instance,
78 | Byte* message,
79 | int32_t messageSize,
80 | int32_t connectionId) {
81 |
82 | NSData *buffer = [NSData dataWithBytesNoCopy: message
83 | length: messageSize
84 | freeWhenDone: NO];
85 |
86 | return [instance sendDirect: buffer connectionId: connectionId];
87 | }
88 |
89 | BOOL _blesock_peripheral_send(PeripheralImpl* instance,
90 | Byte* message,
91 | int32_t messageSize,
92 | int32_t receiver) {
93 |
94 | NSData *buffer = [NSData dataWithBytesNoCopy: message
95 | length: messageSize
96 | freeWhenDone: NO];
97 |
98 | return [instance send: buffer receiver: receiver];
99 | }
100 |
101 | void _blesock_peripheral_cleanup(PeripheralImpl* instance) {
102 |
103 | [instance cleanup];
104 | }
105 |
106 | void _blesock_peripheral_release(PeripheralImpl* instance) {
107 |
108 | CFRelease((CFTypeRef)instance);
109 | }
110 |
111 | #ifdef __cplusplus
112 | }
113 | #endif
114 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/InputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!13 &1
4 | InputManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Axes:
8 | - serializedVersion: 3
9 | m_Name: Horizontal
10 | descriptiveName:
11 | descriptiveNegativeName:
12 | negativeButton: left
13 | positiveButton: right
14 | altNegativeButton: a
15 | altPositiveButton: d
16 | gravity: 3
17 | dead: 0.001
18 | sensitivity: 3
19 | snap: 1
20 | invert: 0
21 | type: 0
22 | axis: 0
23 | joyNum: 0
24 | - serializedVersion: 3
25 | m_Name: Vertical
26 | descriptiveName:
27 | descriptiveNegativeName:
28 | negativeButton: down
29 | positiveButton: up
30 | altNegativeButton: s
31 | altPositiveButton: w
32 | gravity: 3
33 | dead: 0.001
34 | sensitivity: 3
35 | snap: 1
36 | invert: 0
37 | type: 0
38 | axis: 0
39 | joyNum: 0
40 | - serializedVersion: 3
41 | m_Name: Fire1
42 | descriptiveName:
43 | descriptiveNegativeName:
44 | negativeButton:
45 | positiveButton: left ctrl
46 | altNegativeButton:
47 | altPositiveButton: mouse 0
48 | gravity: 1000
49 | dead: 0.001
50 | sensitivity: 1000
51 | snap: 0
52 | invert: 0
53 | type: 0
54 | axis: 0
55 | joyNum: 0
56 | - serializedVersion: 3
57 | m_Name: Fire2
58 | descriptiveName:
59 | descriptiveNegativeName:
60 | negativeButton:
61 | positiveButton: left alt
62 | altNegativeButton:
63 | altPositiveButton: mouse 1
64 | gravity: 1000
65 | dead: 0.001
66 | sensitivity: 1000
67 | snap: 0
68 | invert: 0
69 | type: 0
70 | axis: 0
71 | joyNum: 0
72 | - serializedVersion: 3
73 | m_Name: Fire3
74 | descriptiveName:
75 | descriptiveNegativeName:
76 | negativeButton:
77 | positiveButton: left shift
78 | altNegativeButton:
79 | altPositiveButton: mouse 2
80 | gravity: 1000
81 | dead: 0.001
82 | sensitivity: 1000
83 | snap: 0
84 | invert: 0
85 | type: 0
86 | axis: 0
87 | joyNum: 0
88 | - serializedVersion: 3
89 | m_Name: Jump
90 | descriptiveName:
91 | descriptiveNegativeName:
92 | negativeButton:
93 | positiveButton: space
94 | altNegativeButton:
95 | altPositiveButton:
96 | gravity: 1000
97 | dead: 0.001
98 | sensitivity: 1000
99 | snap: 0
100 | invert: 0
101 | type: 0
102 | axis: 0
103 | joyNum: 0
104 | - serializedVersion: 3
105 | m_Name: Mouse X
106 | descriptiveName:
107 | descriptiveNegativeName:
108 | negativeButton:
109 | positiveButton:
110 | altNegativeButton:
111 | altPositiveButton:
112 | gravity: 0
113 | dead: 0
114 | sensitivity: 0.1
115 | snap: 0
116 | invert: 0
117 | type: 1
118 | axis: 0
119 | joyNum: 0
120 | - serializedVersion: 3
121 | m_Name: Mouse Y
122 | descriptiveName:
123 | descriptiveNegativeName:
124 | negativeButton:
125 | positiveButton:
126 | altNegativeButton:
127 | altPositiveButton:
128 | gravity: 0
129 | dead: 0
130 | sensitivity: 0.1
131 | snap: 0
132 | invert: 0
133 | type: 1
134 | axis: 1
135 | joyNum: 0
136 | - serializedVersion: 3
137 | m_Name: Mouse ScrollWheel
138 | descriptiveName:
139 | descriptiveNegativeName:
140 | negativeButton:
141 | positiveButton:
142 | altNegativeButton:
143 | altPositiveButton:
144 | gravity: 0
145 | dead: 0
146 | sensitivity: 0.1
147 | snap: 0
148 | invert: 0
149 | type: 1
150 | axis: 2
151 | joyNum: 0
152 | - serializedVersion: 3
153 | m_Name: Horizontal
154 | descriptiveName:
155 | descriptiveNegativeName:
156 | negativeButton:
157 | positiveButton:
158 | altNegativeButton:
159 | altPositiveButton:
160 | gravity: 0
161 | dead: 0.19
162 | sensitivity: 1
163 | snap: 0
164 | invert: 0
165 | type: 2
166 | axis: 0
167 | joyNum: 0
168 | - serializedVersion: 3
169 | m_Name: Vertical
170 | descriptiveName:
171 | descriptiveNegativeName:
172 | negativeButton:
173 | positiveButton:
174 | altNegativeButton:
175 | altPositiveButton:
176 | gravity: 0
177 | dead: 0.19
178 | sensitivity: 1
179 | snap: 0
180 | invert: 1
181 | type: 2
182 | axis: 1
183 | joyNum: 0
184 | - serializedVersion: 3
185 | m_Name: Fire1
186 | descriptiveName:
187 | descriptiveNegativeName:
188 | negativeButton:
189 | positiveButton: joystick button 0
190 | altNegativeButton:
191 | altPositiveButton:
192 | gravity: 1000
193 | dead: 0.001
194 | sensitivity: 1000
195 | snap: 0
196 | invert: 0
197 | type: 0
198 | axis: 0
199 | joyNum: 0
200 | - serializedVersion: 3
201 | m_Name: Fire2
202 | descriptiveName:
203 | descriptiveNegativeName:
204 | negativeButton:
205 | positiveButton: joystick button 1
206 | altNegativeButton:
207 | altPositiveButton:
208 | gravity: 1000
209 | dead: 0.001
210 | sensitivity: 1000
211 | snap: 0
212 | invert: 0
213 | type: 0
214 | axis: 0
215 | joyNum: 0
216 | - serializedVersion: 3
217 | m_Name: Fire3
218 | descriptiveName:
219 | descriptiveNegativeName:
220 | negativeButton:
221 | positiveButton: joystick button 2
222 | altNegativeButton:
223 | altPositiveButton:
224 | gravity: 1000
225 | dead: 0.001
226 | sensitivity: 1000
227 | snap: 0
228 | invert: 0
229 | type: 0
230 | axis: 0
231 | joyNum: 0
232 | - serializedVersion: 3
233 | m_Name: Jump
234 | descriptiveName:
235 | descriptiveNegativeName:
236 | negativeButton:
237 | positiveButton: joystick button 3
238 | altNegativeButton:
239 | altPositiveButton:
240 | gravity: 1000
241 | dead: 0.001
242 | sensitivity: 1000
243 | snap: 0
244 | invert: 0
245 | type: 0
246 | axis: 0
247 | joyNum: 0
248 | - serializedVersion: 3
249 | m_Name: Submit
250 | descriptiveName:
251 | descriptiveNegativeName:
252 | negativeButton:
253 | positiveButton: return
254 | altNegativeButton:
255 | altPositiveButton: joystick button 0
256 | gravity: 1000
257 | dead: 0.001
258 | sensitivity: 1000
259 | snap: 0
260 | invert: 0
261 | type: 0
262 | axis: 0
263 | joyNum: 0
264 | - serializedVersion: 3
265 | m_Name: Submit
266 | descriptiveName:
267 | descriptiveNegativeName:
268 | negativeButton:
269 | positiveButton: enter
270 | altNegativeButton:
271 | altPositiveButton: space
272 | gravity: 1000
273 | dead: 0.001
274 | sensitivity: 1000
275 | snap: 0
276 | invert: 0
277 | type: 0
278 | axis: 0
279 | joyNum: 0
280 | - serializedVersion: 3
281 | m_Name: Cancel
282 | descriptiveName:
283 | descriptiveNegativeName:
284 | negativeButton:
285 | positiveButton: escape
286 | altNegativeButton:
287 | altPositiveButton: joystick button 1
288 | gravity: 1000
289 | dead: 0.001
290 | sensitivity: 1000
291 | snap: 0
292 | invert: 0
293 | type: 0
294 | axis: 0
295 | joyNum: 0
296 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/QualitySettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!47 &1
4 | QualitySettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 5
7 | m_CurrentQuality: 0
8 | m_QualitySettings:
9 | - serializedVersion: 2
10 | name: Very Low
11 | pixelLightCount: 0
12 | shadows: 0
13 | shadowResolution: 0
14 | shadowProjection: 1
15 | shadowCascades: 1
16 | shadowDistance: 15
17 | shadowNearPlaneOffset: 3
18 | shadowCascade2Split: 0.33333334
19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
20 | shadowmaskMode: 0
21 | blendWeights: 1
22 | textureQuality: 1
23 | anisotropicTextures: 0
24 | antiAliasing: 0
25 | softParticles: 0
26 | softVegetation: 0
27 | realtimeReflectionProbes: 0
28 | billboardsFaceCameraPosition: 0
29 | vSyncCount: 0
30 | lodBias: 0.3
31 | maximumLODLevel: 0
32 | streamingMipmapsActive: 0
33 | streamingMipmapsAddAllCameras: 1
34 | streamingMipmapsMemoryBudget: 512
35 | streamingMipmapsRenderersPerFrame: 512
36 | streamingMipmapsMaxLevelReduction: 2
37 | streamingMipmapsMaxFileIORequests: 1024
38 | particleRaycastBudget: 4
39 | asyncUploadTimeSlice: 2
40 | asyncUploadBufferSize: 4
41 | resolutionScalingFixedDPIFactor: 1
42 | excludedTargetPlatforms: []
43 | - serializedVersion: 2
44 | name: Low
45 | pixelLightCount: 0
46 | shadows: 0
47 | shadowResolution: 0
48 | shadowProjection: 1
49 | shadowCascades: 1
50 | shadowDistance: 20
51 | shadowNearPlaneOffset: 3
52 | shadowCascade2Split: 0.33333334
53 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
54 | shadowmaskMode: 0
55 | blendWeights: 2
56 | textureQuality: 0
57 | anisotropicTextures: 0
58 | antiAliasing: 0
59 | softParticles: 0
60 | softVegetation: 0
61 | realtimeReflectionProbes: 0
62 | billboardsFaceCameraPosition: 0
63 | vSyncCount: 0
64 | lodBias: 0.4
65 | maximumLODLevel: 0
66 | streamingMipmapsActive: 0
67 | streamingMipmapsAddAllCameras: 1
68 | streamingMipmapsMemoryBudget: 512
69 | streamingMipmapsRenderersPerFrame: 512
70 | streamingMipmapsMaxLevelReduction: 2
71 | streamingMipmapsMaxFileIORequests: 1024
72 | particleRaycastBudget: 16
73 | asyncUploadTimeSlice: 2
74 | asyncUploadBufferSize: 4
75 | resolutionScalingFixedDPIFactor: 1
76 | excludedTargetPlatforms: []
77 | - serializedVersion: 2
78 | name: Medium
79 | pixelLightCount: 1
80 | shadows: 1
81 | shadowResolution: 0
82 | shadowProjection: 1
83 | shadowCascades: 1
84 | shadowDistance: 20
85 | shadowNearPlaneOffset: 3
86 | shadowCascade2Split: 0.33333334
87 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
88 | shadowmaskMode: 0
89 | blendWeights: 2
90 | textureQuality: 0
91 | anisotropicTextures: 1
92 | antiAliasing: 0
93 | softParticles: 0
94 | softVegetation: 0
95 | realtimeReflectionProbes: 0
96 | billboardsFaceCameraPosition: 0
97 | vSyncCount: 1
98 | lodBias: 0.7
99 | maximumLODLevel: 0
100 | streamingMipmapsActive: 0
101 | streamingMipmapsAddAllCameras: 1
102 | streamingMipmapsMemoryBudget: 512
103 | streamingMipmapsRenderersPerFrame: 512
104 | streamingMipmapsMaxLevelReduction: 2
105 | streamingMipmapsMaxFileIORequests: 1024
106 | particleRaycastBudget: 64
107 | asyncUploadTimeSlice: 2
108 | asyncUploadBufferSize: 4
109 | resolutionScalingFixedDPIFactor: 1
110 | excludedTargetPlatforms: []
111 | - serializedVersion: 2
112 | name: High
113 | pixelLightCount: 2
114 | shadows: 2
115 | shadowResolution: 1
116 | shadowProjection: 1
117 | shadowCascades: 2
118 | shadowDistance: 40
119 | shadowNearPlaneOffset: 3
120 | shadowCascade2Split: 0.33333334
121 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
122 | shadowmaskMode: 1
123 | blendWeights: 2
124 | textureQuality: 0
125 | anisotropicTextures: 1
126 | antiAliasing: 2
127 | softParticles: 0
128 | softVegetation: 1
129 | realtimeReflectionProbes: 1
130 | billboardsFaceCameraPosition: 1
131 | vSyncCount: 1
132 | lodBias: 1
133 | maximumLODLevel: 0
134 | streamingMipmapsActive: 0
135 | streamingMipmapsAddAllCameras: 1
136 | streamingMipmapsMemoryBudget: 512
137 | streamingMipmapsRenderersPerFrame: 512
138 | streamingMipmapsMaxLevelReduction: 2
139 | streamingMipmapsMaxFileIORequests: 1024
140 | particleRaycastBudget: 256
141 | asyncUploadTimeSlice: 2
142 | asyncUploadBufferSize: 4
143 | resolutionScalingFixedDPIFactor: 1
144 | excludedTargetPlatforms: []
145 | - serializedVersion: 2
146 | name: Very High
147 | pixelLightCount: 3
148 | shadows: 2
149 | shadowResolution: 2
150 | shadowProjection: 1
151 | shadowCascades: 2
152 | shadowDistance: 40
153 | shadowNearPlaneOffset: 3
154 | shadowCascade2Split: 0.33333334
155 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
156 | shadowmaskMode: 1
157 | blendWeights: 4
158 | textureQuality: 0
159 | anisotropicTextures: 1
160 | antiAliasing: 4
161 | softParticles: 1
162 | softVegetation: 1
163 | realtimeReflectionProbes: 1
164 | billboardsFaceCameraPosition: 1
165 | vSyncCount: 1
166 | lodBias: 1.5
167 | maximumLODLevel: 0
168 | streamingMipmapsActive: 0
169 | streamingMipmapsAddAllCameras: 1
170 | streamingMipmapsMemoryBudget: 512
171 | streamingMipmapsRenderersPerFrame: 512
172 | streamingMipmapsMaxLevelReduction: 2
173 | streamingMipmapsMaxFileIORequests: 1024
174 | particleRaycastBudget: 1024
175 | asyncUploadTimeSlice: 2
176 | asyncUploadBufferSize: 4
177 | resolutionScalingFixedDPIFactor: 1
178 | excludedTargetPlatforms: []
179 | - serializedVersion: 2
180 | name: Ultra
181 | pixelLightCount: 4
182 | shadows: 2
183 | shadowResolution: 2
184 | shadowProjection: 1
185 | shadowCascades: 4
186 | shadowDistance: 150
187 | shadowNearPlaneOffset: 3
188 | shadowCascade2Split: 0.33333334
189 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
190 | shadowmaskMode: 1
191 | blendWeights: 4
192 | textureQuality: 0
193 | anisotropicTextures: 1
194 | antiAliasing: 4
195 | softParticles: 1
196 | softVegetation: 1
197 | realtimeReflectionProbes: 1
198 | billboardsFaceCameraPosition: 1
199 | vSyncCount: 1
200 | lodBias: 2
201 | maximumLODLevel: 0
202 | streamingMipmapsActive: 0
203 | streamingMipmapsAddAllCameras: 1
204 | streamingMipmapsMemoryBudget: 512
205 | streamingMipmapsRenderersPerFrame: 512
206 | streamingMipmapsMaxLevelReduction: 2
207 | streamingMipmapsMaxFileIORequests: 1024
208 | particleRaycastBudget: 4096
209 | asyncUploadTimeSlice: 2
210 | asyncUploadBufferSize: 4
211 | resolutionScalingFixedDPIFactor: 1
212 | excludedTargetPlatforms: []
213 | m_PerPlatformDefaultQuality:
214 | Android: 2
215 | Nintendo 3DS: 5
216 | Nintendo Switch: 5
217 | PS4: 5
218 | PSP2: 2
219 | Standalone: 5
220 | Tizen: 2
221 | WebGL: 3
222 | WiiU: 5
223 | Windows Store Apps: 5
224 | XboxOne: 5
225 | iPhone: 2
226 | tvOS: 2
227 |
--------------------------------------------------------------------------------
/WinBle/WinBleHandler/CentralHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.ServiceModel.Channels;
4 |
5 | using UnityEngine;
6 |
7 | namespace BleSock.Windows
8 | {
9 | public class CentralHandler : HandlerBase, IWcfCentralCallback
10 | {
11 | // Events
12 |
13 | public event Action onBluetoothRequire;
14 | public event Action onReady;
15 | public event Action onFail;
16 |
17 | public event Action onDiscover;
18 | public event Action onConnect;
19 | public event Action onDisconnect;
20 |
21 | public event Action onReceive;
22 |
23 | // Properties
24 |
25 | public bool IsBluetoothEnabled
26 | {
27 | get
28 | {
29 | return true; // TODO
30 | }
31 | }
32 |
33 | // Methods
34 |
35 | public bool Initialize(string executionFilepath, int portNumber, string serviceUUID, string uploadUUID, string downloadUUID)
36 | {
37 | if (mHost != null)
38 | {
39 | Debug.LogError("already called initialize");
40 | return false;
41 | }
42 |
43 | try
44 | {
45 | if (string.IsNullOrEmpty(executionFilepath))
46 | {
47 | Debug.Log("skip launching process");
48 | }
49 | else
50 | {
51 | string arguments = string.Format("Central {0}", portNumber);
52 | LaunchProcess(executionFilepath, arguments);
53 | }
54 |
55 | var bindingElements = new BindingElement[] // UnityEditorのmonoからはこの組み合わせでしかWCFを使用できない
56 | {
57 | new BinaryMessageEncodingBindingElement(),
58 | new TcpTransportBindingElement()
59 | };
60 | string address = string.Format("net.tcp://localhost:{0}/WcfCentralHost", portNumber);
61 |
62 | mHost = DuplexChannelFactory.CreateChannel(
63 | this,
64 | new CustomBinding(bindingElements),
65 | new EndpointAddress(address));
66 |
67 | Debug.LogFormat("Host: {0}", address);
68 |
69 | if (!mHost.Initialize(serviceUUID, uploadUUID, downloadUUID))
70 | {
71 | Debug.LogError("failed to Initialize");
72 | Cleanup();
73 | return false;
74 | }
75 | }
76 | catch (Exception e)
77 | {
78 | Debug.LogException(e);
79 | Cleanup();
80 | return false;
81 | }
82 |
83 | return true;
84 | }
85 |
86 | public bool StartScan()
87 | {
88 | if (mHost == null)
89 | {
90 | return false;
91 | }
92 |
93 | try
94 | {
95 | if (!mHost.StartScan())
96 | {
97 | Debug.LogError("failed to StartScan");
98 | return false;
99 | }
100 | }
101 | catch (Exception e)
102 | {
103 | Debug.LogException(e);
104 | mHost = null;
105 | return false;
106 | }
107 |
108 | return true;
109 | }
110 |
111 | public void StopScan()
112 | {
113 | if (mHost == null)
114 | {
115 | return;
116 | }
117 |
118 | try
119 | {
120 | mHost.StopScan();
121 | }
122 | catch (Exception e)
123 | {
124 | Debug.LogException(e);
125 | mHost = null;
126 | }
127 | }
128 |
129 |
130 | public bool Connect(int deviceId)
131 | {
132 | if (mHost == null)
133 | {
134 | return false;
135 | }
136 |
137 | try
138 | {
139 | if (!mHost.Connect(deviceId))
140 | {
141 | Debug.LogError("failed to Connect");
142 | return false;
143 | }
144 | }
145 | catch (Exception e)
146 | {
147 | Debug.LogException(e);
148 | mHost = null;
149 | return false;
150 | }
151 |
152 | return true;
153 | }
154 |
155 | public void Accept()
156 | {
157 | if (mHost == null)
158 | {
159 | return;
160 | }
161 |
162 | try
163 | {
164 | mHost.Accept();
165 | }
166 | catch (Exception e)
167 | {
168 | Debug.LogException(e);
169 | mHost = null;
170 | }
171 | }
172 |
173 | public void Disconnect()
174 | {
175 | if (mHost == null)
176 | {
177 | return;
178 | }
179 |
180 | try
181 | {
182 | mHost.Disconnect();
183 | }
184 | catch (Exception e)
185 | {
186 | Debug.LogException(e);
187 | mHost = null;
188 | }
189 | }
190 |
191 | public bool Send(byte[] message, int messageSize, int receiver)
192 | {
193 | if (mHost == null)
194 | {
195 | return false;
196 | }
197 |
198 | try
199 | {
200 | mHost.Send(message, messageSize, receiver);
201 | }
202 | catch (Exception e)
203 | {
204 | Debug.LogException(e);
205 | mHost = null;
206 | return false;
207 | }
208 |
209 | return true;
210 | }
211 |
212 | public override void Cleanup()
213 | {
214 | if (mHost != null)
215 | {
216 | try
217 | {
218 | mHost.Cleanup();
219 | }
220 | catch (Exception e)
221 | {
222 | Debug.LogException(e);
223 | }
224 |
225 | mHost = null;
226 | }
227 |
228 | base.Cleanup();
229 |
230 | onBluetoothRequire = null;
231 | onReady = null;
232 | onFail = null;
233 |
234 | onDiscover = null;
235 | onConnect = null;
236 | onDisconnect = null;
237 |
238 | onReceive = null;
239 | }
240 |
241 | // Internal
242 |
243 | private IWcfCentralHost mHost;
244 |
245 | protected override void OnProcessExited()
246 | {
247 | base.OnProcessExited();
248 |
249 | mHost = null;
250 | }
251 |
252 | // IWcfCentralCallback
253 |
254 | void IWcfCentralCallback.OnBluetoothRequire()
255 | {
256 | onBluetoothRequire?.Invoke();
257 | }
258 |
259 | void IWcfCentralCallback.OnReady()
260 | {
261 | onReady?.Invoke();
262 | }
263 |
264 | void IWcfCentralCallback.OnFail()
265 | {
266 | onFail?.Invoke();
267 | }
268 |
269 | void IWcfCentralCallback.OnDiscover(string deviceName, int deviceId)
270 | {
271 | onDiscover?.Invoke(deviceName, deviceId);
272 | }
273 |
274 | void IWcfCentralCallback.OnConnect()
275 | {
276 | onConnect?.Invoke();
277 | }
278 |
279 | void IWcfCentralCallback.OnDisconnect()
280 | {
281 | onDisconnect?.Invoke();
282 | }
283 |
284 | void IWcfCentralCallback.OnReceive(byte[] message, int sender)
285 | {
286 | onReceive?.Invoke(message, sender);
287 | }
288 | }
289 | }
290 |
--------------------------------------------------------------------------------
/WinBle/WinBleHandler/PeripheralHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceModel;
3 | using System.ServiceModel.Channels;
4 |
5 | using UnityEngine;
6 |
7 | namespace BleSock.Windows
8 | {
9 | public class PeripheralHandler : HandlerBase, IWcfPeripheralCallback
10 | {
11 | // Events
12 |
13 | public event Action onBluetoothRequire;
14 | public event Action onReady;
15 | public event Action onFail;
16 |
17 | public event Action onConnect;
18 | public event Action onDisconnect;
19 |
20 | public event Action onReceiveDirect;
21 | public event Action onReceive;
22 |
23 | // Properties
24 |
25 | public bool IsBluetoothEnabled
26 | {
27 | get
28 | {
29 | return true; // TODO
30 | }
31 | }
32 |
33 | // Methods
34 |
35 | public bool Initialize(string executionFilepath, int portNumber, string serviceUUID, string uploadUUID, string downloadUUID)
36 | {
37 | if (mHost != null)
38 | {
39 | Debug.LogError("already called initialize");
40 | return false;
41 | }
42 |
43 | try
44 | {
45 | if (string.IsNullOrEmpty(executionFilepath))
46 | {
47 | Debug.Log("skip launching process");
48 | }
49 | else
50 | {
51 | string arguments = string.Format("Peripheral {0}", portNumber);
52 | LaunchProcess(executionFilepath, arguments);
53 | }
54 |
55 | var bindingElements = new BindingElement[] // UnityEditorのmonoからはこの組み合わせでしかWCFを使用できない
56 | {
57 | new BinaryMessageEncodingBindingElement(),
58 | new TcpTransportBindingElement()
59 | };
60 | string address = string.Format("net.tcp://localhost:{0}/WcfPeripheralHost", portNumber);
61 |
62 | mHost = DuplexChannelFactory.CreateChannel(
63 | this,
64 | new CustomBinding(bindingElements),
65 | new EndpointAddress(address));
66 |
67 | Debug.LogFormat("Host: {0}", address);
68 |
69 | if (!mHost.Initialize(serviceUUID, uploadUUID, downloadUUID))
70 | {
71 | Debug.LogError("failed to Initialize");
72 | Cleanup();
73 | return false;
74 | }
75 | }
76 | catch (Exception e)
77 | {
78 | Debug.LogException(e);
79 | Cleanup();
80 | return false;
81 | }
82 |
83 | return true;
84 | }
85 |
86 | public bool StartAdvertising(string deviceName)
87 | {
88 | if (mHost == null)
89 | {
90 | return false;
91 | }
92 |
93 | try
94 | {
95 | if (!mHost.StartAdvertising(deviceName))
96 | {
97 | Debug.LogError("failed to StartAdvertising");
98 | return false;
99 | }
100 | }
101 | catch (Exception e)
102 | {
103 | Debug.LogException(e);
104 | mHost = null;
105 | return false;
106 | }
107 |
108 | return true;
109 | }
110 |
111 | public void StopAdvertising()
112 | {
113 | if (mHost == null)
114 | {
115 | return;
116 | }
117 |
118 | try
119 | {
120 | mHost.StopAdvertising();
121 | }
122 | catch (Exception e)
123 | {
124 | Debug.LogException(e);
125 | mHost = null;
126 | }
127 | }
128 |
129 |
130 | public bool Accept(int connectionId, int playerId)
131 | {
132 | if (mHost == null)
133 | {
134 | return false;
135 | }
136 |
137 | try
138 | {
139 | if (!mHost.Accept(connectionId, playerId))
140 | {
141 | Debug.LogError("failed to Accept");
142 | return false;
143 | }
144 | }
145 | catch (Exception e)
146 | {
147 | Debug.LogException(e);
148 | mHost = null;
149 | return false;
150 | }
151 |
152 | return true;
153 | }
154 |
155 | public void Invalidate(int connectionId)
156 | {
157 | if (mHost == null)
158 | {
159 | return;
160 | }
161 |
162 | try
163 | {
164 | mHost.Invalidate(connectionId);
165 | }
166 | catch (Exception e)
167 | {
168 | Debug.LogException(e);
169 | mHost = null;
170 | }
171 | }
172 |
173 | public bool SendDirect(byte[] message, int messageSize, int connectionId)
174 | {
175 | if (mHost == null)
176 | {
177 | return false;
178 | }
179 |
180 | try
181 | {
182 | mHost.SendDirect(message, messageSize, connectionId);
183 | }
184 | catch (Exception e)
185 | {
186 | Debug.LogException(e);
187 | mHost = null;
188 | return false;
189 | }
190 |
191 | return true;
192 | }
193 |
194 | public bool Send(byte[] message, int messageSize, int receiver)
195 | {
196 | if (mHost == null)
197 | {
198 | return false;
199 | }
200 |
201 | try
202 | {
203 | mHost.Send(message, messageSize, receiver);
204 | }
205 | catch (Exception e)
206 | {
207 | Debug.LogException(e);
208 | mHost = null;
209 | return false;
210 | }
211 |
212 | return true;
213 | }
214 |
215 | public override void Cleanup()
216 | {
217 | if (mHost != null)
218 | {
219 | try
220 | {
221 | mHost.Cleanup();
222 | }
223 | catch (Exception e)
224 | {
225 | Debug.LogException(e);
226 | }
227 |
228 | mHost = null;
229 | }
230 |
231 | base.Cleanup();
232 |
233 | onBluetoothRequire = null;
234 | onReady = null;
235 | onFail = null;
236 |
237 | onConnect = null;
238 | onDisconnect = null;
239 |
240 | onReceiveDirect = null;
241 | onReceive = null;
242 | }
243 |
244 | // Internal
245 |
246 | private IWcfPeripheralHost mHost;
247 |
248 | protected override void OnProcessExited()
249 | {
250 | base.OnProcessExited();
251 |
252 | mHost = null;
253 | }
254 |
255 | // IWcfPeripheralCallback
256 |
257 | void IWcfPeripheralCallback.OnBluetoothRequire()
258 | {
259 | onBluetoothRequire?.Invoke();
260 | }
261 |
262 | void IWcfPeripheralCallback.OnReady()
263 | {
264 | onReady?.Invoke();
265 | }
266 |
267 | void IWcfPeripheralCallback.OnFail()
268 | {
269 | onFail?.Invoke();
270 | }
271 |
272 | void IWcfPeripheralCallback.OnConnect(int connectionId)
273 | {
274 | onConnect?.Invoke(connectionId);
275 | }
276 |
277 | void IWcfPeripheralCallback.OnDisconnect(int connectionId)
278 | {
279 | onDisconnect?.Invoke(connectionId);
280 | }
281 |
282 | void IWcfPeripheralCallback.OnReceiveDirect(byte[] message, int connectionId)
283 | {
284 | onReceiveDirect?.Invoke(message, connectionId);
285 | }
286 |
287 | void IWcfPeripheralCallback.OnReceive(byte[] message, int sender)
288 | {
289 | onReceive?.Invoke(message, sender);
290 | }
291 | }
292 | }
293 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/PeerBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Security.Cryptography;
5 | using System.Threading;
6 |
7 | using UnityEngine;
8 |
9 | namespace BleSock
10 | {
11 | public static class Address
12 | {
13 | // Constants
14 |
15 | public const int Host = 1;
16 | public const int All = 0xffff;
17 | public const int Others = 0x10000;
18 | }
19 |
20 | public abstract class PeerBase : IDisposable
21 | {
22 | // Events
23 |
24 | public event Action onBluetoothRequire;
25 | public event Action onReady;
26 | public event Action onFail;
27 |
28 | public event Action onPlayerJoin;
29 | public event Action onPlayerLeave;
30 |
31 | public event Action onReceive;
32 |
33 | // Properties
34 |
35 | public bool IsReady
36 | {
37 | get
38 | {
39 | return mReady;
40 | }
41 | }
42 |
43 | public IList Players
44 | {
45 | get
46 | {
47 | return mPlayers.AsReadOnly();
48 | }
49 | }
50 |
51 | public Player LocalPlayer
52 | {
53 | get
54 | {
55 | return mPlayers.Where(p => p.PlayerId == LocalPlayerId).FirstOrDefault();
56 | }
57 | }
58 |
59 | public abstract bool IsBluetoothEnabled { get; }
60 |
61 | public abstract int LocalPlayerId { get; }
62 |
63 | // Methods
64 |
65 | public abstract void Send(byte[] message, int messageSize, int receiver);
66 |
67 | public virtual void Cleanup()
68 | {
69 | onBluetoothRequire = null;
70 | onReady = null;
71 | onFail = null;
72 | onPlayerJoin = null;
73 | onPlayerLeave = null;
74 | onReceive = null;
75 |
76 | mReady = false;
77 | mSynchronizationContext = null;
78 | mServiceUUID = null;
79 | mUploadUUID = null;
80 | mDownloadUUID = null;
81 | mAuthData = null;
82 | mLocalPlayerName = null;
83 | mPlayers.Clear();
84 | mSendBuffer = null;
85 | mReceiveBuffer = null;
86 | }
87 |
88 | public void Dispose()
89 | {
90 | Cleanup();
91 | }
92 |
93 | // Internal
94 |
95 | protected const int MESSAGE_SIZE_MAX = 4096;
96 | protected const int PLAYER_NAME_LENGTH_MAX = 32;
97 |
98 | // protected const byte SYSMSG_REQUEST_PING = 0;
99 | // protected const byte SYSMSG_RESPOND_PING = 1;
100 |
101 | protected const byte SYSMSG_REQUEST_AUTHENTICATION = 10;
102 | protected const byte SYSMSG_ACCEPT_AUTHENTICATION = 11;
103 | protected const byte SYSMSG_PLAYER_JOIN = 12;
104 | protected const byte SYSMSG_PLAYER_LEAVE = 13;
105 |
106 | protected const byte SYSMSG_RESPOND_AUTHENTICATION = 20;
107 |
108 | private readonly byte[] PBKDF2_SALT = { 0x6d, 0x9f, 0x67, 0x59, 0x05, 0xc8, 0xbb, 0x21 };
109 | private const int PBKDF2_ITERATIONS = 1193;
110 |
111 |
112 | protected bool mReady;
113 | protected SynchronizationContext mSynchronizationContext;
114 | protected string mServiceUUID;
115 | protected string mUploadUUID;
116 | protected string mDownloadUUID;
117 | protected byte[] mAuthData;
118 | protected string mLocalPlayerName;
119 | protected List mPlayers = new List();
120 | protected MessageBuffer mSendBuffer;
121 | protected MessageBuffer mReceiveBuffer;
122 |
123 |
124 | protected void InitializeInternal(string protocolIdentifier, string playerName, SynchronizationContext synchronizationContext)
125 | {
126 | if (string.IsNullOrEmpty(protocolIdentifier))
127 | {
128 | throw new Exception("Invalid protocol-identifier");
129 | }
130 |
131 | if (string.IsNullOrEmpty(playerName))
132 | {
133 | throw new Exception("Invalid player-name");
134 | }
135 |
136 | if (playerName.Length > PLAYER_NAME_LENGTH_MAX)
137 | {
138 | throw new Exception("Player-name too long");
139 | }
140 |
141 | mSynchronizationContext = (synchronizationContext != null) ? synchronizationContext : SynchronizationContext.Current;
142 | if (mSynchronizationContext == null)
143 | {
144 | throw new Exception("Synchronization context is null");
145 | }
146 |
147 | var deriveBytes = new Rfc2898DeriveBytes(protocolIdentifier, PBKDF2_SALT, PBKDF2_ITERATIONS);
148 |
149 | mServiceUUID = new Guid(deriveBytes.GetBytes(16)).ToString("D");
150 | mUploadUUID = new Guid(deriveBytes.GetBytes(16)).ToString("D");
151 | mDownloadUUID = new Guid(deriveBytes.GetBytes(16)).ToString("D");
152 | // Debug.LogFormat("serviceUUID: {0} uploadUUID: {1} downloadUUID: {2}", mServiceUUID, mUploadUUID, mDownloadUUID);
153 |
154 | mAuthData = deriveBytes.GetBytes(16);
155 |
156 | mLocalPlayerName = playerName;
157 |
158 | mSendBuffer = new MessageBuffer();
159 | mReceiveBuffer = new MessageBuffer();
160 | }
161 |
162 | protected int PrepareSend(byte[] message, int messageSize, int receiver)
163 | {
164 | if (!IsReady)
165 | {
166 | throw new Exception("Not ready");
167 | }
168 |
169 | if (message == null)
170 | {
171 | throw new Exception("Message is null");
172 | }
173 |
174 | if (messageSize < 0)
175 | {
176 | throw new Exception("Invalid message-size");
177 | }
178 |
179 | if ((messageSize > message.Length) || (messageSize > MESSAGE_SIZE_MAX))
180 | {
181 | throw new Exception("Message-size too large");
182 | }
183 |
184 | int result = receiver;
185 |
186 | if ((receiver & Address.Others) != 0)
187 | {
188 | result |= ~LocalPlayerId;
189 | }
190 |
191 | return result & 0xffff;
192 | }
193 |
194 | protected void Post(Action action)
195 | {
196 | if ((mSynchronizationContext == null) || (action == null))
197 | {
198 | return;
199 | }
200 |
201 | mSynchronizationContext.Post(_ =>
202 | {
203 | action();
204 | }, null);
205 | }
206 |
207 | protected void InvokeOnBluetoothRequire()
208 | {
209 | if (onBluetoothRequire != null)
210 | {
211 | try
212 | {
213 | onBluetoothRequire();
214 | }
215 | catch (Exception e)
216 | {
217 | Debug.LogException(e);
218 | }
219 | }
220 | }
221 |
222 | protected void InvokeOnReady()
223 | {
224 | if (onReady != null)
225 | {
226 | try
227 | {
228 | onReady();
229 | }
230 | catch (Exception e)
231 | {
232 | Debug.LogException(e);
233 | }
234 | }
235 | }
236 |
237 | protected void InvokeOnFail()
238 | {
239 | if (onFail != null)
240 | {
241 | try
242 | {
243 | onFail();
244 | }
245 | catch (Exception e)
246 | {
247 | Debug.LogException(e);
248 | }
249 | }
250 | }
251 |
252 | protected void InvokeOnPlayerJoin(Player player)
253 | {
254 | if (onPlayerJoin != null)
255 | {
256 | try
257 | {
258 | onPlayerJoin(player);
259 | }
260 | catch (Exception e)
261 | {
262 | Debug.LogException(e);
263 | }
264 | }
265 | }
266 |
267 | protected void InvokeOnPlayerLeave(Player player)
268 | {
269 | if (onPlayerLeave != null)
270 | {
271 | try
272 | {
273 | onPlayerLeave(player);
274 | }
275 | catch (Exception e)
276 | {
277 | Debug.LogException(e);
278 | }
279 | }
280 | }
281 |
282 | protected void InvokeOnReceive(byte[] message, int messageSize, int playerId)
283 | {
284 | var player = mPlayers.Where(p => p.PlayerId == playerId).FirstOrDefault();
285 | if (player == null)
286 | {
287 | Debug.LogWarningFormat("Invalid playerId: {0}", playerId);
288 | return;
289 | }
290 |
291 | if (onReceive != null)
292 | {
293 | try
294 | {
295 | onReceive(message, messageSize, player);
296 | }
297 | catch (Exception e)
298 | {
299 | Debug.LogException(e);
300 | }
301 | }
302 | }
303 | }
304 | }
305 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/MessageBuffer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Runtime.InteropServices;
4 | using System.Text;
5 |
6 | using UnityEngine;
7 |
8 | namespace BleSock
9 | {
10 | public class MessageBuffer
11 | {
12 | // Properties
13 |
14 | public byte[] RawData
15 | {
16 | get
17 | {
18 | return mRawData;
19 | }
20 | }
21 |
22 | public int Capacity
23 | {
24 | get
25 | {
26 | return mRawData.Length;
27 | }
28 | }
29 |
30 | public int Size
31 | {
32 | get
33 | {
34 | return mSize;
35 | }
36 | }
37 |
38 | public int Position
39 | {
40 | get
41 | {
42 | return mPosition;
43 | }
44 | }
45 |
46 | public bool IsReallocAllowed
47 | {
48 | get
49 | {
50 | return mReallocAllowed;
51 | }
52 | }
53 |
54 | // Constructors
55 |
56 | public MessageBuffer(int capacity = 1024, bool reallocAllowed = true)
57 | {
58 | Debug.Assert(capacity > 0);
59 |
60 | mRawData = new byte[capacity];
61 | mSize = 0;
62 | mPosition = 0;
63 | mReallocAllowed = reallocAllowed;
64 | }
65 |
66 | // Methods
67 |
68 | public void Clear()
69 | {
70 | mSize = 0;
71 | mPosition = 0;
72 | }
73 |
74 | public void Seek(int position)
75 | {
76 | Debug.Assert(position >= 0);
77 | Debug.Assert(position < mSize);
78 |
79 | mPosition = position;
80 | }
81 |
82 | public byte[] GetBytes()
83 | {
84 | var bytes = new byte[mSize];
85 | Array.Copy(mRawData, bytes, mSize);
86 |
87 | return bytes;
88 | }
89 |
90 | public ArraySegment GetArraySegment()
91 | {
92 | return new ArraySegment(mRawData, 0, mSize);
93 | }
94 |
95 | public void Write(int value)
96 | {
97 | Write((byte)value);
98 | Write((byte)(value >> 8));
99 | Write((byte)(value >> 16));
100 | Write((byte)(value >> 24));
101 | }
102 |
103 | public void Write(uint value)
104 | {
105 | Write((byte)value);
106 | Write((byte)(value >> 8));
107 | Write((byte)(value >> 16));
108 | Write((byte)(value >> 24));
109 | }
110 |
111 | public void Write(short value)
112 | {
113 | Write((byte)value);
114 | Write((byte)(value >> 8));
115 | }
116 |
117 | public void Write(ushort value)
118 | {
119 | Write((byte)value);
120 | Write((byte)(value >> 8));
121 | }
122 |
123 | public void Write(char value)
124 | {
125 | Write((byte)value);
126 | }
127 |
128 | public void Write(byte value)
129 | {
130 | PrepareWrite(1);
131 |
132 | mRawData[mPosition++] = value;
133 | mSize = Math.Max(mPosition, mSize);
134 | }
135 |
136 | public void Write(bool value)
137 | {
138 | Write((byte)(value ? 1 : 0));
139 | }
140 |
141 | public void Write(float value)
142 | {
143 | mTypeConvert.single = value;
144 |
145 | Write(mTypeConvert.int32);
146 | }
147 |
148 | public void WriteString(string str, bool large = false)
149 | {
150 | Debug.Assert(str != null);
151 |
152 | int size = Encoding.UTF8.GetByteCount(str);
153 |
154 | if (large)
155 | {
156 | Debug.Assert(size <= UInt16.MaxValue);
157 |
158 | Write((UInt16)size);
159 | }
160 | else
161 | {
162 | Debug.Assert(size <= byte.MaxValue);
163 |
164 | Write((byte)size);
165 | }
166 |
167 | PrepareWrite(size);
168 |
169 | Encoding.UTF8.GetBytes(str, 0, str.Length, mRawData, mPosition);
170 |
171 | mPosition += size;
172 | mSize = Math.Max(mPosition, mSize);
173 | }
174 |
175 | public void WriteBytes(byte[] bytes, int offset, int count)
176 | {
177 | Debug.Assert(bytes != null);
178 | Debug.Assert(offset >= 0);
179 | Debug.Assert(count >= 0);
180 | Debug.Assert(offset + count <= bytes.Length);
181 |
182 | PrepareWrite(count);
183 |
184 | Array.Copy(bytes, offset, mRawData, mPosition, count);
185 |
186 | mPosition += count;
187 | mSize = Math.Max(mPosition, mSize);
188 | }
189 |
190 | public void WriteStream(Stream stream, int length)
191 | {
192 | Debug.Assert(stream != null);
193 | Debug.Assert(length >= 0);
194 | Debug.Assert(length <= stream.Length - stream.Position);
195 |
196 | PrepareWrite(length);
197 |
198 | int size = stream.Read(mRawData, mPosition, length);
199 | Debug.Assert(size == length);
200 |
201 | mPosition += length;
202 | mSize = Math.Max(mPosition, mSize);
203 | }
204 |
205 |
206 | public int ReadInt32()
207 | {
208 | PrepareRead(sizeof(int));
209 |
210 | int result = BitConverter.ToInt32(mRawData, mPosition);
211 | mPosition += sizeof(int);
212 |
213 | return result;
214 | }
215 |
216 | public uint ReadUInt32()
217 | {
218 | PrepareRead(sizeof(uint));
219 |
220 | uint result = BitConverter.ToUInt32(mRawData, mPosition);
221 | mPosition += sizeof(uint);
222 |
223 | return result;
224 | }
225 |
226 | public short ReadInt16()
227 | {
228 | PrepareRead(sizeof(short));
229 |
230 | short result = BitConverter.ToInt16(mRawData, mPosition);
231 | mPosition += sizeof(short);
232 |
233 | return result;
234 | }
235 |
236 | public ushort ReadUInt16()
237 | {
238 | PrepareRead(sizeof(ushort));
239 |
240 | ushort result = BitConverter.ToUInt16(mRawData, mPosition);
241 | mPosition += sizeof(ushort);
242 |
243 | return result;
244 | }
245 |
246 | public char ReadChar()
247 | {
248 | PrepareRead(sizeof(char));
249 |
250 | char result = (char)mRawData[mPosition];
251 | mPosition += sizeof(char);
252 |
253 | return result;
254 | }
255 |
256 | public byte ReadByte()
257 | {
258 | PrepareRead(sizeof(byte));
259 |
260 | byte result = mRawData[mPosition];
261 | mPosition += sizeof(byte);
262 |
263 | return result;
264 | }
265 |
266 | public bool ReadBoolean()
267 | {
268 | return (ReadByte() > 0);
269 | }
270 |
271 | public float ReadSingle()
272 | {
273 | PrepareRead(sizeof(float));
274 |
275 | float result = BitConverter.ToSingle(mRawData, mPosition);
276 | mPosition += sizeof(float);
277 |
278 | return result;
279 | }
280 |
281 | public string ReadString(bool large = false)
282 | {
283 | int size = large ? ReadUInt16() : ReadByte();
284 | PrepareRead(size);
285 |
286 | var result = Encoding.UTF8.GetString(mRawData, mPosition, size);
287 | mPosition += size;
288 |
289 | return result;
290 | }
291 |
292 | public void ReadBytes(byte[] bytes, int offset, int count)
293 | {
294 | Debug.Assert(bytes != null);
295 | Debug.Assert(offset >= 0);
296 | Debug.Assert(count >= 0);
297 | Debug.Assert(offset + count <= bytes.Length);
298 |
299 | PrepareRead(count);
300 |
301 | Array.Copy(mRawData, mPosition, bytes, offset, count);
302 |
303 | mPosition += count;
304 | }
305 |
306 | // Internal
307 |
308 | [StructLayout(LayoutKind.Explicit)]
309 | private struct TypeConvert
310 | {
311 | [FieldOffset(0)]
312 | public int int32;
313 |
314 | [FieldOffset(0)]
315 | public uint uint32;
316 |
317 | [FieldOffset(0)]
318 | public short int16;
319 |
320 | [FieldOffset(0)]
321 | public ushort ushort16;
322 |
323 | [FieldOffset(0)]
324 | public float single;
325 |
326 | [FieldOffset(0)]
327 | public byte byte0;
328 |
329 | [FieldOffset(1)]
330 | public byte byte1;
331 |
332 | [FieldOffset(2)]
333 | public byte byte2;
334 |
335 | [FieldOffset(3)]
336 | public byte byte3;
337 | };
338 |
339 | private byte[] mRawData;
340 | private int mSize;
341 | private int mPosition;
342 | private bool mReallocAllowed;
343 | private TypeConvert mTypeConvert = new TypeConvert();
344 |
345 | private void PrepareWrite(int size)
346 | {
347 | if (mPosition + size > mRawData.Length)
348 | {
349 | Debug.Assert(mReallocAllowed);
350 |
351 | int newSize = mRawData.Length;
352 | while (newSize < mPosition + size)
353 | {
354 | newSize *= 2;
355 | }
356 |
357 | Array.Resize(ref mRawData, newSize);
358 | }
359 | }
360 |
361 | private void PrepareRead(int size)
362 | {
363 | Debug.Assert(mPosition + size <= mSize);
364 | }
365 | }
366 | }
367 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/SpeedTest/SpeedTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Security.Cryptography;
4 | using System.Text;
5 |
6 | using UnityEngine;
7 | using UnityEngine.UI;
8 |
9 | public class SpeedTest : MonoBehaviour
10 | {
11 | public GameObject modeSelectObject;
12 | public InputField playerNameInputField;
13 | public Button hostButton;
14 | public Button joinButton;
15 |
16 | public GameObject connectObject;
17 | public Dropdown devicesDropdown;
18 | public Button connectButton;
19 |
20 | public GameObject testObject;
21 | public Text logsText;
22 | public Dropdown sizesDropdown;
23 | public Button testButton;
24 | public Button backButton;
25 |
26 |
27 | private const string PROTOCOL_IDENTIFIER = "SpeedTest";
28 |
29 |
30 | private class ValueOptionData : Dropdown.OptionData
31 | {
32 | public int value { get; private set; }
33 |
34 | public ValueOptionData(string text, int value)
35 | {
36 | this.text = text;
37 | this.value = value;
38 | }
39 | }
40 |
41 |
42 | private BleSock.PeerBase mPeer;
43 | private RandomNumberGenerator mRandom = RandomNumberGenerator.Create();
44 | private int mStartTime;
45 | private List mLogs = new List();
46 |
47 |
48 | private void Start()
49 | {
50 | modeSelectObject.SetActive(true);
51 |
52 | playerNameInputField.onEndEdit.AddListener((name) =>
53 | {
54 | bool interactable = !string.IsNullOrEmpty(name);
55 | hostButton.interactable = interactable;
56 | joinButton.interactable = interactable;
57 | });
58 |
59 | // Host
60 |
61 | hostButton.interactable = false;
62 | hostButton.onClick.AddListener(() =>
63 | {
64 | modeSelectObject.SetActive(false);
65 | testObject.SetActive(true);
66 |
67 | backButton.interactable = true;
68 |
69 | var host = new BleSock.HostPeer();
70 | host.MaximumPlayers = 2;
71 |
72 | host.onReady += () =>
73 | {
74 | Log("初期化が完了しました");
75 |
76 | try
77 | {
78 | host.StartAdvertising(playerNameInputField.text);
79 | }
80 | catch (Exception e)
81 | {
82 | Debug.LogException(e);
83 | Log("アドバタイズ開始できません");
84 | }
85 |
86 | Log("接続を待っています..");
87 | };
88 |
89 | host.onBluetoothRequire += () =>
90 | {
91 | Log("Bluetoothを有効にしてください");
92 | };
93 |
94 | host.onFail += () =>
95 | {
96 | Log("失敗しました");
97 | };
98 |
99 | host.onPlayerJoin += (player) =>
100 | {
101 | Log("{0} が参加しました", player.PlayerName);
102 | sizesDropdown.interactable = true;
103 | testButton.interactable = true;
104 | };
105 |
106 | host.onPlayerLeave += (player) =>
107 | {
108 | Log("{0} が離脱しました", player.PlayerName);
109 | sizesDropdown.interactable = false;
110 | testButton.interactable = false;
111 | };
112 |
113 | host.onReceive += OnReceive;
114 |
115 | try
116 | {
117 | host.Initialize(PROTOCOL_IDENTIFIER, playerNameInputField.text);
118 | }
119 | catch (Exception e)
120 | {
121 | Debug.LogException(e);
122 | Log("初期化できません");
123 | return;
124 | }
125 |
126 | Log("初期化しています..");
127 | mPeer = host;
128 | });
129 |
130 | // Guest
131 |
132 | connectObject.SetActive(false);
133 |
134 | joinButton.interactable = false;
135 | joinButton.onClick.AddListener(() =>
136 | {
137 | modeSelectObject.SetActive(false);
138 | connectObject.SetActive(true);
139 | testObject.SetActive(true);
140 |
141 | devicesDropdown.interactable = false;
142 | connectButton.interactable = false;
143 |
144 | backButton.interactable = true;
145 |
146 | var guest = new BleSock.GuestPeer();
147 |
148 | guest.onBluetoothRequire += () =>
149 | {
150 | Log("Bluetoothを有効にしてください");
151 | };
152 |
153 | guest.onReady += () =>
154 | {
155 | Log("初期化が完了しました");
156 |
157 | try
158 | {
159 | guest.StartScan();
160 | }
161 | catch (Exception e)
162 | {
163 | Debug.LogException(e);
164 | Log("スキャン開始できません");
165 | return;
166 | }
167 |
168 | Log("デバイスを探索しています..");
169 | devicesDropdown.ClearOptions();
170 | };
171 |
172 | guest.onFail += () =>
173 | {
174 | Log("失敗しました");
175 | };
176 |
177 | guest.onDiscover += (deviceName, deviceId) =>
178 | {
179 | Log("デバイスを発見: {0} [{1}]", deviceName, deviceId);
180 | devicesDropdown.options.Add(new ValueOptionData(deviceName, deviceId));
181 |
182 | if (!devicesDropdown.interactable)
183 | {
184 | devicesDropdown.interactable = true;
185 | devicesDropdown.value = 0;
186 | devicesDropdown.RefreshShownValue();
187 | connectButton.interactable = true;
188 | }
189 | };
190 |
191 | guest.onConnect += () =>
192 | {
193 | Log("接続されました");
194 | sizesDropdown.interactable = true;
195 | testButton.interactable = true;
196 | };
197 |
198 | guest.onDisconnect += () =>
199 | {
200 | Log("切断されました");
201 | sizesDropdown.interactable = false;
202 | testButton.interactable = false;
203 | };
204 |
205 | guest.onPlayerJoin += (player) =>
206 | {
207 | Log("{0} が参加しました", player.PlayerName);
208 | };
209 |
210 | guest.onPlayerLeave += (player) =>
211 | {
212 | Log("{0} が離脱しました", player.PlayerName);
213 | };
214 |
215 | guest.onReceive += OnReceive;
216 |
217 | try
218 | {
219 | guest.Initialize(PROTOCOL_IDENTIFIER, playerNameInputField.text);
220 | }
221 | catch (Exception e)
222 | {
223 | Debug.LogException(e);
224 | Log("初期化できません");
225 | return;
226 | }
227 |
228 | Log("初期化しています..");
229 | mPeer = guest;
230 | });
231 |
232 | connectButton.onClick.AddListener(() =>
233 | {
234 | var optionData = (ValueOptionData)devicesDropdown.options[devicesDropdown.value];
235 | try
236 | {
237 | ((BleSock.GuestPeer)mPeer).Connect(optionData.value);
238 | }
239 | catch (Exception e)
240 | {
241 | Debug.LogException(e);
242 | Log("エラー");
243 | return;
244 | }
245 |
246 | Log("デバイスに接続しています..");
247 | devicesDropdown.interactable = false;
248 | connectButton.interactable = false;
249 | });
250 |
251 | // Test
252 |
253 | testObject.SetActive(false);
254 |
255 | sizesDropdown.interactable = false;
256 | for (int i = 8; i < 13; ++i)
257 | {
258 | int size = 1 << i;
259 | sizesDropdown.options.Add(new ValueOptionData(size.ToString(), size));
260 | }
261 | sizesDropdown.value = 0;
262 |
263 | testButton.interactable = false;
264 | testButton.onClick.AddListener(() =>
265 | {
266 | int size = ((ValueOptionData)sizesDropdown.options[sizesDropdown.value]).value;
267 | var bytes = new byte[size];
268 |
269 | mRandom.GetBytes(bytes);
270 |
271 | bytes[0] = 0;
272 |
273 | try
274 | {
275 | mPeer.Send(bytes, bytes.Length, BleSock.Address.Others);
276 | }
277 | catch (Exception e)
278 | {
279 | Debug.LogException(e);
280 | Log("エラー");
281 | return;
282 | }
283 |
284 | Log("スピード計測中..");
285 | mStartTime = Environment.TickCount;
286 | sizesDropdown.interactable = false;
287 | testButton.interactable = false;
288 | });
289 |
290 | backButton.interactable = false;
291 | backButton.onClick.AddListener(() =>
292 | {
293 | if (mPeer != null)
294 | {
295 | mPeer.Dispose();
296 | mPeer = null;
297 | }
298 |
299 | mLogs.Clear();
300 |
301 | modeSelectObject.SetActive(true);
302 | connectObject.SetActive(false);
303 | testObject.SetActive(false);
304 | });
305 | }
306 |
307 | private void OnReceive(byte[] message, int messageSize, BleSock.Player sender)
308 | {
309 | if (message[0] == 0)
310 | {
311 | message[0] = 1;
312 |
313 | try
314 | {
315 | mPeer.Send(message, message.Length, BleSock.Address.Others);
316 | }
317 | catch (Exception e)
318 | {
319 | Debug.LogException(e);
320 | Log("エラー");
321 | return;
322 | }
323 | }
324 | else
325 | {
326 | Log("計測が完了しました: {0} bytes/sec", (float)messageSize * 1000 / (Environment.TickCount - mStartTime));
327 | sizesDropdown.interactable = true;
328 | testButton.interactable = true;
329 | }
330 | }
331 |
332 | private void OnDestroy()
333 | {
334 | if (mPeer != null)
335 | {
336 | mPeer.Dispose();
337 | mPeer = null;
338 | }
339 | }
340 |
341 | private void Log(string format, params object[] args)
342 | {
343 | mLogs.Add(string.Format(format, args));
344 |
345 | if (mLogs.Count > 12)
346 | {
347 | mLogs.RemoveAt(0);
348 | }
349 |
350 | var builder = new StringBuilder();
351 | foreach (var log in mLogs)
352 | {
353 | builder.AppendLine(log);
354 | }
355 |
356 | logsText.text = builder.ToString();
357 | }
358 | }
359 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Demos/ChatTest/ChatTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | using UnityEngine;
6 | using UnityEngine.UI;
7 |
8 | public class ChatTest : MonoBehaviour
9 | {
10 | public GameObject modeSelectObject;
11 | public InputField playerNameInputField;
12 | public Button hostButton;
13 | public Button joinButton;
14 |
15 | public GameObject hostObject;
16 | public Button advertiseButton;
17 | public Button stopButton;
18 |
19 | public GameObject guestObject;
20 | public Dropdown devicesDropdown;
21 | public Button connectButton;
22 | public Button disconnectButton;
23 |
24 | public GameObject chatObject;
25 | public Text statusText;
26 | public Text logsText;
27 | public InputField sendInputField;
28 | public Button backButton;
29 |
30 |
31 | private const string PROTOCOL_IDENTIFIER = "ChatTest";
32 |
33 |
34 | private class DeviceOptionData : Dropdown.OptionData
35 | {
36 | public int deviceId { get; private set; }
37 |
38 | public DeviceOptionData(string deviceName, int deviceId)
39 | {
40 | text = deviceName;
41 | this.deviceId = deviceId;
42 | }
43 | }
44 |
45 |
46 | private BleSock.PeerBase mPeer;
47 | private List mLogs = new List();
48 |
49 |
50 | private void Start()
51 | {
52 | modeSelectObject.SetActive(true);
53 |
54 | playerNameInputField.onEndEdit.AddListener((name) =>
55 | {
56 | bool interactable = !string.IsNullOrEmpty(name);
57 | hostButton.interactable = interactable;
58 | joinButton.interactable = interactable;
59 | });
60 |
61 | // Host
62 |
63 | hostObject.SetActive(false);
64 |
65 | hostButton.interactable = false;
66 | hostButton.onClick.AddListener(() =>
67 | {
68 | modeSelectObject.SetActive(false);
69 | hostObject.SetActive(true);
70 | chatObject.SetActive(true);
71 |
72 | advertiseButton.interactable = false;
73 | stopButton.interactable = false;
74 |
75 | backButton.interactable = true;
76 |
77 | var host = new BleSock.HostPeer();
78 |
79 | host.onReady += () =>
80 | {
81 | Log("初期化が完了しました");
82 | advertiseButton.interactable = true;
83 | sendInputField.interactable = true;
84 | };
85 |
86 | host.onBluetoothRequire += () =>
87 | {
88 | Log("Bluetoothを有効にしてください");
89 | };
90 |
91 | host.onFail += () =>
92 | {
93 | Log("失敗しました");
94 | };
95 |
96 | host.onPlayerJoin += (player) =>
97 | {
98 | Log("{0} が参加しました", player.PlayerName);
99 | };
100 |
101 | host.onPlayerLeave += (player) =>
102 | {
103 | Log("{0} が離脱しました", player.PlayerName);
104 | };
105 |
106 | host.onReceive += (message, messageSize, sender) =>
107 | {
108 | Log("{0}: {1}", sender.PlayerName, Encoding.UTF8.GetString(message, 0, messageSize));
109 | };
110 |
111 | try
112 | {
113 | host.Initialize(PROTOCOL_IDENTIFIER, playerNameInputField.text);
114 | }
115 | catch (Exception e)
116 | {
117 | Debug.LogException(e);
118 | Log("初期化できません");
119 | return;
120 | }
121 |
122 | Log("初期化しています..");
123 | mPeer = host;
124 | });
125 |
126 | advertiseButton.onClick.AddListener(() =>
127 | {
128 | try
129 | {
130 | ((BleSock.HostPeer)mPeer).StartAdvertising(playerNameInputField.text);
131 | }
132 | catch (Exception e)
133 | {
134 | Debug.LogException(e);
135 | Log("アドバタイズ開始できません");
136 | return;
137 | }
138 |
139 | Log("アドバタイズしています..");
140 | advertiseButton.interactable = false;
141 | stopButton.interactable = true;
142 | });
143 |
144 | stopButton.onClick.AddListener(() =>
145 | {
146 | ((BleSock.HostPeer)mPeer).StopAdvertising();
147 |
148 | Log("アドバタイズを停止しました");
149 | advertiseButton.interactable = true;
150 | stopButton.interactable = false;
151 | });
152 |
153 | // Guest
154 |
155 | guestObject.SetActive(false);
156 |
157 | joinButton.interactable = false;
158 | joinButton.onClick.AddListener(() =>
159 | {
160 | modeSelectObject.SetActive(false);
161 | guestObject.SetActive(true);
162 | chatObject.SetActive(true);
163 |
164 | devicesDropdown.interactable = false;
165 | connectButton.interactable = false;
166 | disconnectButton.interactable = false;
167 |
168 | backButton.interactable = true;
169 |
170 | var guest = new BleSock.GuestPeer();
171 |
172 | guest.onBluetoothRequire += () =>
173 | {
174 | Log("Bluetoothを有効にしてください");
175 | };
176 |
177 | guest.onReady += () =>
178 | {
179 | Log("初期化が完了しました");
180 |
181 | try
182 | {
183 | guest.StartScan();
184 | }
185 | catch (Exception e)
186 | {
187 | Debug.LogException(e);
188 | Log("スキャン開始できません");
189 | return;
190 | }
191 |
192 | Log("デバイスを探索しています..");
193 | devicesDropdown.ClearOptions();
194 | };
195 |
196 | guest.onFail += () =>
197 | {
198 | Log("失敗しました");
199 | };
200 |
201 | guest.onDiscover += (deviceName, deviceId) =>
202 | {
203 | Log("デバイスを発見: {0} [{1}]", deviceName, deviceId);
204 | devicesDropdown.options.Add(new DeviceOptionData(deviceName, deviceId));
205 |
206 | if (!devicesDropdown.interactable)
207 | {
208 | devicesDropdown.interactable = true;
209 | devicesDropdown.value = 0;
210 | devicesDropdown.RefreshShownValue();
211 | connectButton.interactable = true;
212 | }
213 | };
214 |
215 | guest.onConnect += () =>
216 | {
217 | Log("接続されました");
218 |
219 | foreach (var player in guest.Players)
220 | {
221 | Log(player.PlayerName);
222 | }
223 |
224 | sendInputField.interactable = true;
225 | };
226 |
227 | guest.onDisconnect += () =>
228 | {
229 | Log("切断されました");
230 | sendInputField.interactable = false;
231 | disconnectButton.interactable = false;
232 | };
233 |
234 | guest.onPlayerJoin += (player) =>
235 | {
236 | Log("{0} が参加しました", player.PlayerName);
237 | };
238 |
239 | guest.onPlayerLeave += (player) =>
240 | {
241 | Log("{0} が離脱しました", player.PlayerName);
242 | };
243 |
244 | guest.onReceive += (message, messageSize, sender) =>
245 | {
246 | Log("{0}: {1}", sender.PlayerName, Encoding.UTF8.GetString(message, 0, messageSize));
247 | };
248 |
249 | try
250 | {
251 | guest.Initialize(PROTOCOL_IDENTIFIER, playerNameInputField.text);
252 | }
253 | catch (Exception e)
254 | {
255 | Debug.LogException(e);
256 | Log("初期化できません");
257 | return;
258 | }
259 |
260 | Log("初期化しています..");
261 | mPeer = guest;
262 | });
263 |
264 | connectButton.onClick.AddListener(() =>
265 | {
266 | var optionData = (DeviceOptionData)devicesDropdown.options[devicesDropdown.value];
267 | try
268 | {
269 | ((BleSock.GuestPeer)mPeer).Connect(optionData.deviceId);
270 | }
271 | catch (Exception e)
272 | {
273 | Debug.LogException(e);
274 | Log("エラー");
275 | return;
276 | }
277 |
278 | Log("デバイスに接続しています..");
279 | devicesDropdown.interactable = false;
280 | connectButton.interactable = false;
281 | disconnectButton.interactable = true;
282 | });
283 |
284 | disconnectButton.onClick.AddListener(() =>
285 | {
286 | ((BleSock.GuestPeer)mPeer).Disconnect();
287 | });
288 |
289 | // Chat
290 |
291 | chatObject.SetActive(false);
292 |
293 | sendInputField.interactable = false;
294 | sendInputField.onEndEdit.AddListener((text) =>
295 | {
296 | var bytes = Encoding.UTF8.GetBytes(text);
297 | try
298 | {
299 | mPeer.Send(bytes, bytes.Length, BleSock.Address.All);
300 | }
301 | catch (Exception e)
302 | {
303 | Debug.LogException(e);
304 | Log("エラー");
305 | return;
306 | }
307 |
308 | sendInputField.text = "";
309 | });
310 |
311 | backButton.interactable = false;
312 | backButton.onClick.AddListener(() =>
313 | {
314 | if (mPeer != null)
315 | {
316 | mPeer.Dispose();
317 | mPeer = null;
318 | }
319 |
320 | mLogs.Clear();
321 |
322 | modeSelectObject.SetActive(true);
323 | hostObject.SetActive(false);
324 | guestObject.SetActive(false);
325 | chatObject.SetActive(false);
326 | });
327 | }
328 |
329 | private void Update()
330 | {
331 | if (mPeer != null)
332 | {
333 | statusText.text = string.Format("BluetoothEnabled: {0}", mPeer.IsBluetoothEnabled.ToString());
334 | }
335 | }
336 |
337 | private void OnDestroy()
338 | {
339 | if (mPeer != null)
340 | {
341 | mPeer.Dispose();
342 | mPeer = null;
343 | }
344 | }
345 |
346 | private void Log(string format, params object[] args)
347 | {
348 | mLogs.Add(string.Format(format, args));
349 |
350 | if (mLogs.Count > 12)
351 | {
352 | mLogs.RemoveAt(0);
353 | }
354 |
355 | var builder = new StringBuilder();
356 | foreach (var log in mLogs)
357 | {
358 | builder.AppendLine(log);
359 | }
360 |
361 | logsText.text = builder.ToString();
362 | }
363 | }
364 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/GuestPeer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Security.Cryptography;
4 | using System.Threading;
5 |
6 | using UnityEngine;
7 |
8 | namespace BleSock
9 | {
10 | public class GuestPeer : PeerBase
11 | {
12 | // Events
13 |
14 | public event Action onDiscover;
15 | public event Action onConnect;
16 | public event Action onDisconnect;
17 |
18 | // Properties
19 |
20 | public override bool IsBluetoothEnabled
21 | {
22 | get
23 | {
24 | if (mImplementation != null)
25 | {
26 | return mImplementation.IsBluetoothEnabled;
27 | }
28 |
29 | return false;
30 | }
31 | }
32 |
33 | public override int LocalPlayerId
34 | {
35 | get
36 | {
37 | return mLocalPlayerId;
38 | }
39 | }
40 |
41 | // Methods
42 |
43 | public void Initialize(string protocolIdentifier, string playerName, SynchronizationContext synchronizationContext = null)
44 | {
45 | if (mImplementation != null)
46 | {
47 | throw new Exception("Already called initialize");
48 | }
49 |
50 | InitializeInternal(protocolIdentifier, playerName, synchronizationContext);
51 |
52 | mImplementation = new Central();
53 | mImplementation.onBluetoothRequire += OnBluetoothRequire;
54 | mImplementation.onReady += OnReady;
55 | mImplementation.onFail += OnFail;
56 | mImplementation.onDiscover += OnDiscover;
57 | mImplementation.onConnect += OnConnect;
58 | mImplementation.onDisconnect += OnDisconnect;
59 | mImplementation.onReceive += OnReceive;
60 |
61 | if (!mImplementation.Initialize(mServiceUUID, mUploadUUID, mDownloadUUID))
62 | {
63 | mImplementation.Dispose();
64 | mImplementation = null;
65 | throw new Exception("Failed to initialize");
66 | }
67 | }
68 |
69 | public void StartScan()
70 | {
71 | if (!IsReady)
72 | {
73 | throw new Exception("Not ready");
74 | }
75 |
76 | if (mState == State.Scan)
77 | {
78 | return;
79 | }
80 |
81 | if (mImplementation.StartScan())
82 | {
83 | mState = State.Scan;
84 | }
85 | else
86 | {
87 | throw new Exception("Failed to start scan");
88 | }
89 | }
90 |
91 | public void StopScan()
92 | {
93 | if (!IsReady)
94 | {
95 | throw new Exception("Not ready");
96 | }
97 |
98 | if (mState == State.Scan)
99 | {
100 | mImplementation.StopScan();
101 | mState = State.Ready;
102 | }
103 | }
104 |
105 | public void Connect(int deviceId)
106 | {
107 | if (!IsReady)
108 | {
109 | throw new Exception("Not ready");
110 | }
111 |
112 | if ((mState != State.Ready) && (mState != State.Scan))
113 | {
114 | throw new Exception("Already connection started");
115 | }
116 |
117 | StopScan();
118 |
119 | if (mImplementation.Connect(deviceId))
120 | {
121 | mState = State.Connect;
122 | }
123 | else
124 | {
125 | throw new Exception("Failed to connect");
126 | }
127 | }
128 |
129 | public void Disconnect()
130 | {
131 | if (!IsReady)
132 | {
133 | throw new Exception("Not ready");
134 | }
135 |
136 | mImplementation.Disconnect();
137 | }
138 |
139 | public override void Send(byte[] message, int messageSize, int receiver)
140 | {
141 | int address = PrepareSend(message, messageSize, receiver);
142 | if ((address & ~LocalPlayerId) != 0)
143 | {
144 | if (!mImplementation.Send(message, messageSize, address & ~LocalPlayerId))
145 | {
146 | throw new Exception("Failed to send user message");
147 | }
148 | }
149 |
150 | if ((address & LocalPlayerId) != 0)
151 | {
152 | InvokeOnReceive(message, messageSize, LocalPlayerId);
153 | }
154 | }
155 |
156 | public override void Cleanup()
157 | {
158 | onDiscover = null;
159 | onConnect = null;
160 | onDisconnect = null;
161 |
162 | if (mImplementation != null)
163 | {
164 | mImplementation.Dispose();
165 | mImplementation = null;
166 | }
167 |
168 | mState = State.Invalid;
169 | mLocalPlayerId = 0;
170 |
171 | base.Cleanup();
172 | }
173 |
174 | // Internal
175 |
176 | private Central mImplementation;
177 |
178 | private enum State
179 | {
180 | Invalid,
181 | Ready,
182 | Scan,
183 | Connect,
184 | Authenticate,
185 | Online,
186 | }
187 |
188 | private State mState;
189 | private int mLocalPlayerId = 0;
190 |
191 |
192 | private void OnBluetoothRequire()
193 | {
194 | Post(() =>
195 | {
196 | InvokeOnBluetoothRequire();
197 | });
198 | }
199 |
200 | private void OnReady()
201 | {
202 | Post(() =>
203 | {
204 | mReady = true;
205 |
206 | InvokeOnReady();
207 | });
208 | }
209 |
210 | private void OnFail()
211 | {
212 | Post(() =>
213 | {
214 | if (mState != State.Invalid)
215 | {
216 | mState = State.Ready;
217 | }
218 |
219 | InvokeOnFail();
220 | });
221 | }
222 |
223 | private void OnDiscover(string deviceName, int deviceId)
224 | {
225 | Post(() =>
226 | {
227 | if (mState != State.Scan)
228 | {
229 | return;
230 | }
231 |
232 | if (onDiscover != null)
233 | {
234 | try
235 | {
236 | onDiscover(deviceName, deviceId);
237 | }
238 | catch (Exception e)
239 | {
240 | Debug.LogException(e);
241 | }
242 | }
243 | });
244 | }
245 |
246 | private void OnConnect()
247 | {
248 | Post(() =>
249 | {
250 | if (mState != State.Connect)
251 | {
252 | return;
253 | }
254 |
255 | mState = State.Authenticate;
256 | });
257 | }
258 |
259 | private void OnDisconnect()
260 | {
261 | Post(() =>
262 | {
263 | if (mState == State.Invalid)
264 | {
265 | return;
266 | }
267 |
268 | bool disconnected = (mState == State.Online);
269 |
270 | mState = State.Ready;
271 | mLocalPlayerId = 0;
272 | mPlayers.Clear();
273 |
274 | if (disconnected)
275 | {
276 | if (onDisconnect != null)
277 | {
278 | try
279 | {
280 | onDisconnect();
281 | }
282 | catch (Exception e)
283 | {
284 | Debug.LogException(e);
285 | }
286 | }
287 | }
288 | else
289 | {
290 | OnFail();
291 | }
292 | });
293 | }
294 |
295 | private void OnReceive(byte[] message, int sender)
296 | {
297 | Post(() =>
298 | {
299 | if (mState == State.Invalid)
300 | {
301 | return;
302 | }
303 |
304 | if (sender == 0)
305 | {
306 | mReceiveBuffer.Clear();
307 | mReceiveBuffer.WriteBytes(message, 0, message.Length);
308 | mReceiveBuffer.Seek(0);
309 |
310 | byte msgType = mReceiveBuffer.ReadByte();
311 |
312 | switch (msgType)
313 | {
314 | case SYSMSG_REQUEST_AUTHENTICATION:
315 | OnReceive_RequestAuthentication();
316 | break;
317 |
318 | case SYSMSG_ACCEPT_AUTHENTICATION:
319 | OnReceive_AcceptAuthentication();
320 | break;
321 |
322 | case SYSMSG_PLAYER_JOIN:
323 | OnReceive_PlayerJoin();
324 | break;
325 |
326 | case SYSMSG_PLAYER_LEAVE:
327 | OnReceive_PlayerLeave();
328 | break;
329 |
330 |
331 | default:
332 | Debug.LogWarningFormat("Invalid message type: {0}", msgType);
333 | mImplementation.Disconnect();
334 | break;
335 | }
336 | }
337 | else
338 | {
339 | InvokeOnReceive(message, message.Length, sender);
340 | }
341 | });
342 | }
343 |
344 | private void OnReceive_RequestAuthentication()
345 | {
346 | if (mState != State.Authenticate)
347 | {
348 | Debug.LogWarningFormat("Invalid state: {0}", mState);
349 | return;
350 | }
351 |
352 | var bytes = new byte[32];
353 | Array.Copy(mAuthData, 0, bytes, 0, 16);
354 | mReceiveBuffer.ReadBytes(bytes, 16, 16);
355 |
356 | var hash = new SHA256Managed().ComputeHash(bytes);
357 |
358 | // SYSMSG_RESPOND_AUTHENTICATION
359 |
360 | mSendBuffer.Clear();
361 | mSendBuffer.Write(SYSMSG_RESPOND_AUTHENTICATION);
362 | mSendBuffer.WriteBytes(hash, 0, 32);
363 | mSendBuffer.WriteString(mLocalPlayerName);
364 |
365 | if (!mImplementation.Send(mSendBuffer.RawData, mSendBuffer.Size, 0))
366 | {
367 | Debug.LogWarning("Failed to send SYSMSG_RESPOND_AUTHENTICATION");
368 | mImplementation.Disconnect();
369 | }
370 | }
371 |
372 | private void OnReceive_AcceptAuthentication()
373 | {
374 | if (mState != State.Authenticate)
375 | {
376 | Debug.LogWarningFormat("Invalid state: {0}", mState);
377 | return;
378 | }
379 |
380 | mLocalPlayerId = mReceiveBuffer.ReadUInt16();
381 | int numPlayers = mReceiveBuffer.ReadByte();
382 |
383 | for (int i = 0; i < numPlayers; ++i)
384 | {
385 | int playerId = mReceiveBuffer.ReadUInt16();
386 | var playerName = mReceiveBuffer.ReadString();
387 |
388 | var player = new Player(playerId, playerName);
389 | mPlayers.Add(player);
390 | }
391 |
392 | var localPlayer = new Player(mLocalPlayerId, mLocalPlayerName);
393 | mPlayers.Add(localPlayer);
394 |
395 | mImplementation.Accept();
396 |
397 | mState = State.Online;
398 |
399 | if (onConnect != null)
400 | {
401 | try
402 | {
403 | onConnect();
404 | }
405 | catch (Exception e)
406 | {
407 | Debug.LogException(e);
408 | }
409 | }
410 | }
411 |
412 | private void OnReceive_PlayerJoin()
413 | {
414 | if (mState != State.Online)
415 | {
416 | Debug.LogWarningFormat("Invalid state: {0}", mState);
417 | return;
418 | }
419 |
420 | int playerId = mReceiveBuffer.ReadUInt16();
421 | var playerName = mReceiveBuffer.ReadString();
422 | var player = new Player(playerId, playerName);
423 | mPlayers.Add(player);
424 |
425 | InvokeOnPlayerJoin(player);
426 | }
427 |
428 | private void OnReceive_PlayerLeave()
429 | {
430 | if (mState != State.Online)
431 | {
432 | Debug.LogWarningFormat("Invalid state: {0}", mState);
433 | return;
434 | }
435 |
436 | int playerId = mReceiveBuffer.ReadUInt16();
437 |
438 | var player = mPlayers.Where(p => p.PlayerId == playerId).FirstOrDefault();
439 | if (player == null)
440 | {
441 | Debug.LogWarningFormat("Invalid playerId: {0}", playerId);
442 | return;
443 | }
444 |
445 | mPlayers.Remove(player);
446 |
447 | InvokeOnPlayerLeave(player);
448 | }
449 | }
450 | }
451 |
--------------------------------------------------------------------------------
/BleSockPlugin/Assets/Plugins/BleSock/HostPeer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Security.Cryptography;
5 | using System.Text;
6 | using System.Threading;
7 |
8 | using UnityEngine;
9 |
10 | namespace BleSock
11 | {
12 | public class HostPeer : PeerBase
13 | {
14 | // Properties
15 |
16 | public bool IsAdvertising
17 | {
18 | get
19 | {
20 | return mAdvertising;
21 | }
22 | }
23 |
24 | public int MaximumPlayers
25 | {
26 | get
27 | {
28 | return mMaximumPlayers;
29 | }
30 |
31 | set
32 | {
33 | mMaximumPlayers = Math.Max(value, 0);
34 | }
35 | }
36 |
37 | public override bool IsBluetoothEnabled
38 | {
39 | get
40 | {
41 | if (mImplementation != null)
42 | {
43 | return mImplementation.IsBluetoothEnabled;
44 | }
45 |
46 | return false;
47 | }
48 | }
49 |
50 | public override int LocalPlayerId
51 | {
52 | get
53 | {
54 | return Address.Host;
55 | }
56 | }
57 |
58 | // Methods
59 |
60 | public void Initialize(string protocolIdentifier, string playerName, SynchronizationContext synchronizationContext = null)
61 | {
62 | if (mImplementation != null)
63 | {
64 | throw new Exception("Already called initialize");
65 | }
66 |
67 | InitializeInternal(protocolIdentifier, playerName, synchronizationContext);
68 |
69 | for (int i = 1; i < 16; ++i)
70 | {
71 | mUnusedPlayerIds.Add(1 << i);
72 | }
73 |
74 | mImplementation = new Peripheral();
75 | mImplementation.onBluetoothRequire += OnBluetoothRequire;
76 | mImplementation.onReady += OnReady;
77 | mImplementation.onFail += OnFail;
78 | mImplementation.onConnect += OnConnect;
79 | mImplementation.onDisconnect += OnDisconnect;
80 | mImplementation.onReceiveDirect += OnReceiveDirect;
81 | mImplementation.onReceive += OnReceive;
82 |
83 | if (!mImplementation.Initialize(mServiceUUID, mUploadUUID, mDownloadUUID))
84 | {
85 | mImplementation.Dispose();
86 | mImplementation = null;
87 | throw new Exception("Failed to initialize");
88 | }
89 | }
90 |
91 | public void StartAdvertising(string deviceName)
92 | {
93 | if (!IsReady)
94 | {
95 | throw new Exception("Not ready");
96 | }
97 |
98 | if (string.IsNullOrEmpty(deviceName))
99 | {
100 | throw new Exception("Invalid deviceName");
101 | }
102 |
103 | if (Encoding.UTF8.GetByteCount(deviceName) > DEVICE_NAME_SIZE_MAX)
104 | {
105 | throw new Exception("deviceName too large");
106 | }
107 |
108 | if (mAdvertising)
109 | {
110 | throw new Exception("Already advertising started");
111 | }
112 |
113 | if (mImplementation.StartAdvertising(deviceName))
114 | {
115 | mAdvertising = true;
116 | }
117 | else
118 | {
119 | throw new Exception("Failed to start advertising");
120 | }
121 | }
122 |
123 | public void StopAdvertising()
124 | {
125 | if (!IsReady)
126 | {
127 | throw new Exception("Not ready");
128 | }
129 |
130 | if (mAdvertising)
131 | {
132 | mImplementation.StopAdvertising();
133 | mAdvertising = false;
134 | }
135 | }
136 |
137 | public override void Send(byte[] message, int messageSize, int receiver)
138 | {
139 | int address = PrepareSend(message, messageSize, receiver);
140 | if ((address & ~LocalPlayerId) != 0)
141 | {
142 | if (!mImplementation.Send(message, messageSize, address & ~LocalPlayerId))
143 | {
144 | throw new Exception("Failed to send user message");
145 | }
146 | }
147 |
148 | if ((address & LocalPlayerId) != 0)
149 | {
150 | InvokeOnReceive(message, messageSize, LocalPlayerId);
151 | }
152 | }
153 |
154 | public override void Cleanup()
155 | {
156 | if (mImplementation != null)
157 | {
158 | mImplementation.Dispose();
159 | mImplementation = null;
160 | }
161 |
162 | mAdvertising = false;
163 | mMaximumPlayers = 0;
164 |
165 | mCentralContexts.Clear();
166 | mUnusedPlayerIds.Clear();
167 |
168 | base.Cleanup();
169 | }
170 |
171 | // Internal
172 |
173 | private const int DEVICE_NAME_SIZE_MAX = 27;
174 |
175 | private Peripheral mImplementation;
176 | private bool mAdvertising;
177 | private int mMaximumPlayers;
178 |
179 | private class CentralContext
180 | {
181 | public int connectionId;
182 | public byte[] authHash;
183 | public int playerId;
184 | }
185 |
186 | private List mCentralContexts = new List();
187 | private List mUnusedPlayerIds = new List();
188 |
189 |
190 | private void OnBluetoothRequire()
191 | {
192 | Post(() =>
193 | {
194 | InvokeOnBluetoothRequire();
195 | });
196 | }
197 |
198 | private void OnReady()
199 | {
200 | Post(() =>
201 | {
202 | mReady = true;
203 |
204 | var player = new Player(Address.Host, mLocalPlayerName);
205 | mPlayers.Add(player);
206 |
207 | InvokeOnReady();
208 | });
209 | }
210 |
211 | private void OnFail()
212 | {
213 | Post(() =>
214 | {
215 | mAdvertising = false;
216 |
217 | InvokeOnFail();
218 | });
219 | }
220 |
221 | private void OnConnect(int connectionId)
222 | {
223 | Post(() =>
224 | {
225 | if (!IsReady)
226 | {
227 | return;
228 | }
229 |
230 | if ((mMaximumPlayers > 0) && (mPlayers.Count >= mMaximumPlayers))
231 | {
232 | mImplementation.Invalidate(connectionId);
233 | }
234 |
235 | var authData = new byte[16];
236 | RandomNumberGenerator.Create().GetNonZeroBytes(authData);
237 |
238 | // SYSMSG_REQUEST_AUTHENTICATION
239 |
240 | mSendBuffer.Clear();
241 | mSendBuffer.Write(SYSMSG_REQUEST_AUTHENTICATION);
242 | mSendBuffer.WriteBytes(authData, 0, authData.Length);
243 |
244 | if (!mImplementation.SendDirect(mSendBuffer.RawData, mSendBuffer.Size, connectionId))
245 | {
246 | Debug.LogWarning("Failed to send SYSMSG_REQUEST_AUTHENTICATION");
247 | mImplementation.Invalidate(connectionId);
248 | return;
249 | }
250 |
251 | var bytes = new byte[32];
252 | Array.Copy(mAuthData, 0, bytes, 0, 16);
253 | Array.Copy(authData, 0, bytes, 16, 16);
254 |
255 | var context = new CentralContext();
256 | context.connectionId = connectionId;
257 | context.authHash = new SHA256Managed().ComputeHash(bytes);
258 | context.playerId = 0;
259 |
260 | mCentralContexts.Add(context);
261 | });
262 | }
263 |
264 | private void OnDisconnect(int connectionId)
265 | {
266 | Post(() =>
267 | {
268 | if (!IsReady)
269 | {
270 | return;
271 | }
272 |
273 | var context = mCentralContexts.Where(ctx => ctx.connectionId == connectionId).FirstOrDefault();
274 | if (context == null)
275 | {
276 | Debug.LogWarningFormat("Invalid connectionId: {0}", connectionId);
277 | return;
278 | }
279 |
280 | mCentralContexts.Remove(context);
281 |
282 | if (context.playerId != 0)
283 | {
284 | mUnusedPlayerIds.Add(context.playerId);
285 | }
286 |
287 | var player = mPlayers.Where(p => p.PlayerId == context.playerId).FirstOrDefault();
288 | if (player != null)
289 | {
290 | // SYSMSG_PLAYER_LEAVE
291 |
292 | mSendBuffer.Clear();
293 | mSendBuffer.Write(SYSMSG_PLAYER_LEAVE);
294 | mSendBuffer.Write((UInt16)context.playerId);
295 |
296 | foreach (var ctx in mCentralContexts)
297 | {
298 | if (ctx.playerId != 0)
299 | {
300 | if (!mImplementation.SendDirect(mSendBuffer.RawData, mSendBuffer.Size, ctx.connectionId))
301 | {
302 | Debug.LogWarning("Failed to send SYSMSG_PLAYER_LEAVE");
303 | }
304 | }
305 | }
306 |
307 | mPlayers.Remove(player);
308 |
309 | InvokeOnPlayerLeave(player);
310 | }
311 | });
312 | }
313 |
314 | private void OnReceiveDirect(byte[] message, int connectionId)
315 | {
316 | Post(() =>
317 | {
318 | mReceiveBuffer.Clear();
319 | mReceiveBuffer.WriteBytes(message, 0, message.Length);
320 | mReceiveBuffer.Seek(0);
321 |
322 | byte msgType = mReceiveBuffer.ReadByte();
323 | switch (msgType)
324 | {
325 | case SYSMSG_RESPOND_AUTHENTICATION:
326 | OnReceive_RespondAuthentication(connectionId);
327 | break;
328 |
329 |
330 | default:
331 | Debug.LogWarningFormat("Invalid message type: {0}", msgType);
332 | mImplementation.Invalidate(connectionId);
333 | break;
334 | }
335 | });
336 | }
337 |
338 | private void OnReceive_RespondAuthentication(int connectionId)
339 | {
340 | var context = mCentralContexts.Where(ctx => ctx.connectionId == connectionId).FirstOrDefault();
341 | if (context == null)
342 | {
343 | Debug.LogWarningFormat("Invalid connectionId: {0}", connectionId);
344 | return;
345 | }
346 |
347 | var receivedHash = new byte[32];
348 | mReceiveBuffer.ReadBytes(receivedHash, 0, receivedHash.Length);
349 |
350 | var playerName = mReceiveBuffer.ReadString();
351 |
352 | if (context.playerId != 0)
353 | {
354 | Debug.LogWarning("Already authenticated");
355 | return;
356 | }
357 |
358 | var hash = context.authHash;
359 | context.authHash = null;
360 |
361 | if (!receivedHash.SequenceEqual(hash))
362 | {
363 | Debug.LogWarning("Authentication error");
364 | mImplementation.Invalidate(connectionId);
365 | return;
366 | }
367 |
368 | if (mUnusedPlayerIds.Count == 0)
369 | {
370 | Debug.LogWarning("Too many players");
371 | mImplementation.Invalidate(connectionId);
372 | return;
373 | }
374 |
375 | context.playerId = mUnusedPlayerIds[0];
376 | mUnusedPlayerIds.RemoveAt(0);
377 |
378 | mImplementation.Accept(connectionId, context.playerId);
379 |
380 | // SYSMSG_ACCEPT_AUTHENTICATION
381 |
382 | mSendBuffer.Clear();
383 | mSendBuffer.Write(SYSMSG_ACCEPT_AUTHENTICATION);
384 | mSendBuffer.Write((UInt16)context.playerId);
385 | mSendBuffer.Write((byte)mPlayers.Count);
386 |
387 | foreach (var ply in mPlayers)
388 | {
389 | mSendBuffer.Write((UInt16)ply.PlayerId);
390 | mSendBuffer.WriteString(ply.PlayerName);
391 | }
392 |
393 | if (!mImplementation.SendDirect(mSendBuffer.RawData, mSendBuffer.Size, connectionId))
394 | {
395 | Debug.LogWarning("Failed to send SYSMSG_ACCEPT_AUTHENTICATION");
396 | mImplementation.Invalidate(connectionId);
397 | return;
398 | }
399 |
400 | // SYSMSG_PLAYER_JOIN
401 |
402 | mSendBuffer.Clear();
403 | mSendBuffer.Write(SYSMSG_PLAYER_JOIN);
404 | mSendBuffer.Write((UInt16)context.playerId);
405 | mSendBuffer.WriteString(playerName);
406 |
407 | foreach (var ctx in mCentralContexts)
408 | {
409 | if ((ctx.playerId != 0) && (ctx != context))
410 | {
411 | if (!mImplementation.SendDirect(mSendBuffer.RawData, mSendBuffer.Size, ctx.connectionId))
412 | {
413 | Debug.LogWarning("Failed to send SYSMSG_PLAYER_JOIN");
414 | }
415 | }
416 | }
417 |
418 | var player = new Player(context.playerId, playerName);
419 | mPlayers.Add(player);
420 |
421 | InvokeOnPlayerJoin(player);
422 | }
423 |
424 | private void OnReceive(byte[] message, int playerId)
425 | {
426 | Post(() =>
427 | {
428 | if (!IsReady)
429 | {
430 | return;
431 | }
432 |
433 | InvokeOnReceive(message, message.Length, playerId);
434 | });
435 | }
436 | }
437 | }
438 |
--------------------------------------------------------------------------------
/BleSockPlugin/ProjectSettings/ProjectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!129 &1
4 | PlayerSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 15
7 | productGUID: 39986f1fadcbdd94a81020fffe40194e
8 | AndroidProfiler: 0
9 | AndroidFilterTouchesWhenObscured: 0
10 | AndroidEnableSustainedPerformanceMode: 0
11 | defaultScreenOrientation: 4
12 | targetDevice: 2
13 | useOnDemandResources: 0
14 | accelerometerFrequency: 60
15 | companyName: DefaultCompany
16 | productName: BleSockPlugin
17 | defaultCursor: {fileID: 0}
18 | cursorHotspot: {x: 0, y: 0}
19 | m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
20 | m_ShowUnitySplashScreen: 0
21 | m_ShowUnitySplashLogo: 1
22 | m_SplashScreenOverlayOpacity: 1
23 | m_SplashScreenAnimation: 1
24 | m_SplashScreenLogoStyle: 1
25 | m_SplashScreenDrawMode: 0
26 | m_SplashScreenBackgroundAnimationZoom: 1
27 | m_SplashScreenLogoAnimationZoom: 1
28 | m_SplashScreenBackgroundLandscapeAspect: 1
29 | m_SplashScreenBackgroundPortraitAspect: 1
30 | m_SplashScreenBackgroundLandscapeUvs:
31 | serializedVersion: 2
32 | x: 0
33 | y: 0
34 | width: 1
35 | height: 1
36 | m_SplashScreenBackgroundPortraitUvs:
37 | serializedVersion: 2
38 | x: 0
39 | y: 0
40 | width: 1
41 | height: 1
42 | m_SplashScreenLogos: []
43 | m_VirtualRealitySplashScreen: {fileID: 0}
44 | m_HolographicTrackingLossScreen: {fileID: 0}
45 | defaultScreenWidth: 1024
46 | defaultScreenHeight: 768
47 | defaultScreenWidthWeb: 960
48 | defaultScreenHeightWeb: 600
49 | m_StereoRenderingPath: 0
50 | m_ActiveColorSpace: 0
51 | m_MTRendering: 1
52 | m_StackTraceTypes: 010000000100000001000000010000000100000001000000
53 | iosShowActivityIndicatorOnLoading: -1
54 | androidShowActivityIndicatorOnLoading: -1
55 | iosAppInBackgroundBehavior: 0
56 | displayResolutionDialog: 1
57 | iosAllowHTTPDownload: 1
58 | allowedAutorotateToPortrait: 1
59 | allowedAutorotateToPortraitUpsideDown: 1
60 | allowedAutorotateToLandscapeRight: 0
61 | allowedAutorotateToLandscapeLeft: 0
62 | useOSAutorotation: 1
63 | use32BitDisplayBuffer: 1
64 | preserveFramebufferAlpha: 0
65 | disableDepthAndStencilBuffers: 0
66 | androidBlitType: 0
67 | defaultIsNativeResolution: 1
68 | macRetinaSupport: 1
69 | runInBackground: 1
70 | captureSingleScreen: 0
71 | muteOtherAudioSources: 0
72 | Prepare IOS For Recording: 0
73 | Force IOS Speakers When Recording: 0
74 | deferSystemGesturesMode: 0
75 | hideHomeButton: 0
76 | submitAnalytics: 1
77 | usePlayerLog: 1
78 | bakeCollisionMeshes: 0
79 | forceSingleInstance: 0
80 | resizableWindow: 0
81 | useMacAppStoreValidation: 0
82 | macAppStoreCategory: public.app-category.games
83 | gpuSkinning: 1
84 | graphicsJobs: 0
85 | xboxPIXTextureCapture: 0
86 | xboxEnableAvatar: 0
87 | xboxEnableKinect: 0
88 | xboxEnableKinectAutoTracking: 0
89 | xboxEnableFitness: 0
90 | visibleInBackground: 1
91 | allowFullscreenSwitch: 1
92 | graphicsJobMode: 0
93 | fullscreenMode: 1
94 | xboxSpeechDB: 0
95 | xboxEnableHeadOrientation: 0
96 | xboxEnableGuest: 0
97 | xboxEnablePIXSampling: 0
98 | metalFramebufferOnly: 0
99 | n3dsDisableStereoscopicView: 0
100 | n3dsEnableSharedListOpt: 1
101 | n3dsEnableVSync: 0
102 | xboxOneResolution: 0
103 | xboxOneSResolution: 0
104 | xboxOneXResolution: 3
105 | xboxOneMonoLoggingLevel: 0
106 | xboxOneLoggingLevel: 1
107 | xboxOneDisableEsram: 0
108 | xboxOnePresentImmediateThreshold: 0
109 | switchQueueCommandMemory: 0
110 | videoMemoryForVertexBuffers: 0
111 | psp2PowerMode: 0
112 | psp2AcquireBGM: 1
113 | vulkanEnableSetSRGBWrite: 0
114 | vulkanUseSWCommandBuffers: 0
115 | m_SupportedAspectRatios:
116 | 4:3: 1
117 | 5:4: 1
118 | 16:10: 1
119 | 16:9: 1
120 | Others: 1
121 | bundleVersion: 0.1
122 | preloadedAssets: []
123 | metroInputSource: 0
124 | wsaTransparentSwapchain: 0
125 | m_HolographicPauseOnTrackingLoss: 1
126 | xboxOneDisableKinectGpuReservation: 0
127 | xboxOneEnable7thCore: 0
128 | vrSettings:
129 | cardboard:
130 | depthFormat: 0
131 | enableTransitionView: 0
132 | daydream:
133 | depthFormat: 0
134 | useSustainedPerformanceMode: 0
135 | enableVideoLayer: 0
136 | useProtectedVideoMemory: 0
137 | minimumSupportedHeadTracking: 0
138 | maximumSupportedHeadTracking: 1
139 | hololens:
140 | depthFormat: 1
141 | depthBufferSharingEnabled: 0
142 | oculus:
143 | sharedDepthBuffer: 0
144 | dashSupport: 0
145 | enable360StereoCapture: 0
146 | protectGraphicsMemory: 0
147 | useHDRDisplay: 0
148 | m_ColorGamuts: 00000000
149 | targetPixelDensity: 30
150 | resolutionScalingMode: 0
151 | androidSupportedAspectRatio: 1
152 | androidMaxAspectRatio: 2.1
153 | applicationIdentifier:
154 | Android: blesock.demoapp.xflag
155 | iOS: blesock.demoapp.xflag
156 | buildNumber: {}
157 | AndroidBundleVersionCode: 1
158 | AndroidMinSdkVersion: 21
159 | AndroidTargetSdkVersion: 26
160 | AndroidPreferredInstallLocation: 1
161 | aotOptions:
162 | stripEngineCode: 1
163 | iPhoneStrippingLevel: 0
164 | iPhoneScriptCallOptimization: 0
165 | ForceInternetPermission: 0
166 | ForceSDCardPermission: 0
167 | CreateWallpaper: 0
168 | APKExpansionFiles: 0
169 | keepLoadedShadersAlive: 0
170 | StripUnusedMeshComponents: 1
171 | VertexChannelCompressionMask: 4054
172 | iPhoneSdkVersion: 988
173 | iOSTargetOSVersionString: 9.0
174 | tvOSSdkVersion: 0
175 | tvOSRequireExtendedGameController: 0
176 | tvOSTargetOSVersionString: 9.0
177 | uIPrerenderedIcon: 0
178 | uIRequiresPersistentWiFi: 0
179 | uIRequiresFullScreen: 1
180 | uIStatusBarHidden: 1
181 | uIExitOnSuspend: 0
182 | uIStatusBarStyle: 0
183 | iPhoneSplashScreen: {fileID: 0}
184 | iPhoneHighResSplashScreen: {fileID: 0}
185 | iPhoneTallHighResSplashScreen: {fileID: 0}
186 | iPhone47inSplashScreen: {fileID: 0}
187 | iPhone55inPortraitSplashScreen: {fileID: 0}
188 | iPhone55inLandscapeSplashScreen: {fileID: 0}
189 | iPhone58inPortraitSplashScreen: {fileID: 0}
190 | iPhone58inLandscapeSplashScreen: {fileID: 0}
191 | iPadPortraitSplashScreen: {fileID: 0}
192 | iPadHighResPortraitSplashScreen: {fileID: 0}
193 | iPadLandscapeSplashScreen: {fileID: 0}
194 | iPadHighResLandscapeSplashScreen: {fileID: 0}
195 | appleTVSplashScreen: {fileID: 0}
196 | appleTVSplashScreen2x: {fileID: 0}
197 | tvOSSmallIconLayers: []
198 | tvOSSmallIconLayers2x: []
199 | tvOSLargeIconLayers: []
200 | tvOSLargeIconLayers2x: []
201 | tvOSTopShelfImageLayers: []
202 | tvOSTopShelfImageLayers2x: []
203 | tvOSTopShelfImageWideLayers: []
204 | tvOSTopShelfImageWideLayers2x: []
205 | iOSLaunchScreenType: 0
206 | iOSLaunchScreenPortrait: {fileID: 0}
207 | iOSLaunchScreenLandscape: {fileID: 0}
208 | iOSLaunchScreenBackgroundColor:
209 | serializedVersion: 2
210 | rgba: 0
211 | iOSLaunchScreenFillPct: 100
212 | iOSLaunchScreenSize: 100
213 | iOSLaunchScreenCustomXibPath:
214 | iOSLaunchScreeniPadType: 0
215 | iOSLaunchScreeniPadImage: {fileID: 0}
216 | iOSLaunchScreeniPadBackgroundColor:
217 | serializedVersion: 2
218 | rgba: 0
219 | iOSLaunchScreeniPadFillPct: 100
220 | iOSLaunchScreeniPadSize: 100
221 | iOSLaunchScreeniPadCustomXibPath:
222 | iOSUseLaunchScreenStoryboard: 0
223 | iOSLaunchScreenCustomStoryboardPath:
224 | iOSDeviceRequirements: []
225 | iOSURLSchemes: []
226 | iOSBackgroundModes: 0
227 | iOSMetalForceHardShadows: 0
228 | metalEditorSupport: 1
229 | metalAPIValidation: 1
230 | iOSRenderExtraFrameOnPause: 0
231 | appleDeveloperTeamID:
232 | iOSManualSigningProvisioningProfileID:
233 | tvOSManualSigningProvisioningProfileID:
234 | iOSManualSigningProvisioningProfileType: 0
235 | tvOSManualSigningProvisioningProfileType: 0
236 | appleEnableAutomaticSigning: 1
237 | iOSRequireARKit: 0
238 | appleEnableProMotion: 0
239 | vulkanEditorSupport: 0
240 | clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea
241 | templatePackageId: com.unity.3d@1.0.2
242 | templateDefaultScene: Assets/Scenes/SampleScene.unity
243 | AndroidTargetArchitectures: 5
244 | AndroidSplashScreenScale: 0
245 | androidSplashScreen: {fileID: 0}
246 | AndroidKeystoreName:
247 | AndroidKeyaliasName:
248 | AndroidBuildApkPerCpuArchitecture: 0
249 | AndroidTVCompatibility: 0
250 | AndroidIsGame: 1
251 | AndroidEnableTango: 0
252 | androidEnableBanner: 1
253 | androidUseLowAccuracyLocation: 1
254 | m_AndroidBanners:
255 | - width: 320
256 | height: 180
257 | banner: {fileID: 0}
258 | androidGamepadSupportLevel: 0
259 | resolutionDialogBanner: {fileID: 0}
260 | m_BuildTargetIcons: []
261 | m_BuildTargetPlatformIcons:
262 | - m_BuildTarget: Android
263 | m_Icons:
264 | - m_Textures: []
265 | m_Width: 432
266 | m_Height: 432
267 | m_Kind: 2
268 | m_SubKind:
269 | - m_Textures: []
270 | m_Width: 324
271 | m_Height: 324
272 | m_Kind: 2
273 | m_SubKind:
274 | - m_Textures: []
275 | m_Width: 216
276 | m_Height: 216
277 | m_Kind: 2
278 | m_SubKind:
279 | - m_Textures: []
280 | m_Width: 162
281 | m_Height: 162
282 | m_Kind: 2
283 | m_SubKind:
284 | - m_Textures: []
285 | m_Width: 108
286 | m_Height: 108
287 | m_Kind: 2
288 | m_SubKind:
289 | - m_Textures: []
290 | m_Width: 81
291 | m_Height: 81
292 | m_Kind: 2
293 | m_SubKind:
294 | - m_Textures: []
295 | m_Width: 192
296 | m_Height: 192
297 | m_Kind: 1
298 | m_SubKind:
299 | - m_Textures: []
300 | m_Width: 144
301 | m_Height: 144
302 | m_Kind: 1
303 | m_SubKind:
304 | - m_Textures: []
305 | m_Width: 96
306 | m_Height: 96
307 | m_Kind: 1
308 | m_SubKind:
309 | - m_Textures: []
310 | m_Width: 72
311 | m_Height: 72
312 | m_Kind: 1
313 | m_SubKind:
314 | - m_Textures: []
315 | m_Width: 48
316 | m_Height: 48
317 | m_Kind: 1
318 | m_SubKind:
319 | - m_Textures: []
320 | m_Width: 36
321 | m_Height: 36
322 | m_Kind: 1
323 | m_SubKind:
324 | - m_Textures: []
325 | m_Width: 192
326 | m_Height: 192
327 | m_Kind: 0
328 | m_SubKind:
329 | - m_Textures: []
330 | m_Width: 144
331 | m_Height: 144
332 | m_Kind: 0
333 | m_SubKind:
334 | - m_Textures: []
335 | m_Width: 96
336 | m_Height: 96
337 | m_Kind: 0
338 | m_SubKind:
339 | - m_Textures: []
340 | m_Width: 72
341 | m_Height: 72
342 | m_Kind: 0
343 | m_SubKind:
344 | - m_Textures: []
345 | m_Width: 48
346 | m_Height: 48
347 | m_Kind: 0
348 | m_SubKind:
349 | - m_Textures: []
350 | m_Width: 36
351 | m_Height: 36
352 | m_Kind: 0
353 | m_SubKind:
354 | m_BuildTargetBatching:
355 | - m_BuildTarget: Standalone
356 | m_StaticBatching: 1
357 | m_DynamicBatching: 0
358 | - m_BuildTarget: tvOS
359 | m_StaticBatching: 1
360 | m_DynamicBatching: 0
361 | - m_BuildTarget: Android
362 | m_StaticBatching: 1
363 | m_DynamicBatching: 0
364 | - m_BuildTarget: iPhone
365 | m_StaticBatching: 1
366 | m_DynamicBatching: 0
367 | - m_BuildTarget: WebGL
368 | m_StaticBatching: 0
369 | m_DynamicBatching: 0
370 | m_BuildTargetGraphicsAPIs:
371 | - m_BuildTarget: AndroidPlayer
372 | m_APIs: 0b00000015000000
373 | m_Automatic: 1
374 | - m_BuildTarget: iOSSupport
375 | m_APIs: 10000000
376 | m_Automatic: 1
377 | - m_BuildTarget: AppleTVSupport
378 | m_APIs: 10000000
379 | m_Automatic: 0
380 | - m_BuildTarget: WebGLSupport
381 | m_APIs: 0b000000
382 | m_Automatic: 1
383 | m_BuildTargetVRSettings:
384 | - m_BuildTarget: Standalone
385 | m_Enabled: 0
386 | m_Devices:
387 | - Oculus
388 | - OpenVR
389 | m_BuildTargetEnableVuforiaSettings: []
390 | openGLRequireES31: 0
391 | openGLRequireES31AEP: 0
392 | m_TemplateCustomTags: {}
393 | mobileMTRendering:
394 | Android: 1
395 | iPhone: 1
396 | tvOS: 1
397 | m_BuildTargetGroupLightmapEncodingQuality: []
398 | m_BuildTargetGroupLightmapSettings: []
399 | playModeTestRunnerEnabled: 0
400 | runPlayModeTestAsEditModeTest: 0
401 | actionOnDotNetUnhandledException: 1
402 | enableInternalProfiler: 0
403 | logObjCUncaughtExceptions: 1
404 | enableCrashReportAPI: 0
405 | cameraUsageDescription:
406 | locationUsageDescription: "\u4F4D\u7F6E\u60C5\u5831\u306E\u4F7F\u7528\u7406\u7531"
407 | microphoneUsageDescription:
408 | switchNetLibKey:
409 | switchSocketMemoryPoolSize: 6144
410 | switchSocketAllocatorPoolSize: 128
411 | switchSocketConcurrencyLimit: 14
412 | switchScreenResolutionBehavior: 2
413 | switchUseCPUProfiler: 0
414 | switchApplicationID: 0x01004b9000490000
415 | switchNSODependencies:
416 | switchTitleNames_0:
417 | switchTitleNames_1:
418 | switchTitleNames_2:
419 | switchTitleNames_3:
420 | switchTitleNames_4:
421 | switchTitleNames_5:
422 | switchTitleNames_6:
423 | switchTitleNames_7:
424 | switchTitleNames_8:
425 | switchTitleNames_9:
426 | switchTitleNames_10:
427 | switchTitleNames_11:
428 | switchTitleNames_12:
429 | switchTitleNames_13:
430 | switchTitleNames_14:
431 | switchPublisherNames_0:
432 | switchPublisherNames_1:
433 | switchPublisherNames_2:
434 | switchPublisherNames_3:
435 | switchPublisherNames_4:
436 | switchPublisherNames_5:
437 | switchPublisherNames_6:
438 | switchPublisherNames_7:
439 | switchPublisherNames_8:
440 | switchPublisherNames_9:
441 | switchPublisherNames_10:
442 | switchPublisherNames_11:
443 | switchPublisherNames_12:
444 | switchPublisherNames_13:
445 | switchPublisherNames_14:
446 | switchIcons_0: {fileID: 0}
447 | switchIcons_1: {fileID: 0}
448 | switchIcons_2: {fileID: 0}
449 | switchIcons_3: {fileID: 0}
450 | switchIcons_4: {fileID: 0}
451 | switchIcons_5: {fileID: 0}
452 | switchIcons_6: {fileID: 0}
453 | switchIcons_7: {fileID: 0}
454 | switchIcons_8: {fileID: 0}
455 | switchIcons_9: {fileID: 0}
456 | switchIcons_10: {fileID: 0}
457 | switchIcons_11: {fileID: 0}
458 | switchIcons_12: {fileID: 0}
459 | switchIcons_13: {fileID: 0}
460 | switchIcons_14: {fileID: 0}
461 | switchSmallIcons_0: {fileID: 0}
462 | switchSmallIcons_1: {fileID: 0}
463 | switchSmallIcons_2: {fileID: 0}
464 | switchSmallIcons_3: {fileID: 0}
465 | switchSmallIcons_4: {fileID: 0}
466 | switchSmallIcons_5: {fileID: 0}
467 | switchSmallIcons_6: {fileID: 0}
468 | switchSmallIcons_7: {fileID: 0}
469 | switchSmallIcons_8: {fileID: 0}
470 | switchSmallIcons_9: {fileID: 0}
471 | switchSmallIcons_10: {fileID: 0}
472 | switchSmallIcons_11: {fileID: 0}
473 | switchSmallIcons_12: {fileID: 0}
474 | switchSmallIcons_13: {fileID: 0}
475 | switchSmallIcons_14: {fileID: 0}
476 | switchManualHTML:
477 | switchAccessibleURLs:
478 | switchLegalInformation:
479 | switchMainThreadStackSize: 1048576
480 | switchPresenceGroupId:
481 | switchLogoHandling: 0
482 | switchReleaseVersion: 0
483 | switchDisplayVersion: 1.0.0
484 | switchStartupUserAccount: 0
485 | switchTouchScreenUsage: 0
486 | switchSupportedLanguagesMask: 0
487 | switchLogoType: 0
488 | switchApplicationErrorCodeCategory:
489 | switchUserAccountSaveDataSize: 0
490 | switchUserAccountSaveDataJournalSize: 0
491 | switchApplicationAttribute: 0
492 | switchCardSpecSize: -1
493 | switchCardSpecClock: -1
494 | switchRatingsMask: 0
495 | switchRatingsInt_0: 0
496 | switchRatingsInt_1: 0
497 | switchRatingsInt_2: 0
498 | switchRatingsInt_3: 0
499 | switchRatingsInt_4: 0
500 | switchRatingsInt_5: 0
501 | switchRatingsInt_6: 0
502 | switchRatingsInt_7: 0
503 | switchRatingsInt_8: 0
504 | switchRatingsInt_9: 0
505 | switchRatingsInt_10: 0
506 | switchRatingsInt_11: 0
507 | switchLocalCommunicationIds_0:
508 | switchLocalCommunicationIds_1:
509 | switchLocalCommunicationIds_2:
510 | switchLocalCommunicationIds_3:
511 | switchLocalCommunicationIds_4:
512 | switchLocalCommunicationIds_5:
513 | switchLocalCommunicationIds_6:
514 | switchLocalCommunicationIds_7:
515 | switchParentalControl: 0
516 | switchAllowsScreenshot: 1
517 | switchAllowsVideoCapturing: 1
518 | switchAllowsRuntimeAddOnContentInstall: 0
519 | switchDataLossConfirmation: 0
520 | switchSupportedNpadStyles: 3
521 | switchNativeFsCacheSize: 32
522 | switchIsHoldTypeHorizontal: 0
523 | switchSupportedNpadCount: 8
524 | switchSocketConfigEnabled: 0
525 | switchTcpInitialSendBufferSize: 32
526 | switchTcpInitialReceiveBufferSize: 64
527 | switchTcpAutoSendBufferSizeMax: 256
528 | switchTcpAutoReceiveBufferSizeMax: 256
529 | switchUdpSendBufferSize: 9
530 | switchUdpReceiveBufferSize: 42
531 | switchSocketBufferEfficiency: 4
532 | switchSocketInitializeEnabled: 1
533 | switchNetworkInterfaceManagerInitializeEnabled: 1
534 | switchPlayerConnectionEnabled: 1
535 | ps4NPAgeRating: 12
536 | ps4NPTitleSecret:
537 | ps4NPTrophyPackPath:
538 | ps4ParentalLevel: 11
539 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000
540 | ps4Category: 0
541 | ps4MasterVersion: 01.00
542 | ps4AppVersion: 01.00
543 | ps4AppType: 0
544 | ps4ParamSfxPath:
545 | ps4VideoOutPixelFormat: 0
546 | ps4VideoOutInitialWidth: 1920
547 | ps4VideoOutBaseModeInitialWidth: 1920
548 | ps4VideoOutReprojectionRate: 60
549 | ps4PronunciationXMLPath:
550 | ps4PronunciationSIGPath:
551 | ps4BackgroundImagePath:
552 | ps4StartupImagePath:
553 | ps4StartupImagesFolder:
554 | ps4IconImagesFolder:
555 | ps4SaveDataImagePath:
556 | ps4SdkOverride:
557 | ps4BGMPath:
558 | ps4ShareFilePath:
559 | ps4ShareOverlayImagePath:
560 | ps4PrivacyGuardImagePath:
561 | ps4NPtitleDatPath:
562 | ps4RemotePlayKeyAssignment: -1
563 | ps4RemotePlayKeyMappingDir:
564 | ps4PlayTogetherPlayerCount: 0
565 | ps4EnterButtonAssignment: 1
566 | ps4ApplicationParam1: 0
567 | ps4ApplicationParam2: 0
568 | ps4ApplicationParam3: 0
569 | ps4ApplicationParam4: 0
570 | ps4DownloadDataSize: 0
571 | ps4GarlicHeapSize: 2048
572 | ps4ProGarlicHeapSize: 2560
573 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ
574 | ps4pnSessions: 1
575 | ps4pnPresence: 1
576 | ps4pnFriends: 1
577 | ps4pnGameCustomData: 1
578 | playerPrefsSupport: 0
579 | enableApplicationExit: 0
580 | restrictedAudioUsageRights: 0
581 | ps4UseResolutionFallback: 0
582 | ps4ReprojectionSupport: 0
583 | ps4UseAudio3dBackend: 0
584 | ps4SocialScreenEnabled: 0
585 | ps4ScriptOptimizationLevel: 0
586 | ps4Audio3dVirtualSpeakerCount: 14
587 | ps4attribCpuUsage: 0
588 | ps4PatchPkgPath:
589 | ps4PatchLatestPkgPath:
590 | ps4PatchChangeinfoPath:
591 | ps4PatchDayOne: 0
592 | ps4attribUserManagement: 0
593 | ps4attribMoveSupport: 0
594 | ps4attrib3DSupport: 0
595 | ps4attribShareSupport: 0
596 | ps4attribExclusiveVR: 0
597 | ps4disableAutoHideSplash: 0
598 | ps4videoRecordingFeaturesUsed: 0
599 | ps4contentSearchFeaturesUsed: 0
600 | ps4attribEyeToEyeDistanceSettingVR: 0
601 | ps4IncludedModules: []
602 | monoEnv:
603 | psp2Splashimage: {fileID: 0}
604 | psp2NPTrophyPackPath:
605 | psp2NPSupportGBMorGJP: 0
606 | psp2NPAgeRating: 12
607 | psp2NPTitleDatPath:
608 | psp2NPCommsID:
609 | psp2NPCommunicationsID:
610 | psp2NPCommsPassphrase:
611 | psp2NPCommsSig:
612 | psp2ParamSfxPath:
613 | psp2ManualPath:
614 | psp2LiveAreaGatePath:
615 | psp2LiveAreaBackroundPath:
616 | psp2LiveAreaPath:
617 | psp2LiveAreaTrialPath:
618 | psp2PatchChangeInfoPath:
619 | psp2PatchOriginalPackage:
620 | psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui
621 | psp2KeystoneFile:
622 | psp2MemoryExpansionMode: 0
623 | psp2DRMType: 0
624 | psp2StorageType: 0
625 | psp2MediaCapacity: 0
626 | psp2DLCConfigPath:
627 | psp2ThumbnailPath:
628 | psp2BackgroundPath:
629 | psp2SoundPath:
630 | psp2TrophyCommId:
631 | psp2TrophyPackagePath:
632 | psp2PackagedResourcesPath:
633 | psp2SaveDataQuota: 10240
634 | psp2ParentalLevel: 1
635 | psp2ShortTitle: Not Set
636 | psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF
637 | psp2Category: 0
638 | psp2MasterVersion: 01.00
639 | psp2AppVersion: 01.00
640 | psp2TVBootMode: 0
641 | psp2EnterButtonAssignment: 2
642 | psp2TVDisableEmu: 0
643 | psp2AllowTwitterDialog: 1
644 | psp2Upgradable: 0
645 | psp2HealthWarning: 0
646 | psp2UseLibLocation: 0
647 | psp2InfoBarOnStartup: 0
648 | psp2InfoBarColor: 0
649 | psp2ScriptOptimizationLevel: 0
650 | splashScreenBackgroundSourceLandscape: {fileID: 0}
651 | splashScreenBackgroundSourcePortrait: {fileID: 0}
652 | spritePackerPolicy:
653 | webGLMemorySize: 256
654 | webGLExceptionSupport: 1
655 | webGLNameFilesAsHashes: 0
656 | webGLDataCaching: 1
657 | webGLDebugSymbols: 0
658 | webGLEmscriptenArgs:
659 | webGLModulesDirectory:
660 | webGLTemplate: APPLICATION:Default
661 | webGLAnalyzeBuildSize: 0
662 | webGLUseEmbeddedResources: 0
663 | webGLCompressionFormat: 1
664 | webGLLinkerTarget: 1
665 | scriptingDefineSymbols: {}
666 | platformArchitecture: {}
667 | scriptingBackend: {}
668 | il2cppCompilerConfiguration: {}
669 | incrementalIl2cppBuild: {}
670 | allowUnsafeCode: 0
671 | additionalIl2CppArgs:
672 | scriptingRuntimeVersion: 1
673 | apiCompatibilityLevelPerPlatform: {}
674 | m_RenderingPath: 1
675 | m_MobileRenderingPath: 1
676 | metroPackageName: Template_3D
677 | metroPackageVersion:
678 | metroCertificatePath:
679 | metroCertificatePassword:
680 | metroCertificateSubject:
681 | metroCertificateIssuer:
682 | metroCertificateNotAfter: 0000000000000000
683 | metroApplicationDescription: Template_3D
684 | wsaImages: {}
685 | metroTileShortName:
686 | metroTileShowName: 0
687 | metroMediumTileShowName: 0
688 | metroLargeTileShowName: 0
689 | metroWideTileShowName: 0
690 | metroDefaultTileSize: 1
691 | metroTileForegroundText: 2
692 | metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0}
693 | metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628,
694 | a: 1}
695 | metroSplashScreenUseBackgroundColor: 0
696 | platformCapabilities: {}
697 | metroFTAName:
698 | metroFTAFileTypes: []
699 | metroProtocolName:
700 | metroCompilationOverrides: 1
701 | n3dsUseExtSaveData: 0
702 | n3dsCompressStaticMem: 1
703 | n3dsExtSaveDataNumber: 0x12345
704 | n3dsStackSize: 131072
705 | n3dsTargetPlatform: 2
706 | n3dsRegion: 7
707 | n3dsMediaSize: 0
708 | n3dsLogoStyle: 3
709 | n3dsTitle: GameName
710 | n3dsProductCode:
711 | n3dsApplicationId: 0xFF3FF
712 | XboxOneProductId:
713 | XboxOneUpdateKey:
714 | XboxOneSandboxId:
715 | XboxOneContentId:
716 | XboxOneTitleId:
717 | XboxOneSCId:
718 | XboxOneGameOsOverridePath:
719 | XboxOnePackagingOverridePath:
720 | XboxOneAppManifestOverridePath:
721 | XboxOneVersion: 1.0.0.0
722 | XboxOnePackageEncryption: 0
723 | XboxOnePackageUpdateGranularity: 2
724 | XboxOneDescription:
725 | XboxOneLanguage:
726 | - enus
727 | XboxOneCapability: []
728 | XboxOneGameRating: {}
729 | XboxOneIsContentPackage: 0
730 | XboxOneEnableGPUVariability: 0
731 | XboxOneSockets: {}
732 | XboxOneSplashScreen: {fileID: 0}
733 | XboxOneAllowedProductIds: []
734 | XboxOnePersistentLocalStorageSize: 0
735 | XboxOneXTitleMemory: 8
736 | xboxOneScriptCompiler: 0
737 | vrEditorSettings:
738 | daydream:
739 | daydreamIconForeground: {fileID: 0}
740 | daydreamIconBackground: {fileID: 0}
741 | cloudServicesEnabled:
742 | UNet: 1
743 | facebookSdkVersion: 7.9.4
744 | apiCompatibilityLevel: 3
745 | cloudProjectId:
746 | projectName:
747 | organizationId:
748 | cloudEnabled: 0
749 | enableNativePlatformBackendsForNewInputSystem: 0
750 | disableOldInputManagerSupport: 0
751 |
--------------------------------------------------------------------------------