PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WM - Windev Mobile - Identificando o MacAddress e o IP do Celular usando os codigos nativos WL
WM - Windev Mobile - Identificando o MacAddress e o IP do Celular usando os codigos nativos WL
Débuté par adrianoboller, 03 oct. 2015 19:43 - 13 réponses
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 19:43
Wifi - WL codigo exemplo para testes = Exemplo: Android System - que acompanha o Windev Mobile





//Codigo Alterado no Exemplo

Wifi_MacAddress, wifi_All, wifi_BSSID, wifi_IdNetwork, wifi_Speed, wifi_IP_Address is string = ""

HourGlass(True)

IF WiFiStatus() = wifiDisabled THEN

// Enable the Wifi
WiFiActivate(True)

//Changes the display of the button
BTN_Activate = "Enabling in progress"
WHILE WiFiStatus() = wifiActivationInProgress OR WiFiStatus() = wifiDisabled

END

//Identificando dados do Wifi - MacAddress, IP e maiores detalhes

Wifi_MacAddress = WiFiConnectionInfo(wifiMacAddress)

wifi_All = WiFiConnectionInfo(wifiAll)

wifi_BSSID = WiFiConnectionInfo(wifiBSSID)

wifi_IdNetwork = WiFiConnectionInfo(wifiIdNetwork)

wifi_Speed = WiFiConnectionInfo(wifiSpeed)

wifi_IP_Address = WiFiConnectionInfo(wifiIPAddress)


Info(Wifi_MacAddress, wifi_All, wifi_BSSID, wifi_IdNetwork, wifi_Speed, wifi_IP_Address)


ELSE
// Disable the Wifi
WiFiActivate(False)

//Changes the display of the button
BTN_Activate = "Disabling in progress"
WHILE WiFiStatus() = wifiDeactivationInProgress OR WiFiStatus() = wifiEnabled

END

END

// Refreshes the window
Refresh()

HourGlass(False)


--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 20:01
Bluetooth - WL codigo exemplo para testes = Exemplo: Android System - que acompanha o Windev Mobile





//Bluetooth

HourGlass(True)

IF BTStatus() = btDisabled THEN
// Enable the bluetooth
BTActivate(True)

//Changes the display of the button
BTN_Activate = "Enabling in progress"
WHILE BTStatus() = btActivationInProgress OR BTStatus() = btDisabled

END

//Identificando dados do Wifi

sListDevices is string
sADevice is string
sId is string
sName is string
sMACAddress is string
// Clears the list
// Returns the list of the Bluetooth devices found nearby
sListDevices = BTListDevice(btSimpleList)
// Browse the connected devices
FOR EACH STRING sADevice OF sListDevices SEPARATED by CR
// Stores the device information
sId = ExtractString(sADevice, 1)
sName = ExtractString(sADevice, 3)
sMACAddress = ExtractString(sADevice, 2)

Info(sId, sName, sMACAddress)

END

ELSE
// Disable the bluetooth
BTActivate(False)

//Changes the display of the button
BTN_Activate = "Disabling in progress"
WHILE BTStatus() = btDeactivationInProgress OR BTStatus() = btEnabled

END
END

HourGlass(False)

// Refreshes the window
Refresh()


--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 20:05
Links de referencia:

//Wifi
http://doc.windev.com/en-US/search2.awp…
http://doc.windev.com/en-US/…
http://doc.windev.com/en-US/…
http://doc.windev.com/en-US/…


//Bluetooth
http://doc.windev.com/en-US/search2.awp…
http://doc.windev.com/…
http://doc.windev.com/…
http://doc.windev.com/…

--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 20:27
Obs.:

No momento só para o Android, devido a segurança reforçada e politicas da Apple essas informações deixaram de ser abertas.

http://doc.windev.com/en-US/…



Outras informações que podem ser obtidas do celular:

IMEI = http://doc.windev.com/en-US/… (apenas no Android) = SysIMEI ( )

SerialNumber = http://doc.windev.com/en-US/… (apenas no Android) = SysSerialNum( )



Informações do Sistema:

http://doc.windev.com/en-US/…
http://doc.windev.com/en-US/…
http://doc.windev.com/en-US/…

--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 20:36
Prezados,

Agora só para comparar se fosse fazer em java seria mais ou menos assim para descobrir o IP e o MACADDRESS do Celular:

/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package android.net.wifi;

import android.os.Parcelable;
import android.os.Parcel;
import android.net.NetworkInfo.DetailedState;
import android.net.NetworkUtils;

import java.net.InetAddress;
import java.net.Inet6Address;
import java.net.UnknownHostException;
import java.util.EnumMap;

/**
* Describes the state of any Wifi connection that is active or
* is in the process of being set up.
*/
public class WifiInfo implements Parcelable {
/**
* This is the map described in the Javadoc comment above. The positions
* of the elements of the array must correspond to the ordinal values
* of <code>DetailedState</code>.
*/
private static final EnumMap<SupplicantState, DetailedState> stateMap =
new EnumMap<SupplicantState, DetailedState>(SupplicantState.class);

static {
stateMap.put(SupplicantState.DISCONNECTED, DetailedState.DISCONNECTED);
stateMap.put(SupplicantState.INTERFACE_DISABLED, DetailedState.DISCONNECTED);
stateMap.put(SupplicantState.INACTIVE, DetailedState.IDLE);
stateMap.put(SupplicantState.SCANNING, DetailedState.SCANNING);
stateMap.put(SupplicantState.AUTHENTICATING, DetailedState.CONNECTING);
stateMap.put(SupplicantState.ASSOCIATING, DetailedState.CONNECTING);
stateMap.put(SupplicantState.ASSOCIATED, DetailedState.CONNECTING);
stateMap.put(SupplicantState.FOUR_WAY_HANDSHAKE, DetailedState.AUTHENTICATING);
stateMap.put(SupplicantState.GROUP_HANDSHAKE, DetailedState.AUTHENTICATING);
stateMap.put(SupplicantState.COMPLETED, DetailedState.OBTAINING_IPADDR);
stateMap.put(SupplicantState.DORMANT, DetailedState.DISCONNECTED);
stateMap.put(SupplicantState.UNINITIALIZED, DetailedState.IDLE);
stateMap.put(SupplicantState.INVALID, DetailedState.FAILED);
}

private SupplicantState mSupplicantState;
private String mBSSID;
private String mSSID;
private int mNetworkId;
private boolean mHiddenSSID;
/** Received Signal Strength Indicator */
private int mRssi;

/** Link speed in Mbps */
public static final String LINK_SPEED_UNITS = "Mbps";
private int mLinkSpeed;

private InetAddress mIpAddress;

private String mMacAddress;
private boolean mExplicitConnect;

WifiInfo() {
mSSID = null;
mBSSID = null;
mNetworkId = -1;
mSupplicantState = SupplicantState.UNINITIALIZED;
mRssi = -9999;
mLinkSpeed = -1;
mHiddenSSID = false;
mExplicitConnect = false;
}

/**
* Copy constructor
* @hide
*/
public WifiInfo(WifiInfo source) {
if (source != null) {
mSupplicantState = source.mSupplicantState;
mBSSID = source.mBSSID;
mSSID = source.mSSID;
mNetworkId = source.mNetworkId;
mHiddenSSID = source.mHiddenSSID;
mRssi = source.mRssi;
mLinkSpeed = source.mLinkSpeed;
mIpAddress = source.mIpAddress;
mMacAddress = source.mMacAddress;
mExplicitConnect = source.mExplicitConnect;
}
}

void setSSID(String SSID) {
mSSID = SSID;
// network is considered not hidden by default
mHiddenSSID = false;
}

/**
* Returns the service set identifier (SSID) of the current 802.11 network.
* If the SSID is an ASCII string, it will be returned surrounded by double
* quotation marks.Otherwise, it is returned as a string of hex digits. The
* SSID may be {@code null} if there is no network currently connected.
* @return the SSID
*/
public String getSSID() {
return mSSID;
}

void setBSSID(String BSSID) {
mBSSID = BSSID;
}

/**
* Return the basic service set identifier (BSSID) of the current access point.
* The BSSID may be {@code null} if there is no network currently connected.
* @return the BSSID, in the form of a six-byte MAC address: {@code XX:XX:XX:XX:XX:XX}
*/
public String getBSSID() {
return mBSSID;
}

/**
* Returns the received signal strength indicator of the current 802.11
* network.
* <p><strong>This is not normalized, but should be!</strong></p>
* @return the RSSI, in the range ??? to ???
*/
public int getRssi() {
return mRssi;
}

void setRssi(int rssi) {
mRssi = rssi;
}

/**
* Returns the current link speed in {@link #LINK_SPEED_UNITS}.
* @return the link speed.
* @see #LINK_SPEED_UNITS
*/
public int getLinkSpeed() {
return mLinkSpeed;
}

void setLinkSpeed(int linkSpeed) {
this.mLinkSpeed = linkSpeed;
}

/**
* Record the MAC address of the WLAN interface
* @param macAddress the MAC address in {@code XX:XX:XX:XX:XX:XX} form
*/
void setMacAddress(String macAddress) {
this.mMacAddress = macAddress;
}

public String getMacAddress() {
return mMacAddress;
}

void setNetworkId(int id) {
mNetworkId = id;
}


/**
* @hide
*/
public boolean isExplicitConnect() {
return mExplicitConnect;
}

/**
* @hide
*/
public void setExplicitConnect(boolean explicitConnect) {
this.mExplicitConnect = explicitConnect;
}


/**
* Each configured network has a unique small integer ID, used to identify
* the network when performing operations on the supplicant. This method
* returns the ID for the currently connected network.
* @return the network ID, or -1 if there is no currently connected network
*/
public int getNetworkId() {
return mNetworkId;
}

/**
* Return the detailed state of the supplicant's negotiation with an
* access point, in the form of a {@link SupplicantState SupplicantState} object.
* @return the current {@link SupplicantState SupplicantState}
*/
public SupplicantState getSupplicantState() {
return mSupplicantState;
}

void setSupplicantState(SupplicantState state) {
mSupplicantState = state;
}

void setInetAddress(InetAddress address) {
mIpAddress = address;
}

public int getIpAddress() {
if (mIpAddress == null || mIpAddress instanceof Inet6Address) return 0;
return NetworkUtils.inetAddressToInt(mIpAddress);
}

/**
* @return {@code true} if this network does not broadcast its SSID, so an
* SSID-specific probe request must be used for scans.
*/
public boolean getHiddenSSID() {
return mHiddenSSID;
}

/** {@hide} */
public void setHiddenSSID(boolean hiddenSSID) {
mHiddenSSID = hiddenSSID;
}

/**
* Map a supplicant state into a fine-grained network connectivity state.
* @param suppState the supplicant state
* @return the corresponding {@link DetailedState}
*/
public static DetailedState getDetailedStateOf(SupplicantState suppState) {
return stateMap.get(suppState);
}

/**
* Set the <code>SupplicantState</code> from the string name
* of the state.
* @param stateName the name of the state, as a <code>String</code> returned
* in an event sent by {@code wpa_supplicant}.
*/
void setSupplicantState(String stateName) {
mSupplicantState = valueOf(stateName);
}

static SupplicantState valueOf(String stateName) {
if ("4WAY_HANDSHAKE".equalsIgnoreCase(stateName))
return SupplicantState.FOUR_WAY_HANDSHAKE;
else {
try {
return SupplicantState.valueOf(stateName.toUpperCase());
} catch (IllegalArgumentException e) {
return SupplicantState.INVALID;
}
}
}

@Override
public String toString() {
StringBuffer sb = new StringBuffer();
String none = "<none>";

sb.append("SSID: ").append(mSSID == null ? none : mSSID).
append(", BSSID: ").append(mBSSID == null ? none : mBSSID).
append(", MAC: ").append(mMacAddress == null ? none : mMacAddress).
append(", Supplicant state: ").
append(mSupplicantState == null ? none : mSupplicantState).
append(", RSSI: ").append(mRssi).
append(", Link speed: ").append(mLinkSpeed).
append(", Net ID: ").append(mNetworkId).
append(", Explicit connect: ").append(mExplicitConnect);

return sb.toString();
}

/** Implement the Parcelable interface {@hide} */
public int describeContents() {
return 0;
}

/** Implement the Parcelable interface {@hide} */
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mNetworkId);
dest.writeInt(mRssi);
dest.writeInt(mLinkSpeed);
if (mIpAddress != null) {
dest.writeByte((byte)1);
dest.writeByteArray(mIpAddress.getAddress());
} else {
dest.writeByte((byte)0);
}
dest.writeString(getSSID());
dest.writeString(mBSSID);
dest.writeString(mMacAddress);
dest.writeByte(mExplicitConnect ? (byte)1 : (byte)0);
mSupplicantState.writeToParcel(dest, flags);
}

/** Implement the Parcelable interface {@hide} */
public static final Creator<WifiInfo> CREATOR =
new Creator<WifiInfo>() {
public WifiInfo createFromParcel(Parcel in) {
WifiInfo info = new WifiInfo();
info.setNetworkId(in.readInt());
info.setRssi(in.readInt());
info.setLinkSpeed(in.readInt());
if (in.readByte() == 1) {
try {
info.setInetAddress(InetAddress.getByAddress(in.createByteArray()));
} catch (UnknownHostException e) {}
}
info.setSSID(in.readString());
info.mBSSID = in.readString();
info.mMacAddress = in.readString();
info.mExplicitConnect = in.readByte() == 1 ? true : false;
info.mSupplicantState = SupplicantState.CREATOR.createFromParcel(in);
return info;
}

public WifiInfo[] newArray(int size) {
return new WifiInfo[size];
}
};
}


////

Compare os dois codigos e analise qual é mais facil de dar suporte.

Ahhhh.... não esqueça que não pode esquecer de por os ponto e virgulas em todas as linhas.

Acho que agora entenderam por que eu gosto tanto da PcSoft.

Bom final de semana a todos.

--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 20:47
Prezados,

Para o iOS (iPhone, iPads,...) e ate mesmo para o Android...

Confirmar e habilitar a aplicação fazendo da seguintes maneiras:

1 - abre-se o cadastro na primeira tela com eail ou numero do telefone

2 - ao salvar manda por webservice ou sqlconectws o cadastro para o seu banco de dados que esta online na internet

3 - o banco recebe os dados e envia um email ou um sms para o usuario com uma chave randomica que foi colocada no registro do usuario

4 - o usuario recebe o email, sms e informa o seu código ID de autorização em uma tela, que pos sua vez grava na base de dados SQLite ou Hiperfile esse codigo.

5 - em todas as requisições será comparado o token local com o token remoto se identicos os cadastros e status ATIVO, processa normalmente.

Obs.: Para o Banco de dados mandar emails, no caso do MSSQL ele possui um recurso chamado "DatabaseMail", é incrivel vale a pena conhecer, uso e recomendo, façam uma busca no Google e no Youtube e verá que ferramenta incrivel aliada as suas soluções.

--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 21:03
ABOUT Example Android System

This application is a tutorial example presenting some of the new features of WinDev Mobile for Android.
The following system functions are used:

- NFC
- Multimedia control
- Brightness
- Volume
- WIFI
- Bluetooth
- Toast
- Progress Bar control
- 9-image mode
- Compass
- Accelerometer
- Camera control
- LED
- Vibrations
- Notifications
- Drawing functions
- Internet


MacAddress Localizado com o primeiro comando desse post:





--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 23:22
MacAddress Localizado do Bluetooth com o primeiro comando desse post:





--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 05 octobre 2015 - 19:07
Procedure GetMacAddress()

Wifi_MacAddress is string =""

IF InAndroidMode() = True THEN

IF WiFiStatus() = wifiEnabled THEN

Wifi_MacAddress = WiFiConnectionInfo(wifiMacAddress)

END

END

RESULT (Wifi_MacAddress)


--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 05 octobre 2015 - 19:36
Procedure MeuIpFixo()

// function showInfos(){
//setTimeout('document.getElementById("div_ip").innerHTML = "177.6.166.73"', 1000);
//setTimeout('document.getElementById("div_reverso").innerHTML = "4130757575.e.brasiltelecom.net.br"', 2000);
//setTimeout('document.getElementById("div_provedor").innerHTML = "VELOX"', 3000);
//
//}

nInicioBloco, nFinalBloco is int = 0

IP is string = ""

Url is string = "http://www.meuip.com.br/"

HTTPTimeOut(5000)

HTTPRequest(Url)

bufRetorno is Buffer = HTTPGetResult(httpResult)

bufRetorno = Replace(bufRetorno,Charact(34),"")

bufRetorno = Replace(bufRetorno,"'","")

//info(bufRetorno)

nInicioBloco = PositionOccurrence(bufRetorno,"document.getElementById(div_ip).innerHTML = ",firstRank,FromBeginning) + Length("document.getElementById(div_ip).innerHTML = ")

//Info(bufRetorno)

IF nInicioBloco > 0 THEN

//document.getElementById(div_ip).innerHTML = 177.6.166.73, 1000);
// setTimeout(document.getElementById(div_reverso).innerHTML = 4130757575.e.brasiltelecom.net.br, 2000);
//setTimeout(document.getElementById(div_provedor).innerHTML = VELOX, 3000);
//
// }
// </script>
//
// <div align=left ><br>
// <H1><b>      Meu IP: <div id=div_ip style=display:inline><!--<span class=style1> detectando (IPv4 ou IPv6)...</span>--> 177.6.166.73 </div> </b>

bufRetorno = Middle(bufRetorno,nInicioBloco,1000)

IF nInicioBloco > 0
bufRetorno = Middle(bufRetorno,1,20)
END

//Info(bufRetorno)

ELSE

// <div align=left ><br>
// <H1><b>      Meu IP: <div id=div_ip style=display:inline><!--<span class=style1> detectando (IPv4 ou IPv6)...</span>--> 177.6.166.73 </div> </b>

nInicioBloco = PositionOccurrence(bufRetorno,"<span class=style1> detectando (IPv4 ou IPv6)...</span>-->",firstRank,FromBeginning) + Length("<span class=style1> detectando (IPv4 ou IPv6)...</span>-->")

IF nInicioBloco > 0
bufRetorno = Middle(bufRetorno,nInicioBloco,20)
END

//Info(bufRetorno)

END


//192.168.1.180, 1000);

IF bufRetorno <> ""

nFinalBloco = PositionOccurrence(bufRetorno,",",firstRank,FromBeginning) - 1

IF nFinalBloco > 0 THEN
bufRetorno = Middle(bufRetorno,1,nFinalBloco)
END

END

bufRetorno = Replace(bufRetorno,"=","")

bufRetorno = NoSpace(bufRetorno)

IP = NoSpace(bufRetorno)

RESULT(IP)


--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 18 septembre 2017 - 15:38
SysImei to iOS

tapiDialerCall("*#06#")


https://stackoverflow.com/questions/19927160/finding-imei-number-using-objective-c

you cant get IMEI code but can use uuid. thats unique

in swift 2
let DeviceID = UIDevice.currentDevice().identifierForVendor!.UUIDString


and in swift 3
let DeviceID = UIDevice.current.identifierForVendor!.uuidString


Outra saida é pegar o macadress da placa de rede wifi ou bluethoot do celular

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 18 septembre 2017 - 18:51
arp -a = macaddress 
https://stackoverflow.com/questions/39294726/proccess-command-arp-a-on-android
try {

        Process process = Runtime.getRuntime().exec("arp -a");
        process.waitFor();
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        int i = 0;
        while (reader.ready()) {
            i++;
            String ip = reader.readLine();
            if (i >= 4) {
                ip = ip.substring(2, 15) + "\n";
            }
        }
    } catch (IOException | InterruptedException ioe) {
        ioe.printStackTrace();
    }

​mac address in iOS

​https://stackoverflow.com/questions/31226522/ios-get-arp-table

I finally got it working so I will post the procedure in detail to save some time for other guys:

Go to Applications and right click on Xcode -> Show package contents and browse to: Developer ▸ Platforms ▸ MacOSX.platform ▸ Developer ▸ SDKs ▸ MacOSX10.10.sdk ▸ usr ▸ include. From "net" folder copy the route.h and if_types.h and from the "netinet" folder copy the if_ether.h into your Xcode project.
Then import the following .m and .h files:
MacFinder.h

#import 
#include 
#include 
#include 
#include 

#include 
#include 
#include "if_types.h"

#if TARGET_IPHONE_SIMULATOR
#include 
#else
#include "route.h"
#endif

#include "if_ether.h"
#include 


#include 

#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 

@interface MacFinder : NSObject{

    int nflag;
}

-(NSString*) ip2mac: (char*)ip;

@end
MacFinder.m

#import "MacFinder.h"

@implementation MacFinder
-(NSString*) ip2mac: (char*)ip
{
    int  found_entry = 0;



    NSString *mAddr = nil;
    u_long addr = inet_addr(ip);
    int mib[6];
    size_t needed;
    char *host, *lim, *buf, *next;
    struct rt_msghdr *rtm;
    struct sockaddr_inarp *sin;
    struct sockaddr_dl *sdl;
    extern int h_errno;
    struct hostent *hp;

    mib[0] = CTL_NET;
    mib[1] = PF_ROUTE;
    mib[2] = 0;
    mib[3] = AF_INET;
    mib[4] = NET_RT_FLAGS;
    mib[5] = RTF_LLINFO;
    if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
        err(1, "route-sysctl-estimate");
    if ((buf = malloc(needed)) == NULL)
        err(1, "malloc");
    if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
        err(1, "actual retrieval of routing table");


    lim = buf + needed;
    for (next = buf; next < lim; next += rtm->rtm_msglen) {
        rtm = (struct rt_msghdr *)next;
        sin = (struct sockaddr_inarp *)(rtm + 1);
        sdl = (struct sockaddr_dl *)(sin + 1);
        if (addr) {
            if (addr != sin->sin_addr.s_addr)
                continue;
            found_entry = 1;
        }
        if (nflag == 0)
            hp = gethostbyaddr((caddr_t)&(sin->sin_addr),
                               sizeof sin->sin_addr, AF_INET);
        else
            hp = 0;
        if (hp)
            host = hp->h_name;
        else {
            host = "?";
            if (h_errno == TRY_AGAIN)
                nflag = 1;
        }



        if (sdl->sdl_alen) {

            u_char *cp = LLADDR(sdl);

            mAddr = [NSString stringWithFormat:@"%x:%x:%x:%x:%x:%x", cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]];


            //  ether_print((u_char *)LLADDR(sdl));
        }
        else

            mAddr = nil;



    }


    if (found_entry == 0) {
        return nil;
    } else {
        return mAddr;
    }




}
@end
Then import the MacFinder.h file in your ViewController
Example how to use it for each host you want to find the MAC Address:
MacFinder *mc = [[MacFinder alloc]init];
NSString *mac = [mc ip2mac:"192.168.10.24"]; 

NSLog(@"Mac:%@",mac);

https://github.com/mavris/MacFinder  
fonts

http://www.dltec.com.br/blog/redes/descobrir-o-mac-de-um-host/
​​
Merci​


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 18 septembre 2017 - 21:21
arp -a = macaddress
https://stackoverflow.com/questions/39294726/proccess-command-arp-a-on-android
try {

Process Process = Runtime.getRuntime().exec("arp -a");
Process.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(Process.getInputStream()));
int i = 0;
WHILE (reader.ready()) {
i++;
string ip = reader.readLine();
IF (i >= 4) {
ip = ip.substring(2, 15) + "\n";
}
}
} catch (IOException | InterruptedException ioe) {
ioe.printStackTrace();
}

?mac Address IN iOS

?https://stackoverflow.com/questions/31226522/ios-get-arp-table

I finally got it working so I will Post the Procedure IN detail to save some time for other guys:

Go to Applications AND Right click on Xcode -> Show package contents AND browse to: Developer ? Platforms ? MacOSX.platform ? Developer ? SDKs ? MacOSX10.10.sdk ? usr ? include. From "net" folder copy the route.h AND if_types.h AND from the "netinet" folder copy the if_ether.h into your Xcode project.
THEN import the following .m AND .h files:
MacFinder.h

#import <Foundation/Foundation.h>
#include <sys/param.h>
#include <sys/File.h>
#include <sys/socket.h>
#include <sys/sysctl.h>

#include <net/IF.h>
#include <net/if_dl.h>
#include "if_types.h"

#if TARGET_IPHONE_SIMULATOR
#include <net/route.h>
#else
#include "route.h"
#endif

#include "if_ether.h"
#include <netinet/IN.h>


#include <arpa/inet.h>

#include <err.h>
#include <errno.h>
#include <netdb.h>

#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

@interface MacFinder : NSObject{

int nflag;
}

-(NSString*) ip2mac: (char*)ip;

@END
MacFinder.m

#import "MacFinder.h"

@implementation MacFinder
-(NSString*) ip2mac: (char*)ip
{
int found_entry = 0;



NSString *mAddr = nil;
u_long addr = inet_addr(ip);
int mib[6];
size_t needed;
char *host, *lim, *buf, *next;
struct rt_msghdr *rtm;
struct sockaddr_inarp *Sin;
struct sockaddr_dl *sdl;
EXTERN int h_errno;
struct hostent *hp;

mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0;
mib[3] = AF_INET;
mib[4] = NET_RT_FLAGS;
mib[5] = RTF_LLINFO;
IF (sysctl(mib, 6, Null, &needed, Null, 0) < 0)
err(1, "route-sysctl-estimate");
IF ((buf = malloc(needed)) == Null)
err(1, "malloc");
IF (sysctl(mib, 6, buf, &needed, Null, 0) < 0)
err(1, "actual retrieval of routing table");


lim = buf + needed;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
Sin = (struct sockaddr_inarp *)(rtm + 1);
sdl = (struct sockaddr_dl *)(Sin + 1);
IF (addr) {
IF (addr != Sin->sin_addr.s_addr)
CONTINUE;
found_entry = 1;
}
IF (nflag == 0)
hp = gethostbyaddr((caddr_t)&(Sin->sin_addr),
sizeof Sin->sin_addr, AF_INET);
ELSE
hp = 0;
IF (hp)
host = hp->h_name;
ELSE {
host = "?";
IF (h_errno == TRY_AGAIN)
nflag = 1;
}



IF (sdl->sdl_alen) {

u_char *cp = LLADDR(sdl);

mAddr = [NSString stringWithFormat:@"%x:%x:%x:%x:%x:%x", cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]];


// ether_print((u_char *)LLADDR(sdl));
}
ELSE

mAddr = nil;



}


IF (found_entry == 0) {
RETURN nil;
} ELSE {
RETURN mAddr;
}




}
@END
THEN import the MacFinder.h File IN your ViewController
Example how to Use it for each host you want to find the MAC Address:
MacFinder *mc = [[MacFinder alloc]init];
NSString *mac = [mc ip2mac:"192.168.10.24"];

NSLog(@"Mac:%@",mac);


https://github.com/mavris/MacFinder
fonts

http://www.dltec.com.br/blog/redes/descobrir-o-mac-de-um-host/


:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Posté le 09 décembre 2017 - 22:54
Good Night, Boller.

I saw, about many many resolutions explained for you to start the Others Apps its like Calc for exemple and others Apps, using the one main App build for us.

However, you not explain how stop one this Apps (outside main app), because the App have one function to active others apps, but how i will stop this same openeds Apps? For example: Its possivel start the Calc App or Google Maps Apps across the command line below:

bStarted is boolean
// Starts the application
bStarted = ExeRun("com.google.android.apps.maps")

But my main doubt is: Its possible create onde button inside in the parent application that to close this same application that my app its open in lost? Please, tell me about one solution that i can use for this.

Thank you, and congratulations for all the help us and for your especial informations.

Willy