Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    R128 WIFI AP模式获取连接设备的IP地址的问题

    A Series
    2
    7
    4874
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mxf4511 LV 3 last edited by

      R128的WIFI在AP模式下,其它设备连接这个WIFI,怎么在R128这边获取到分配给连接设备的IP地址呢?
      官方的文档里没看到有提到具体方法,代码里水平有限也找不到接口

      1 Reply Last reply Reply Quote Share 0
      • A
        awwwwa LV 8 last edited by

        wifi_ap_get_config(wifi_ap_config_t * ap_config)

        可以参考 wifi ‑l 的实现

        M 1 Reply Last reply Reply Quote Share 0
        • M
          Mxf4511 LV 3 @awwwwa last edited by

          @awwwwa wifi -l ap 这个指令我也试过了,它调用的就是wifi_ap_get_config()来获取,它返回的ap的地址是对的,但是返回的sta信息好像是mac地址,不是ip地址.
          而且很奇怪,我明明只有一个设备连接,但是获取到的sta_num却有4个fddb13d1-5f75-43b1-9aae-8e786130ff5e-776a6ff61c8688fd37761be52c3108b.png

          A 1 Reply Last reply Reply Quote Share 0
          • A
            awwwwa LV 8 @Mxf4511 last edited by

            @mxf4511 如果AP模式需要获取IP地址应该使用上层的网络协议栈来分配,例如DHCP服务

            M 1 Reply Last reply Reply Quote Share 0
            • M
              Mxf4511 LV 3 @awwwwa last edited by

              @awwwwa LWIP找了几天,没有找到dhcp服务端获取已分配ip的例子,可以提供一个简单的例子吗?

              1 Reply Last reply Reply Quote Share 0
              • A
                awwwwa LV 8 last edited by

                AP的数据是在 lwip 的 static struct etharp_entry arp_table[ARP_TABLE_SIZE]; 中维护

                #if LWIP_XR_IMPL
                ip4_addr_t* etharp_get_ip_from_mac(struct eth_addr *ethaddr) {
                  int i;
                  ip4_addr_t* ip_ret = NULL;
                
                  LWIP_ASSERT("ethaddr != NULL", ethaddr != NULL);
                
                  for (i = 0; i < ARP_TABLE_SIZE; i++) {
                    if (memcmp(ethaddr, &arp_table[i].ethaddr, sizeof(struct eth_addr)) == 0) {
                      ip_ret = &arp_table[i].ipaddr;
                      break;
                    }
                  }
                
                  return ip_ret;
                }
                #endif
                
                M 1 Reply Last reply Reply Quote Share 0
                • M
                  Mxf4511 LV 3 @awwwwa last edited by

                  @awwwwa 好的,感谢我试试

                  1 Reply Last reply Reply Quote Share 0
                  • 1 / 1
                  • First post
                    Last post

                  Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

                  行为准则 | 用户协议 | 隐私权政策