Giter VIP home page Giter VIP logo

Comments (18)

jarlamsa avatar jarlamsa commented on August 18, 2024

@teetak01 @JanneKiiskila @kjbracey-arm
Is this just configuration issue, or should mbed-os have a mechanism in place for cloud client to use the nanostack event loop in co-operation with the mbed-mesh-api?

from mbed-cloud-client-example.

kjbracey avatar kjbracey commented on August 18, 2024

IIRC, the assumption originally when that was written was that mbed-mesh-api's init would get in first, and allocate a big heap to run Nanostack. Cloud client would be the second caller, and that was okay because it used a tiny dynamically-allocated heap - was only used for the event loop, as it used system malloc for all its main structures.

from mbed-cloud-client-example.

kjbracey avatar kjbracey commented on August 18, 2024

Obviously this is all a bit fragile, and I guess something has changed. Looking to see where mesh_system_init is called, I see it

  • in the constructor of Nanostack, which would kick in the moment you create an EthernetInterface with it as the default stack.
  • in MeshInterfaceNanostack::initialize

Seems like it should probably be in MeshInterfaceNanostack's constructor too.

Can you reorder the test app to ensure the network interface is located for the first time before the client code activates?

from mbed-cloud-client-example.

kjbracey avatar kjbracey commented on August 18, 2024

If you do want to share init code with mbed-mesh-api, we could arrange that, but then you would be sharing the config setting, and those would be defaulting to "big enough for Nanostack", so you'd have to have app config to pull that back down when you knew Nanostack wasn't in use.

from mbed-cloud-client-example.

jarlamsa avatar jarlamsa commented on August 18, 2024

Can you reorder the test app to ensure the network interface is located for the first time before the client code activates?

Those are quite coupled together and I am not cloud client expert. @teetak01 could you take a look?

from mbed-cloud-client-example.

kjbracey avatar kjbracey commented on August 18, 2024

It's possible that you have already located the network interface first (via NetworkInterface::get_default_instance(), and the issue is due to the lack of init in MeshInterfaceNanostack's constructor.

By code inspection this sequence would initialise the HAL:

LoWPANNDInterface lowpan();
lowpan.initialize(&NanostackRfPhy::get_default_instance())

But MeshInterface::get_target_default_instance() does this:

LoWPANNDInterface lowpan(&NanostackRfPhy::get_default_instance());

and that apparently does not. I think that's a bug.

from mbed-cloud-client-example.

jarlamsa avatar jarlamsa commented on August 18, 2024

mcc_common_setup.cpp calls the NetworkInterface::get_default_instance, that is called from simplem2mclient.h
SimpleM2MClient has a member MbedCloudClient which has a member ServiceClient which has a member ConnectorClient, which calls ns_hal_init in it's constructor. The member MbedCloudClient is constructed before calling the mcc_common_setup.

from mbed-cloud-client-example.

jarlamsa avatar jarlamsa commented on August 18, 2024

Yes, the initialising of HAL seems to be a bug and probably fixes issues with EUI64, but doesn't solve this issue straight away.

from mbed-cloud-client-example.

jarlamsa avatar jarlamsa commented on August 18, 2024

Adding @mikter @artokin

from mbed-cloud-client-example.

kjbracey avatar kjbracey commented on August 18, 2024

Could a get_default_instance call could be done first in the initializer list? Bit subtle, I know...

from mbed-cloud-client-example.

jarlamsa avatar jarlamsa commented on August 18, 2024

Let's see, at least seems to be possible to do it in the initializer list.
Still the later calls to ns_hal_init are not doing anything, is this intentional that without Nanostack those would still be called? Couldn't just some preprocessor flag solve this race?

from mbed-cloud-client-example.

kjbracey avatar kjbracey commented on August 18, 2024

mbed client uses the ns_hal, so needs it initialised, even if Nanostack isn't in use. Those other calls will start doing something when Nanostack is out of use.

from mbed-cloud-client-example.

ciarmcom avatar ciarmcom commented on August 18, 2024

ARM Internal Ref: IOTCLT-3172

from mbed-cloud-client-example.

jarlamsa avatar jarlamsa commented on August 18, 2024

Changing the constructor https://github.com/ARMmbed/mbed-cloud-client-example/blob/master/source/simplem2mclient.h#L49
so that the mcc_platform_init_connection is first in the initializer-list and calling _cloud_client() last on the initializer-list still causes the ConnectorClient to be initialised first thus causing it to call the ns_hal_init first. Are the member objects constructed already before going through the initializer-list?

from mbed-cloud-client-example.

jarlamsa avatar jarlamsa commented on August 18, 2024

Not sure what happened after changing the initialising order. I have 2 different radio versions, seems that the SPI with the other one doesn't work properly anymore, other is working without problems.

from mbed-cloud-client-example.

jarlamsa avatar jarlamsa commented on August 18, 2024

Hmm, seems that using tr_info in the mesh_system_init caused the issues with the other version of the radio shield.

Reordering the app so that network interface gets initialised first and thus mesh_system.c calls the ns_hal_init first doesn't seem to bring any ill effects. Now the statically allocated memory is used for the Nanostack heap and calls from cloud client to ns_hal_init are returning immediately.

from mbed-cloud-client-example.

JanneKiiskila avatar JanneKiiskila commented on August 18, 2024

Will be fixed to Client 2.2.0 release.

from mbed-cloud-client-example.

teetak01 avatar teetak01 commented on August 18, 2024

This has been fixed in 2.2.0 release.

from mbed-cloud-client-example.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.