Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi

I am using Brew 3.1.5 and the Brew Simluator 3.1.5.179

I am trying to create a UDP socket to receive UDP messages

The following code returns 0.0.0.0. Why ?

char pc[16];

INAddr ipAddress = INETMGR_GetMyIPAddr(pINetMgr);

INET_NTOA( ipAddress, pc, sizeof(pc));

DBGPRINTF("ip address is %08x, %s",ipAddress, pc);

=> returns - pc 0x0013f010 "0.0.0.0"Then Binding fails with error 554Thank you for your help

Hi, 
Have you established data-connection prior to the above calls?
-Herojit
 

Hi, 
Have you established data-connection prior to the above calls?
-Herojit
 

you first need to bind the socket then get your IP address. By default there is no IP associated to a mobile or simulator untill its on a data call.
 
ISockPort *pSockPort;
AEECallback readCB;

boolean UDPSockBind(mySms *pMe)
{

AEESockAddrStorage sockAddr;
sockAddr.wFamily = AEE_AF_INET;
sockAddr.inet.port = HTONS(22);
sockAddr.inet.addr = AEE_INADDR_ANY;
int nErr;

if(!pMe->pSockPort) {
if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SOCKPORT, (void**)&pMe->pSockPort) != SUCCESS)
return FALSE;

nErr = ISOCKPORT_OpenEx(pMe->pSockPort, AEE_AF_INET, AEE_SOCKPORT_DGRAM, AEE_IPPROTO_UDP);
if(nErr != SUCCESS)
return FALSE;
}

// ret = ISockPort_OpenEx(pMe->m_pIReceiveSockPort, AEE_AF_INET, AEE_SOCKPORT_DGRAM,0);
DBGPRINTF("*******UDPSOCKBind Called");

nErr = ISOCKPORT_Bind( pMe->pSockPort, &sockAddr);
if (ISOURCE_WAIT == nErr)
{
DBGPRINTF("*******Socket BIND Waiting");
ISOCKPORT_WriteableEx(pMe->pSockPort, &pMe->readCB, UDPSockBind, pMe);
return 0;
}
if (SUCCESS == nErr)
{
DBGPRINTF("*******Socket BIND Success");
// TryToReceiveUDPPacket(pMe);
}

getMyIP(pMe);

// .. handle errors
return 0;

void getMyIP(mySms *pMe)
{
INAddr addr;
INetwork *pNetwork;
INetMgr *pNetMgr = NULL;
char str[20];

int pNumAddr = 1;
IPAddr aipaAddr[1];

if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_NET, (void**)&pNetMgr) != SUCCESS) {
return;
}

addr = INETMGR_GetMyIPAddr(pNetMgr);

INET_NTOA(addr, str, sizeof(str));
 
the default IP returned is 127.0.0.1, if no IP is configured on the system.
if the system is on LAN, the IP configured/assigned to the local system would be returned.
if the key "IPAddress" is set in the [Settings] section of BREW_Emu.dat, this IP would be returned for all cases.

you first need to bind the socket then get your IP address. By default there is no IP associated to a mobile or simulator untill its on a data call.
 
ISockPort *pSockPort;
AEECallback readCB;

boolean UDPSockBind(mySms *pMe)
{

AEESockAddrStorage sockAddr;
sockAddr.wFamily = AEE_AF_INET;
sockAddr.inet.port = HTONS(22);
sockAddr.inet.addr = AEE_INADDR_ANY;
int nErr;

if(!pMe->pSockPort) {
if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SOCKPORT, (void**)&pMe->pSockPort) != SUCCESS)
return FALSE;

nErr = ISOCKPORT_OpenEx(pMe->pSockPort, AEE_AF_INET, AEE_SOCKPORT_DGRAM, AEE_IPPROTO_UDP);
if(nErr != SUCCESS)
return FALSE;
}

// ret = ISockPort_OpenEx(pMe->m_pIReceiveSockPort, AEE_AF_INET, AEE_SOCKPORT_DGRAM,0);
DBGPRINTF("*******UDPSOCKBind Called");

nErr = ISOCKPORT_Bind( pMe->pSockPort, &sockAddr);
if (ISOURCE_WAIT == nErr)
{
DBGPRINTF("*******Socket BIND Waiting");
ISOCKPORT_WriteableEx(pMe->pSockPort, &pMe->readCB, UDPSockBind, pMe);
return 0;
}
if (SUCCESS == nErr)
{
DBGPRINTF("*******Socket BIND Success");
// TryToReceiveUDPPacket(pMe);
}

getMyIP(pMe);

// .. handle errors
return 0;

void getMyIP(mySms *pMe)
{
INAddr addr;
INetwork *pNetwork;
INetMgr *pNetMgr = NULL;
char str[20];

int pNumAddr = 1;
IPAddr aipaAddr[1];

if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_NET, (void**)&pNetMgr) != SUCCESS) {
return;
}

addr = INETMGR_GetMyIPAddr(pNetMgr);

INET_NTOA(addr, str, sizeof(str));
 
the default IP returned is 127.0.0.1, if no IP is configured on the system.
if the system is on LAN, the IP configured/assigned to the local system would be returned.
if the key "IPAddress" is set in the [Settings] section of BREW_Emu.dat, this IP would be returned for all cases.

So when I bind the socket, how long will the data connection remain open?

So when I bind the socket, how long will the data connection remain open?

Does anyone know the answer here?

Does anyone know the answer here?

until device linger timeout.

until device linger timeout.

What does the pMe structure look like here?  The pMe structure I have is for UART communication also and does not have some of the data types listed in the code.
 
Can I use the same piShell for the UART port and the WLAN connection?  Can I use the same pMe structure for UART and WLAN communications?
 
Do I need to run a different applet for the WLAN communications?  If so, how do I pass variables between the two applets?

What does the pMe structure look like here?  The pMe structure I have is for UART communication also and does not have some of the data types listed in the code.
 
Can I use the same piShell for the UART port and the WLAN connection?  Can I use the same pMe structure for UART and WLAN communications?
 
Do I need to run a different applet for the WLAN communications?  If so, how do I pass variables between the two applets?

This code crashes the module and resets it. The UART_TEST id is used to create a different piShell earlier in the program, is this a problem? if(ISHELL_CreateInstance(up->piShellWLAN, AEECLSID_UART_TEST, (void**)&pNetMgr) != SUCCESS) {
return;
}

This code crashes the module and resets it. The UART_TEST id is used to create a different piShell earlier in the program, is this a problem? if(ISHELL_CreateInstance(up->piShellWLAN, AEECLSID_UART_TEST, (void**)&pNetMgr) != SUCCESS) {
return;
}

i could not find AEECLSID_UART_TEST. wats that? it may be a reason.
 
the pMe->a.m_pIShell being shown in example is a member of the AEEApplet from which your Applet should be derived.

i could not find AEECLSID_UART_TEST. wats that? it may be a reason.
 
the pMe->a.m_pIShell being shown in example is a member of the AEEApplet from which your Applet should be derived.