diff --git a/demo/app/home/device-list/device-list-view-model.ts b/demo/app/home/device-list/device-list-view-model.ts index 4ca6ef4..9c090c8 100644 --- a/demo/app/home/device-list/device-list-view-model.ts +++ b/demo/app/home/device-list/device-list-view-model.ts @@ -1,6 +1,7 @@ import { Observable } from "@nativescript/core"; import { getLogger } from "~/home/logger/logger-view-model"; import { getNodeDiscoverer } from "nativescript-wearos-sensors/node"; +import { getFreeMessageClient } from "nativescript-wearos-sensors/internal/communication/free-message"; export class DeviceListViewModel extends Observable { @@ -13,6 +14,10 @@ export class DeviceListViewModel extends Observable { this.logger = getLogger(); this.scanning = false; this.nodes = []; + + getFreeMessageClient().registerListener((receivedMessage) => { + this.logger.logInfo(`received single message ${JSON.stringify(receivedMessage)}`); + }); } getNode(index: number): ConnectedNode { diff --git a/demo/app/home/device/device-view-model.ts b/demo/app/home/device/device-view-model.ts index bd26342..7b83484 100644 --- a/demo/app/home/device/device-view-model.ts +++ b/demo/app/home/device/device-view-model.ts @@ -65,9 +65,6 @@ export class DeviceViewModel extends Observable { }); this.freeMessageClient = getFreeMessageClient(); - this.freeMessageClient.registerListener((receivedMessage) => { - this.logger.logResultForNode(this.node.name, `received single message ${JSON.stringify(receivedMessage)}`); - }); } async onTestFreeMessage() { diff --git a/src/internal/communication/free-message/android/free-message-result-service.android.ts b/src/internal/communication/free-message/android/free-message-result-service.android.ts index ca99708..8d951c2 100644 --- a/src/internal/communication/free-message/android/free-message-result-service.android.ts +++ b/src/internal/communication/free-message/android/free-message-result-service.android.ts @@ -1,6 +1,6 @@ import { CommunicationResultService } from "../../communication-result-service"; import WearableListenerServiceDelegate = es.uji.geotec.wearos_sensors.messaging.WearableListenerServiceDelegate; -import { FreeMessage, FreeMessageListener, FreeMessageProtocol, ReceivedMessage } from "../index"; +import { FreeMessage, FreeMessageListener, freeMessageProtocol, FreeMessageProtocol, ReceivedMessage } from "../index"; import { CommunicationProtocol } from "../../communication-protocol"; import { wearOS } from "../../../utils/android/wear-os-types.android"; import { decodeMessage } from "../../encoder-decoder"; @@ -8,7 +8,7 @@ import { decodeFreeMessage } from "../encoder-decoder"; export class FreeMessageResultService implements CommunicationResultService, WearableListenerServiceDelegate { - private protocol: FreeMessageProtocol; + private protocol: FreeMessageProtocol = freeMessageProtocol; private resolutionCallbacks = new Map(); private defaultListener: FreeMessageListener;