OZEO-DOOZ / nrf_mesh_plugin

A Flutter plugin to enable mesh network management and communication using Nordic Semiconductor's SDKs.
https://pub.dev/packages/nordic_nrf_mesh
BSD 3-Clause "New" or "Revised" License
28 stars 19 forks source link

Unsupported value for standard codec #254

Closed Hung6129 closed 1 year ago

Hung6129 commented 1 year ago

I'm just test on iOS, the example app https://github.com/OZEO-DOOZ/nrf_mesh_plugin/tree/master/example And after provisioning->nav to control module-> i press on the the device to use on/off function Then this happen in the termial

🥂 [DoozMeshManagerApi] Received flutter call : setMtuSize
flutter: [NordicNrfMesh] connect took 6323ms
🥂 [DoozMeshNetwork] Received flutter call : nodes
flutter: onDeviceReady 7A282415-380D-F839-7457-4097F7B2A01E
🥂 [DoozProvisionedDevice] Received flutter call : elements
Unsupported value: 0xFFFF of type __SwiftValue
*** Assertion failure in -[FlutterStandardWriter writeValue:], FlutterStandardCodec.mm:338
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported value for standard codec'
*** First throw call stack:
(0x180a63d1c 0x198283ee4 0x182209c80 0x108b80254 0x108b80444 0x108b80254 0x108b80444 0x108b80254 0x108b809cc 0x108b7da44 0x104c2dec4 0x104c51044 0x104c50648 0x104c2ddc0 0x108b7d9ac 0x108655e8c 0x180723094 0x180724094 0x1806d0d44 0x1806d0994 0x180a1f0d4 0x1809dc5f8 0x1809ef250 0x1a1522988 0x1831efa94 0x182f88fd4 0x10455a5fc 0x105f6c4d0)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001bb336bbc libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x1bb336bbc <+8>:  b.lo   0x1bb336bd8               ; <+36>
    0x1bb336bc0 <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1bb336bc4 <+16>: mov    x29, sp
    0x1bb336bc8 <+20>: bl     0x1bb33260c               ; cerror_nocancel
Target 0: (Runner) stopped.

i think sth happened when calling element model, but i dont know where to find it i dont know much about swift so i hope you can check it out Thanks

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.7, on macOS 13.0 22A380 darwin-x64, locale en-VN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.73.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
ghost commented 1 year ago

Hello @Hung6129, Thanks for the report !

I can't tell when we can investigate on this. It might be a problem with our definitions of swift data class used as Flutter Method Channels args 🤔

Hung6129 commented 1 year ago

Hi @R0m4in-dooz So in the https://github.com/NordicSemiconductor/IOS-nRF-Mesh-Library and https://github.com/NordicSemiconductor/Android-nRF-Mesh-Library They scan for provisioned node in mesh network and the list only show the nodes that in the mesh network just done provisioning In the plugin you used this:

Future<void> _scanProvisionned() async {
    setState(() {
      _devices.clear();
    });
    await Permissions().checkAndAskPermissions();
    _scanSubscription = widget.nrfMesh.scanForProxy().listen((device) async {
      if (_devices.every((d) => d.id != device.id)) {
        setState(() {
          _devices.add(device);
        });
      }
    });
    setState(() {
      isScanning = true;
    });
    return Future.delayed(const Duration(seconds: 20), _stopScan);
  }

To get the provisioned node and reconnect to that node But it also show other nodes not in mesh network

And in READ_ME said that the we can Custom BLE features

Can you please show me or help me customize one BLE features that look like the nRF app to scan for provisioned node (only show node that provisioned in the mesh network and not show other node like the plugin)

Thanks <3

ghost commented 1 year ago

Hello @Hung6129, Your question seems unrelated to this issue but yes, the scan for provisioned nodes cannot know the network, it's your responsibility to check if it's a relevant node for the current managed network. The plugin provides the API to do this check, just use the following :

DiscoveredDevice device;
final sD = device.serviceData[meshProxyUuid]!;

if (await _meshManagerApi.nodeIdentityMatches(sD) ||
          await _meshManagerApi.networkIdMatches(sD)) {
  // node belongs to loaded mesh n/w
}
Hung6129 commented 1 year ago

Hi @R0m4in-dooz Sorry abt the unrelated question, i am a junior dev and i have a task to re-creating nRF-Mesh app using flutter and lately i've been stuck at scanning for provisioned node so i have no chose to ask you :) Btw thanks for the suggest it work perfect

ghost commented 1 year ago

Ahah no worries. Glad I can help. Don't hesitate to open new issues so my answers are not lost here 👍 and if you want, you can edit the readme or the docs of the plugin with your discoveries too, I know the doc is not complete, sry 😅

ghost commented 1 year ago

Hello there,

A fix has been merged to master, you can use this for now before we publish a new release 👍