MT7620 Openwrt 下开发获取wifi信号强度。

子妙815 2015-04-08 03:17:29
根据网上的例子,在使用 ioctl(skfd, SIOCGIFCONF, &ifc)时 返回了-1 提示不支持。请问怎么回事啊?
...全文
4895 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
强者最帅 2016-05-20
  • 打赏
  • 举报
回复
哪位成功了啊
bearkuan 2015-05-01
  • 打赏
  • 举报
回复
你成功了吗?
子妙815 2015-04-11
  • 打赏
  • 举报
回复
自己给自己顶一下
子妙815 2015-04-08
  • 打赏
  • 举报
回复
#include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <linux/wireless.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <netinet/in.h> #include <unistd.h> /* The name of the interface */ #ifndef IW_NAME #define IW_NAME "eth1" #endif /**************************** 无线设备的这些信息通过iw_statistics结构进行保存,通过get_wireless_stats函数获取。 struct iw_statistics { __u16 status; //* Status * - device dependent for now struct iw_quality qual; //* Quality of the link * (instant/mean/max) struct iw_discarded discard; //* Packet discarded counts struct iw_missed miss; //* Packet missed counts }; ****************************/ int main() { int sockfd; struct iw_statistics stats; struct iwreq req; memset(&stats, 0, sizeof(stats)); memset(&req, 0, sizeof(iwreq)); sprintf(req.ifr_name, "wlan0"); req.u.data.pointer = &stats; req.u.data.length = sizeof(iw_statistics); #ifdef CLEAR_UPDATED req.u.data.flags = 1; #endif /* Any old socket will do, and a datagram socket is pretty cheap */ while(1) { if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) //#define AF_INET 2 // internetwork: UDP, TCP, etc. { //数据报套接字类型为SOCK_DGRAM 0:应使用的传输层协议 perror("Could not create simple datagram socket"); exit(EXIT_FAILURE); } /* Perform the ioctl */ if(ioctl(sockfd, SIOCGIWSTATS, &req) == -1) { perror("Error performing SIOCGIWSTATS"); close(sockfd); exit(EXIT_FAILURE); } close(sockfd); printf("Signal level%s is %d%s.\n",(stats.qual.updated & IW_QUAL_DBM ? " (in dBm)" :""),(signed char)stats.qual.level, (stats.qual.updated & IW_QUAL_LEVEL_UPDATED ? " (updated)" :"")); sleep(1); } return 0; } 这是我的源代码。在红色的字体。

3,846

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 无线
社区管理员
  • 无线
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧