如何从不同设备上的Wifi获取RSSI值?

huangapple 未分类评论48阅读模式
英文:

How to get RSSI value from Wifi on different device?

问题

private class HostsAdapter extends ArrayAdapter<Void> {
    public HostsAdapter(Context ctxt) {
        super(ctxt, R.layout.list_host, R.id.list);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        View view = convertView;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.list_host, null);
            holder = new ViewHolder();
            holder.host = (TextView) convertView.findViewById(R.id.list);
            holder.mac = (TextView) convertView.findViewById(R.id.mac);
            holder.vendor = (TextView) convertView.findViewById(R.id.vendor);
            holder.logo = (ImageView) convertView.findViewById(R.id.logo);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        final HostBean host = hosts.get(position);
        if (host.deviceType == HostBean.TYPE_GATEWAY) {
            holder.logo.setImageResource(R.drawable.router);
        } else if (host.isAlive == 1 || !host.hardwareAddress.equals(NetInfo.NOMAC)) {
            holder.logo.setImageResource(R.drawable.computer);
        } else {
            holder.logo.setImageResource(R.drawable.computer);
        }
        if (host.hostname != null && !host.hostname.equals(host.ipAddress) && !host.hostname.equals(host.rssi)) {
            holder.host.setText(host.hostname + " (" + host.ipAddress + ")");
        } else {
            holder.host.setText(host.ipAddress);
        }
        if (!host.hardwareAddress.equals(NetInfo.NOMAC)) {
            holder.mac.setText(host.hardwareAddress);
            if(host.nicVendor != null){
                holder.vendor.setText(host.nicVendor);
            } else {
                holder.vendor.setText(R.string.info_unknown);
            }
            holder.mac.setVisibility(View.VISIBLE);
            holder.vendor.setVisibility(View.VISIBLE);
        } else {
            holder.mac.setVisibility(View.GONE);
            holder.vendor.setVisibility(View.GONE);
        }

        return convertView;
    }
}
英文:

> Hello, i have new project about indoor positioning. After detect users and get ip address and mac from device who connect in Router, so i'm confused how to get rssi value on that users. Is possible right? Somebody pls help me 如何从不同设备上的Wifi获取RSSI值? this is my thesis, thankyouu

I used android studio btw.. This is my code to display ip address, mac, and SSID device who connect to wifi

private class HostsAdapter extends ArrayAdapter&lt;Void&gt; {
    public HostsAdapter(Context ctxt) {
        super(ctxt, R.layout.list_host, R.id.list);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        View view = convertView;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.list_host, null);
            holder = new ViewHolder();
            holder.host = (TextView) convertView.findViewById(R.id.list);
            holder.mac = (TextView) convertView.findViewById(R.id.mac);
            holder.vendor = (TextView) convertView.findViewById(R.id.vendor);
            holder.logo = (ImageView) convertView.findViewById(R.id.logo);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        final HostBean host = hosts.get(position);
        if (host.deviceType == HostBean.TYPE_GATEWAY) {
            holder.logo.setImageResource(R.drawable.router);
        } else if (host.isAlive == 1 || !host.hardwareAddress.equals(NetInfo.NOMAC)) {
            holder.logo.setImageResource(R.drawable.computer);
        } else {
            holder.logo.setImageResource(R.drawable.computer);
        }
        if (host.hostname != null &amp;&amp; !host.hostname.equals(host.ipAddress) &amp;&amp; !host.hostname.equals(host.rssi)) {
            holder.host.setText(host.hostname + &quot; (&quot; + host.ipAddress + &quot;)&quot;);
        } else {
            holder.host.setText(host.ipAddress);
        }
        if (!host.hardwareAddress.equals(NetInfo.NOMAC)) {
            holder.mac.setText(host.hardwareAddress);
            if(host.nicVendor != null){
                holder.vendor.setText(host.nicVendor);
            } else {
                holder.vendor.setText(R.string.info_unknown);
            }
            holder.mac.setVisibility(View.VISIBLE);
            holder.vendor.setVisibility(View.VISIBLE);
        } else {
            holder.mac.setVisibility(View.GONE);
            holder.vendor.setVisibility(View.GONE);
        }

        return convertView;
    }
}

huangapple
  • 本文由 发表于 2020年4月9日 18:39:13
  • 转载请务必保留本文链接:https://java.coder-hub.com/61119262.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定