| 64 | } |
| 65 | |
| 66 | class Client { |
| 67 | constructor(dictionary) { |
| 68 | for (let property in dictionary) { |
| 69 | switch (property) { |
| 70 | case "ble": |
| 71 | this.ble = dictionary.ble; |
| 72 | break; |
| 73 | case "connection": |
| 74 | this.connection = dictionary.connection; |
| 75 | break; |
| 76 | case "address": |
| 77 | this.address = dictionary.address; |
| 78 | break; |
| 79 | case "addressType": |
| 80 | this.addressType = dictionary.addressType; |
| 81 | break; |
| 82 | default: |
| 83 | throw new Error(`invalid property "${property}`); |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | this.services = []; |
| 88 | } |
| 89 | |
| 90 | close() { |
| 91 | this._disconnect(this.connection); |
| 92 | } |
| 93 | |
| 94 | discoverPrimaryService(uuid) { |
| 95 | this.services.length = 0; |
| 96 | this._discoverPrimaryServices(this.connection, uuid); |
| 97 | } |
| 98 | |
| 99 | discoverAllPrimaryServices() { |
| 100 | this.services.length = 0; |
| 101 | this._discoverPrimaryServices(this.connection); |
| 102 | } |
| 103 | |
| 104 | findServiceByUUID(uuid) { |
| 105 | return this.services.find(service => uuid.equals(service.uuid)); |
| 106 | } |
| 107 | |
| 108 | readRSSI() { |
| 109 | this._readRSSI(this.connection); |
| 110 | } |
| 111 | |
| 112 | exchangeMTU(value) { |
| 113 | this._exchangeMTU(this.connection, value); |
| 114 | } |
| 115 | |
| 116 | _exchangeMTU() @ "xs_gap_connection_exchange_mtu" |
| 117 | |
| 118 | _discoverPrimaryServices() @ "xs_gatt_client_discover_primary_services" |
| 119 | |
| 120 | _disconnect() @ "xs_gap_connection_disconnect" |
| 121 | |
| 122 | _findCharacteristicByHandle(handle) { |
| 123 | for (let i = 0, services = this.services, length = services.length; i < length; i++) { |
nothing calls this directly
no outgoing calls
no test coverage detected