react-native-bluebreeze 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +8 -17
- package/android/generated/java/com/bluebreeze/NativeBlueBreezeSpec.java +17 -9
- package/android/generated/jni/RNBlueBreezeSpec-generated.cpp +21 -14
- package/android/generated/jni/react/renderer/components/RNBlueBreezeSpec/RNBlueBreezeSpecJSI-generated.cpp +19 -12
- package/android/generated/jni/react/renderer/components/RNBlueBreezeSpec/RNBlueBreezeSpecJSI.h +279 -53
- package/android/gradle.properties +5 -5
- package/android/src/main/java/com/bluebreeze/BlueBreezeModule.kt +632 -16
- package/android/src/main/java/com/bluebreeze/BlueBreezePackage.kt +0 -1
- package/ios/BlueBreezeImpl.swift +92 -84
- package/ios/Bluebreeze.mm +52 -25
- package/ios/generated/RNBlueBreezeSpec/RNBlueBreezeSpec-generated.mm +30 -18
- package/ios/generated/RNBlueBreezeSpec/RNBlueBreezeSpec.h +12 -7
- package/ios/generated/RNBlueBreezeSpecJSI-generated.cpp +19 -12
- package/ios/generated/RNBlueBreezeSpecJSI.h +279 -53
- package/lib/commonjs/NativeBlueBreeze.js +11 -0
- package/lib/commonjs/NativeBlueBreeze.js.map +1 -0
- package/lib/commonjs/implementation/bluebreeze_characteristic.js +29 -0
- package/lib/commonjs/implementation/bluebreeze_characteristic.js.map +1 -0
- package/lib/commonjs/implementation/bluebreeze_device.js +31 -0
- package/lib/commonjs/implementation/bluebreeze_device.js.map +1 -0
- package/lib/commonjs/implementation/bluebreeze_scan_result.js +20 -0
- package/lib/commonjs/implementation/bluebreeze_scan_result.js.map +1 -0
- package/lib/commonjs/implementation/bluebreeze_service.js +15 -0
- package/lib/commonjs/implementation/bluebreeze_service.js.map +1 -0
- package/lib/commonjs/implementation/emitters.js +32 -0
- package/lib/commonjs/implementation/emitters.js.map +1 -0
- package/lib/commonjs/index.js +171 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/NativeBlueBreeze.js +10 -0
- package/lib/module/NativeBlueBreeze.js.map +1 -0
- package/lib/module/implementation/bluebreeze_characteristic.js +23 -0
- package/lib/module/implementation/bluebreeze_characteristic.js.map +1 -0
- package/lib/module/implementation/bluebreeze_device.js +25 -0
- package/lib/module/implementation/bluebreeze_device.js.map +1 -0
- package/lib/module/implementation/bluebreeze_scan_result.js +15 -0
- package/lib/module/implementation/bluebreeze_scan_result.js.map +1 -0
- package/lib/module/implementation/bluebreeze_service.js +10 -0
- package/lib/module/implementation/bluebreeze_service.js.map +1 -0
- package/lib/module/implementation/emitters.js +25 -0
- package/lib/module/implementation/emitters.js.map +1 -0
- package/lib/module/index.js +168 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeBlueBreeze.d.ts +86 -0
- package/lib/typescript/commonjs/src/NativeBlueBreeze.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/implementation/bluebreeze_characteristic.d.ts +14 -0
- package/lib/typescript/commonjs/src/implementation/bluebreeze_characteristic.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/implementation/bluebreeze_device.d.ts +15 -0
- package/lib/typescript/commonjs/src/implementation/bluebreeze_device.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/implementation/bluebreeze_scan_result.d.ts +13 -0
- package/lib/typescript/commonjs/src/implementation/bluebreeze_scan_result.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/implementation/bluebreeze_service.d.ts +8 -0
- package/lib/typescript/commonjs/src/implementation/bluebreeze_service.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/implementation/emitters.d.ts +12 -0
- package/lib/typescript/commonjs/src/implementation/emitters.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +30 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeBlueBreeze.d.ts +86 -0
- package/lib/typescript/module/src/NativeBlueBreeze.d.ts.map +1 -0
- package/lib/typescript/module/src/implementation/bluebreeze_characteristic.d.ts +14 -0
- package/lib/typescript/module/src/implementation/bluebreeze_characteristic.d.ts.map +1 -0
- package/lib/typescript/module/src/implementation/bluebreeze_device.d.ts +15 -0
- package/lib/typescript/module/src/implementation/bluebreeze_device.d.ts.map +1 -0
- package/lib/typescript/module/src/implementation/bluebreeze_scan_result.d.ts +13 -0
- package/lib/typescript/module/src/implementation/bluebreeze_scan_result.d.ts.map +1 -0
- package/lib/typescript/module/src/implementation/bluebreeze_service.d.ts +8 -0
- package/lib/typescript/module/src/implementation/bluebreeze_service.d.ts.map +1 -0
- package/lib/typescript/module/src/implementation/emitters.d.ts +12 -0
- package/lib/typescript/module/src/implementation/emitters.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +30 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +25 -21
- package/react-native-bluebreeze.podspec +1 -1
- package/src/NativeBlueBreeze.ts +83 -104
- package/src/implementation/bluebreeze_characteristic.ts +40 -0
- package/src/implementation/bluebreeze_device.ts +40 -0
- package/src/implementation/bluebreeze_scan_result.ts +32 -0
- package/src/implementation/bluebreeze_service.ts +17 -0
- package/src/implementation/emitters.ts +28 -0
- package/src/index.tsx +289 -81
package/src/NativeBlueBreeze.ts
CHANGED
|
@@ -1,142 +1,121 @@
|
|
|
1
|
-
import type { TurboModule } from 'react-native'
|
|
2
|
-
import { TurboModuleRegistry } from 'react-native'
|
|
3
|
-
import type {EventEmitter} from 'react-native/Libraries/Types/CodegenTypes'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly notifyEnabledEmitter: EventEmitter<boolean>;
|
|
17
|
-
|
|
18
|
-
// Operations
|
|
19
|
-
read: () => Promise<number[]>;
|
|
20
|
-
write: (data: number[], withResponse: boolean) => Promise<void>;
|
|
21
|
-
subscribe: () => Promise<void>;
|
|
22
|
-
unsubscribe: () => Promise<void>;
|
|
1
|
+
import type { TurboModule } from 'react-native'
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native'
|
|
3
|
+
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes'
|
|
4
|
+
|
|
5
|
+
/// Events
|
|
6
|
+
|
|
7
|
+
export interface SpecScanResult {
|
|
8
|
+
id: string
|
|
9
|
+
name?: string
|
|
10
|
+
rssi: number
|
|
11
|
+
connectable: boolean
|
|
12
|
+
advertisedServices: string[]
|
|
13
|
+
manufacturerId?: number
|
|
14
|
+
manufacturerName?: string
|
|
15
|
+
manufacturerData?: number[]
|
|
23
16
|
}
|
|
24
17
|
|
|
25
|
-
export interface
|
|
26
|
-
id: string
|
|
27
|
-
name?: string
|
|
28
|
-
characteristics: BBCharacteristic[];
|
|
18
|
+
export interface SpecDevice {
|
|
19
|
+
id: string
|
|
20
|
+
name?: string
|
|
29
21
|
}
|
|
30
22
|
|
|
31
|
-
export interface
|
|
32
|
-
id: string
|
|
33
|
-
|
|
23
|
+
export interface SpecDeviceCharacteristic {
|
|
24
|
+
id: string
|
|
25
|
+
name?: string
|
|
26
|
+
properties: string[]
|
|
34
27
|
}
|
|
35
28
|
|
|
36
|
-
export interface
|
|
37
|
-
id: string
|
|
38
|
-
|
|
29
|
+
export interface SpecDeviceService {
|
|
30
|
+
id: string
|
|
31
|
+
name?: string
|
|
32
|
+
characteristics: SpecDeviceCharacteristic[]
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
export interface
|
|
42
|
-
id: string
|
|
43
|
-
value:
|
|
35
|
+
export interface SpecDeviceServices {
|
|
36
|
+
id: string
|
|
37
|
+
value: SpecDeviceService[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface SpecDeviceConnectionStatus {
|
|
41
|
+
id: string
|
|
42
|
+
value: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SpecDeviceMTU {
|
|
46
|
+
id: string
|
|
47
|
+
value: number
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export interface BBDeviceCharacteristicDataEvent {
|
|
47
|
-
id: string
|
|
48
|
-
serviceId: string
|
|
49
|
-
characteristicId: string
|
|
50
|
-
value: number[]
|
|
51
|
+
id: string
|
|
52
|
+
serviceId: string
|
|
53
|
+
characteristicId: string
|
|
54
|
+
value: number[]
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
export interface BBDeviceCharacteristicNotifyEnabledEvent {
|
|
54
|
-
id: string
|
|
55
|
-
serviceId: string
|
|
56
|
-
characteristicId: string
|
|
57
|
-
value: boolean
|
|
58
|
+
id: string
|
|
59
|
+
serviceId: string
|
|
60
|
+
characteristicId: string
|
|
61
|
+
value: boolean
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
id: string;
|
|
62
|
-
name?: string;
|
|
63
|
-
rssi: number;
|
|
64
|
-
isConnectable: boolean;
|
|
65
|
-
manufacturerId?: number;
|
|
66
|
-
manufacturerName?: string;
|
|
67
|
-
manufacturerData?: number[];
|
|
68
|
-
advertisedServices: string[];
|
|
69
|
-
|
|
70
|
-
// Services
|
|
71
|
-
services(): BBService[];
|
|
72
|
-
readonly servicesEmitter: EventEmitter<BBService[]>;
|
|
73
|
-
|
|
74
|
-
// Connection status
|
|
75
|
-
connectionStatus(): string;
|
|
76
|
-
readonly connectionStatusEmitter: EventEmitter<string>;
|
|
77
|
-
|
|
78
|
-
// MTU
|
|
79
|
-
mtu(): number;
|
|
80
|
-
readonly mtuEmitter: EventEmitter<number>;
|
|
81
|
-
|
|
82
|
-
// Operations
|
|
83
|
-
connect: () => Promise<void>;
|
|
84
|
-
disconnect: () => Promise<void>;
|
|
85
|
-
discoverServices: () => Promise<void>;
|
|
86
|
-
requestMTU: (mtu: number) => Promise<number>;
|
|
87
|
-
}
|
|
64
|
+
/// Module specifications
|
|
88
65
|
|
|
89
66
|
export interface Spec extends TurboModule {
|
|
90
|
-
// Authorization
|
|
91
|
-
authorizationStatus(): string;
|
|
92
|
-
readonly authorizationStatusEmitter: EventEmitter<string>;
|
|
93
|
-
authorizationRequest(): void;
|
|
94
|
-
|
|
95
67
|
// State
|
|
96
|
-
state(): string
|
|
97
|
-
readonly stateEmitter: EventEmitter<string
|
|
68
|
+
state(): string
|
|
69
|
+
readonly stateEmitter: EventEmitter<string>
|
|
70
|
+
|
|
71
|
+
// Authorization
|
|
72
|
+
authorizationStatus(): string
|
|
73
|
+
readonly authorizationStatusEmitter: EventEmitter<string>
|
|
74
|
+
authorizationRequest(): void
|
|
75
|
+
authorizationOpenSettings(): void
|
|
98
76
|
|
|
99
77
|
// Scanning
|
|
100
|
-
|
|
101
|
-
readonly
|
|
102
|
-
|
|
103
|
-
|
|
78
|
+
scanEnabled(): boolean
|
|
79
|
+
readonly scanEnabledEmitter: EventEmitter<boolean>
|
|
80
|
+
readonly scanResultEmitter: EventEmitter<SpecScanResult>
|
|
81
|
+
scanStart(): void
|
|
82
|
+
scanStop(): void
|
|
104
83
|
|
|
105
84
|
// Devices
|
|
106
|
-
devices():
|
|
107
|
-
readonly devicesEmitter: EventEmitter<
|
|
85
|
+
devices(): SpecDevice[]
|
|
86
|
+
readonly devicesEmitter: EventEmitter<SpecDevice[]>
|
|
108
87
|
|
|
109
88
|
// Device services
|
|
110
|
-
deviceServices(id: string):
|
|
111
|
-
readonly deviceServicesEmitter: EventEmitter<
|
|
89
|
+
deviceServices(id: string): SpecDeviceService[]
|
|
90
|
+
readonly deviceServicesEmitter: EventEmitter<SpecDeviceServices>
|
|
112
91
|
|
|
113
92
|
// Device connection status
|
|
114
|
-
deviceConnectionStatus(id: string): string
|
|
115
|
-
readonly deviceConnectionStatusEmitter: EventEmitter<
|
|
93
|
+
deviceConnectionStatus(id: string): string
|
|
94
|
+
readonly deviceConnectionStatusEmitter: EventEmitter<SpecDeviceConnectionStatus>
|
|
116
95
|
|
|
117
96
|
// Device MTU
|
|
118
|
-
deviceMTU(id: string): number
|
|
119
|
-
readonly deviceMTUEmitter: EventEmitter<
|
|
97
|
+
deviceMTU(id: string): number
|
|
98
|
+
readonly deviceMTUEmitter: EventEmitter<SpecDeviceMTU>
|
|
120
99
|
|
|
121
|
-
// Device
|
|
122
|
-
deviceConnect(id: string): Promise<void
|
|
123
|
-
deviceDisconnect(id: string): Promise<void
|
|
124
|
-
deviceDiscoverServices(id: string): Promise<void
|
|
125
|
-
deviceRequestMTU(id: string, mtu: number): Promise<number
|
|
100
|
+
// Device operations
|
|
101
|
+
deviceConnect(id: string): Promise<void>
|
|
102
|
+
deviceDisconnect(id: string): Promise<void>
|
|
103
|
+
deviceDiscoverServices(id: string): Promise<void>
|
|
104
|
+
deviceRequestMTU(id: string, mtu: number): Promise<number>
|
|
126
105
|
|
|
127
106
|
// Device characteristic data
|
|
128
|
-
deviceCharacteristicData(id: string, serviceId: string, characteristicId: string): number[]
|
|
129
|
-
readonly deviceCharacteristicDataEmitter: EventEmitter<BBDeviceCharacteristicDataEvent
|
|
107
|
+
deviceCharacteristicData(id: string, serviceId: string, characteristicId: string): number[]
|
|
108
|
+
readonly deviceCharacteristicDataEmitter: EventEmitter<BBDeviceCharacteristicDataEvent>
|
|
130
109
|
|
|
131
110
|
// Device characteristic notify enabled
|
|
132
|
-
deviceCharacteristicNotifyEnabled(id: string, serviceId: string, characteristicId: string): boolean
|
|
133
|
-
readonly deviceCharacteristicNotifyEnabledEmitter: EventEmitter<BBDeviceCharacteristicNotifyEnabledEvent
|
|
111
|
+
deviceCharacteristicNotifyEnabled(id: string, serviceId: string, characteristicId: string): boolean
|
|
112
|
+
readonly deviceCharacteristicNotifyEnabledEmitter: EventEmitter<BBDeviceCharacteristicNotifyEnabledEvent>
|
|
134
113
|
|
|
135
114
|
// Device characteristic operations
|
|
136
|
-
deviceCharacteristicRead(id: string, serviceId: string, characteristicId: string): Promise<number[]
|
|
137
|
-
deviceCharacteristicWrite(id: string, serviceId: string, characteristicId: string, data: number[], withResponse: boolean): Promise<void
|
|
138
|
-
deviceCharacteristicSubscribe(id: string, serviceId: string, characteristicId: string): Promise<void
|
|
139
|
-
deviceCharacteristicUnsubscribe(id: string, serviceId: string, characteristicId: string): Promise<void
|
|
115
|
+
deviceCharacteristicRead(id: string, serviceId: string, characteristicId: string): Promise<number[]>
|
|
116
|
+
deviceCharacteristicWrite(id: string, serviceId: string, characteristicId: string, data: number[], withResponse: boolean): Promise<void>
|
|
117
|
+
deviceCharacteristicSubscribe(id: string, serviceId: string, characteristicId: string): Promise<void>
|
|
118
|
+
deviceCharacteristicUnsubscribe(id: string, serviceId: string, characteristicId: string): Promise<void>
|
|
140
119
|
}
|
|
141
120
|
|
|
142
|
-
export default TurboModuleRegistry.getEnforcing<Spec>('BlueBreeze')
|
|
121
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('BlueBreeze')
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import BlueBreeze from "react-native-bluebreeze"
|
|
2
|
+
import type { StateEventEmitter } from "./emitters"
|
|
3
|
+
|
|
4
|
+
export class BBCharacteristic {
|
|
5
|
+
constructor(
|
|
6
|
+
deviceId: string,
|
|
7
|
+
serviceId: string,
|
|
8
|
+
id: string,
|
|
9
|
+
name: string | undefined,
|
|
10
|
+
properties: string[]
|
|
11
|
+
) {
|
|
12
|
+
this.id = id
|
|
13
|
+
this.name = name
|
|
14
|
+
this.properties = properties
|
|
15
|
+
|
|
16
|
+
this.data = BlueBreeze.deviceCharacteristicData(deviceId, serviceId, id)
|
|
17
|
+
this.notifyEnabled = BlueBreeze.deviceCharacteristicNotifyEnabled(deviceId, serviceId, id)
|
|
18
|
+
|
|
19
|
+
this.read = () => BlueBreeze.deviceCharacteristicRead(deviceId, serviceId, id)
|
|
20
|
+
this.write = (data: number[], withResponse: boolean) => BlueBreeze.deviceCharacteristicWrite(deviceId, serviceId, id, data, withResponse)
|
|
21
|
+
this.subscribe = () => BlueBreeze.deviceCharacteristicSubscribe(deviceId, serviceId, id)
|
|
22
|
+
this.unsubscribe = () => BlueBreeze.deviceCharacteristicUnsubscribe(deviceId, serviceId, id)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
id: string
|
|
26
|
+
name?: string
|
|
27
|
+
properties: string[]
|
|
28
|
+
|
|
29
|
+
// Data
|
|
30
|
+
data: StateEventEmitter<number[]>
|
|
31
|
+
|
|
32
|
+
// Notifying
|
|
33
|
+
notifyEnabled: StateEventEmitter<boolean>
|
|
34
|
+
|
|
35
|
+
// Operations
|
|
36
|
+
read: () => Promise<number[]>
|
|
37
|
+
write: (data: number[], withResponse: boolean) => Promise<void>
|
|
38
|
+
subscribe: () => Promise<void>
|
|
39
|
+
unsubscribe: () => Promise<void>
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import BlueBreeze from "react-native-bluebreeze"
|
|
2
|
+
import type { BBService } from "./bluebreeze_service"
|
|
3
|
+
import { StateEventEmitter } from "./emitters"
|
|
4
|
+
|
|
5
|
+
export class BBDevice {
|
|
6
|
+
constructor(
|
|
7
|
+
id: string,
|
|
8
|
+
name?: string,
|
|
9
|
+
) {
|
|
10
|
+
this.id = id
|
|
11
|
+
this.name = name
|
|
12
|
+
|
|
13
|
+
this.services = BlueBreeze.deviceServices(id)
|
|
14
|
+
this.connectionStatus = BlueBreeze.deviceConnectionStatus(id)
|
|
15
|
+
this.mtu = BlueBreeze.deviceMTU(id)
|
|
16
|
+
|
|
17
|
+
this.connect = () => BlueBreeze.deviceConnect(id)
|
|
18
|
+
this.disconnect = () => BlueBreeze.deviceDisconnect(id)
|
|
19
|
+
this.discoverServices = () => BlueBreeze.deviceDiscoverServices(id)
|
|
20
|
+
this.requestMTU = (mtu: number) => BlueBreeze.deviceRequestMTU(id, mtu)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
id: string
|
|
24
|
+
name?: string
|
|
25
|
+
|
|
26
|
+
// Services
|
|
27
|
+
services: StateEventEmitter<BBService[]>
|
|
28
|
+
|
|
29
|
+
// Connection status
|
|
30
|
+
connectionStatus: StateEventEmitter<string>
|
|
31
|
+
|
|
32
|
+
// MTU
|
|
33
|
+
mtu: StateEventEmitter<number>
|
|
34
|
+
|
|
35
|
+
// Operations
|
|
36
|
+
connect: () => Promise<void>
|
|
37
|
+
disconnect: () => Promise<void>
|
|
38
|
+
discoverServices: () => Promise<void>
|
|
39
|
+
requestMTU: (mtu: number) => Promise<number>
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BBDevice } from "./bluebreeze_device"
|
|
2
|
+
|
|
3
|
+
export class BBScanResult {
|
|
4
|
+
constructor(
|
|
5
|
+
device: BBDevice,
|
|
6
|
+
name: string | undefined,
|
|
7
|
+
rssi: number,
|
|
8
|
+
connectable: boolean,
|
|
9
|
+
advertisedServices: string[],
|
|
10
|
+
manufacturerId?: number,
|
|
11
|
+
manufacturerName?: string,
|
|
12
|
+
manufacturerData?: number[]
|
|
13
|
+
) {
|
|
14
|
+
this.device = device
|
|
15
|
+
this.name = name
|
|
16
|
+
this.rssi = rssi
|
|
17
|
+
this.connectable = connectable
|
|
18
|
+
this.advertisedServices = advertisedServices
|
|
19
|
+
this.manufacturerId = manufacturerId
|
|
20
|
+
this.manufacturerName = manufacturerName
|
|
21
|
+
this.manufacturerData = manufacturerData
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
device: BBDevice
|
|
25
|
+
name?: string
|
|
26
|
+
rssi: number
|
|
27
|
+
connectable: boolean
|
|
28
|
+
advertisedServices: string[]
|
|
29
|
+
manufacturerId?: number
|
|
30
|
+
manufacturerName?: string
|
|
31
|
+
manufacturerData?: number[]
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BBCharacteristic } from "./bluebreeze_characteristic"
|
|
2
|
+
|
|
3
|
+
export class BBService {
|
|
4
|
+
constructor(
|
|
5
|
+
id: string,
|
|
6
|
+
name: string | undefined,
|
|
7
|
+
characteristics: BBCharacteristic[]
|
|
8
|
+
) {
|
|
9
|
+
this.id = id
|
|
10
|
+
this.name = name
|
|
11
|
+
this.characteristics = characteristics
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
id: string
|
|
15
|
+
name?: string
|
|
16
|
+
characteristics: BBCharacteristic[]
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _EventEmitter, { type EmitterSubscription } from "react-native/Libraries/vendor/emitter/EventEmitter"
|
|
2
|
+
|
|
3
|
+
export class EventEmitter<T> extends _EventEmitter {
|
|
4
|
+
constructor() {
|
|
5
|
+
super()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
add(v: T) {
|
|
9
|
+
this.emit('value', v)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
onValue: (handler: (v: T) => void) => EmitterSubscription = (handler) => {
|
|
13
|
+
return this.addListener('value', handler)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class StateEventEmitter<T> extends EventEmitter<T> {
|
|
17
|
+
constructor(initialValue: T | undefined = undefined) {
|
|
18
|
+
super()
|
|
19
|
+
this.value = initialValue
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
add(v: T) {
|
|
23
|
+
this.value = v
|
|
24
|
+
super.add(v)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
value: T | undefined
|
|
28
|
+
}
|