Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zephyr + Openthread compilation problem #6

Open
andy9a9 opened this issue Aug 10, 2023 · 1 comment
Open

Zephyr + Openthread compilation problem #6

andy9a9 opened this issue Aug 10, 2023 · 1 comment

Comments

@andy9a9
Copy link

andy9a9 commented Aug 10, 2023

Dear maintainers!

I tried to build the samples/light_switch_sensor with zephyr project and it failed.

/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:42:2: error: #error "Thread 1.2 or higher version is required for OPENTHREAD_CONFIG_MLR_ENABLE"
   42 | #error "Thread 1.2 or higher version is required for OPENTHREAD_CONFIG_MLR_ENABLE"
      |  ^~~~~
/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:98:44: error: 'BackboneRouter' has not been declared
   98 |     void HandleBackboneRouterPrimaryUpdate(BackboneRouter::Leader::State aState, const BackboneRouter::Config &aConfig);
      |                                            ^~~~~~~~~~~~~~
/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:98:74: error: expected ',' or '...' before 'aState'
   98 |     void HandleBackboneRouterPrimaryUpdate(BackboneRouter::Leader::State aState, const BackboneRouter::Config &aConfig);
      |                                                                          ^~~~~~
/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:195:70: error: 'Ip6AddressesTlv' has not been declared
  195 |     void        AppendToUniqueAddressList(Ip6::Address (&aAddresses)[Ip6AddressesTlv::kMaxAddresses],
      |                                                                      ^~~~~~~~~~~~~~~
/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:195:101: error: expected ')' before ',' token
  195 |     void        AppendToUniqueAddressList(Ip6::Address (&aAddresses)[Ip6AddressesTlv::kMaxAddresses],
      |                                          ~                                                          ^
      |                                                                                                     )
/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:196:43: error: variable or field 'uint8_t' declared void
  196 |                                           uint8_t            &aAddressNum,
      |                                           ^~~~~~~
/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:196:43: error: expected ';' at end of member declaration
  196 |                                           uint8_t            &aAddressNum,
      |                                           ^~~~~~~
      |                                                  ;
/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:196:63: error: ISO C++ forbids declaration of 'aAddressNum' with no type [-fpermissive]
  196 |                                           uint8_t            &aAddressNum,
      |                                                               ^~~~~~~~~~~
/home/vboxuser/zephyrproject/modules/lib/openthread/src/core/thread/mlr_manager.hpp:197:43: error: expected unqualified-id before 'const'
  197 |                                           const Ip6::Address &aAddr

Is there something special what should I set, like CONFIG_OPENTHREAD_MLR=n? Is there some special version needed? See err.log for more details.

Thanks,
Andy

@andy9a9 andy9a9 changed the title Zephry + Openthread compilation problem Zephyr + Openthread compilation problem Aug 10, 2023
@andy9a9
Copy link
Author

andy9a9 commented Aug 16, 2023

Next question is, why did you chose the OpenThread variant, while the posix Linux is using a native sockets? For example in oc_connectivity_init

// Linux
int
oc_connectivity_init(size_t device)
{
  OC_DBG("Initializing connectivity for device %zd", device);

  ip_context_t *dev = (ip_context_t *)oc_memb_alloc(&ip_context_s);
  if (!dev) {
    oc_abort("Insufficient memory");
  }
  oc_list_add(ip_contexts, dev);
  dev->device = device;
  OC_LIST_STRUCT_INIT(dev, eps);

  if (pthread_mutex_init(&dev->rfds_mutex, NULL) != 0) {
    oc_abort("error initializing TCP adapter mutex");
  }

  if (pipe(dev->shutdown_pipe) < 0) {
    OC_ERR("shutdown pipe: %d", errno);
    return -1;
  }
  if (set_nonblock_socket(dev->shutdown_pipe[0]) < 0) {
    OC_ERR("Could not set non-block shutdown_pipe[0]");
    return -1;
  }

  memset(&dev->mcast, 0, sizeof(struct sockaddr_storage));
  memset(&dev->server, 0, sizeof(struct sockaddr_storage));

  // ...

  if (setsockopt(
// zephyr
int oc_connectivity_init(size_t device)
{
    otError           error;
    struct otInstance *instance = openthread_get_default_instance();
    otSockAddr        sockaddr;

    memset(&socket, 0, sizeof(otUdpSocket));
    memset(&sockaddr, 0, sizeof(sockaddr));
    
    sockaddr.mPort = 5683; // CoAP port

    if (!otUdpIsOpen(instance, &socket))
    {
        error = otUdpOpen(instance, &socket, handle_udp_received, NULL);
        error = otUdpBind(instance, &socket, &sockaddr, OT_NETIF_THREAD);   
    }
}

Can't this port be working with Coap instead of OpenThread?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant