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

Developer

Forums

Forums:

I am using Motorola BQ50.
Brew SDK 3.1.3

static void WebAction_GotResp( void *p )
{
WebAction *pwa = ( WebAction * )p;
MIApp * pApp = pwa->pParent;
WebRespInfo *pwri;

int result;
pwri = IWEBRESP_GetInfo(pwa->piWResp);
pApp->resCode = pwri->nCode;

if (( ISource * )0 != pwri->pisMessage)
{
..........
}
.............

if i run application using simulator it get successfully run.
But if i run it on device i get pwri->nCode = -544.

I set url to static ip. what other necessary setup to set web request on device.

void GotResponse(CAppStruct * pApp)
{
int nByteCount = 0;
char * szBuffer=NULL;
WebRespInfo * m_pWebRespInfo = NULL;
boolean bError=FALSE;
if(!pApp->m_pHttp[2].m_bWeb)
return;
szBuffer=(char*)MALLOC(1024*sizeof(char));
m_pWebRespInfo = IWEBRESP_GetInfo(pApp->m_pHttp[2].m_pIWebResp);
if(!m_pWebRespInfo)
{
FREEIF(szBuffer);
return;
}
DBGPRINTF("code=%d",m_pWebRespInfo->nCode);
if(m_pWebRespInfo && WEB_ERROR_SUCCEEDED(m_pWebRespInfo->nCode))
{
int nContentlength;
ISource* m_pISource = m_pWebRespInfo->pisMessage;
nContentlength=m_pWebRespInfo->lContentLength;
nByteCount = ISOURCE_Read(m_pISource, (char*)szBuffer,1024);
switch (nByteCount)
{
case ISOURCE_WAIT:
ISOURCE_Readable(m_pISource, &pApp->m_pHttp[2].m_cbWebResp);
FREEIF(szBuffer);
return;
case ISOURCE_ERROR:
bError=TRUE;
FREEIF(szBuffer);
return;
case ISOURCE_END:
{
if (pApp->m_pHttp[2].m_iBodySize < pApp->m_pHttp[2].m_iBodyAllocSize)
pApp->m_pHttp[2].m_pszBodyBuffer[pApp->m_pHttp[2].m_iBodySize] = 0;
else
{
if(pApp->m_pHttp[2].m_iBodyAllocSize>0)
pApp->m_pHttp[2].m_pszBodyBuffer[pApp->m_pHttp[2].m_iBodyAllocSize - 1] = 0;
}
FREEIF(szBuffer);
}//ISOurce End
break;
default:
if (nByteCount)
{
if (pApp->m_pHttp[2].m_iBodySize + nByteCount > pApp->m_pHttp[2].m_iBodyAllocSize)
{
uint32 m_NewBufferSize =(uint32) pApp->m_pHttp[2].m_iBodyAllocSize + 1024;
char* m_pNewBuf = (char*)REALLOC(pApp->m_pHttp[2].m_pszBodyBuffer, m_NewBufferSize);
if (m_pNewBuf)
{
pApp->m_pHttp[2].m_pszBodyBuffer = m_pNewBuf;
pApp->m_pHttp[2].m_iBodyAllocSize = m_NewBufferSize;
}
}
if (pApp->m_pHttp[2].m_iBodySize + nByteCount <= pApp->m_pHttp[2].m_iBodyAllocSize)
{
if(MEMCPY(pApp->m_pHttp[2].m_pszBodyBuffer + pApp->m_pHttp[2].m_iBodySize, szBuffer, nByteCount)==NULL)
{
if (pApp->m_pHttp[2].m_pIWebResp)
{
IWEBRESP_Release(pApp->m_pHttp[2].m_pIWebResp);
pApp->m_pHttp[2].m_pIWebResp = NULL;
}
FREEIF(szBuffer);
}
pApp->m_pHttp[2].m_iBodySize += nByteCount;
FREEIF(szBuffer);//commented for full download
}
ISOURCE_Readable(m_pISource, &pApp->m_pHttp[2].m_cbWebResp);
return;
}//end default
break;
}//end switch
}//end if

Please find attached code...this is tested code

void GotResponse(CAppStruct * pApp)
{
int nByteCount = 0;
char * szBuffer=NULL;
WebRespInfo * m_pWebRespInfo = NULL;
boolean bError=FALSE;
if(!pApp->m_pHttp[2].m_bWeb)
return;
szBuffer=(char*)MALLOC(1024*sizeof(char));
m_pWebRespInfo = IWEBRESP_GetInfo(pApp->m_pHttp[2].m_pIWebResp);
if(!m_pWebRespInfo)
{
FREEIF(szBuffer);
return;
}
DBGPRINTF("code=%d",m_pWebRespInfo->nCode);
if(m_pWebRespInfo && WEB_ERROR_SUCCEEDED(m_pWebRespInfo->nCode))
{
int nContentlength;
ISource* m_pISource = m_pWebRespInfo->pisMessage;
nContentlength=m_pWebRespInfo->lContentLength;
nByteCount = ISOURCE_Read(m_pISource, (char*)szBuffer,1024);
switch (nByteCount)
{
case ISOURCE_WAIT:
ISOURCE_Readable(m_pISource, &pApp->m_pHttp[2].m_cbWebResp);
FREEIF(szBuffer);
return;
case ISOURCE_ERROR:
bError=TRUE;
FREEIF(szBuffer);
return;
case ISOURCE_END:
{
if (pApp->m_pHttp[2].m_iBodySize < pApp->m_pHttp[2].m_iBodyAllocSize)
pApp->m_pHttp[2].m_pszBodyBuffer[pApp->m_pHttp[2].m_iBodySize] = 0;
else
{
if(pApp->m_pHttp[2].m_iBodyAllocSize>0)
pApp->m_pHttp[2].m_pszBodyBuffer[pApp->m_pHttp[2].m_iBodyAllocSize - 1] = 0;
}
FREEIF(szBuffer);
}//ISOurce End
break;
default:
if (nByteCount)
{
if (pApp->m_pHttp[2].m_iBodySize + nByteCount > pApp->m_pHttp[2].m_iBodyAllocSize)
{
uint32 m_NewBufferSize =(uint32) pApp->m_pHttp[2].m_iBodyAllocSize + 1024;
char* m_pNewBuf = (char*)REALLOC(pApp->m_pHttp[2].m_pszBodyBuffer, m_NewBufferSize);
if (m_pNewBuf)
{
pApp->m_pHttp[2].m_pszBodyBuffer = m_pNewBuf;
pApp->m_pHttp[2].m_iBodyAllocSize = m_NewBufferSize;
}
}
if (pApp->m_pHttp[2].m_iBodySize + nByteCount <= pApp->m_pHttp[2].m_iBodyAllocSize)
{
if(MEMCPY(pApp->m_pHttp[2].m_pszBodyBuffer + pApp->m_pHttp[2].m_iBodySize, szBuffer, nByteCount)==NULL)
{
if (pApp->m_pHttp[2].m_pIWebResp)
{
IWEBRESP_Release(pApp->m_pHttp[2].m_pIWebResp);
pApp->m_pHttp[2].m_pIWebResp = NULL;
}
FREEIF(szBuffer);
}
pApp->m_pHttp[2].m_iBodySize += nByteCount;
FREEIF(szBuffer);//commented for full download
}
ISOURCE_Readable(m_pISource, &pApp->m_pHttp[2].m_cbWebResp);
return;
}//end default
break;
}//end switch
}//end if

Please find attached code...this is tested code