Hi
I am trying to do to a http post put i am not succeeding in doing this. I keep getting this error WIP_CERR_NOT_SUPPORTED
I get WIP_CEV_OPEN then WIP_CEV_WRITE events and then the error occurs
Here is my code
// HANDLER
void HTTP_hdl_c(wip_event_t *event, void *context)
{
s32 ret;
s32 code;
TRACE((TRACE_LEVEL_HTTP, "HTTP_hdl_c()"));
switch(event->kind)
{
//response header message received
case WIP_CEV_OPEN:
TRACE((TRACE_LEVEL_HTTP, "HTTP_hdl_c(): WIP_CEV_OPEN"));
break;
//response body message received
case WIP_CEV_READ:
TRACE((TRACE_LEVEL_HTTP, "HTTP_hdl_c(): WIP_CEV_READ"));
//check http_status
wip_getOpts(http_channel_pers, WIP_COPT_HTTP_STATUS_CODE, &code, WIP_COPT_END);
TRACE((TRACE_LEVEL_HTTP, "return code is %d", code));
if (code == 200) //OK
{
//...
}
break;
case WIP_CEV_PEER_CLOSE:
TRACE((TRACE_LEVEL_HTTP, "HTTP_hdl_c(): WIP_CEV_PEER_CLOSE"));
wip_close(http_channel_pers);
break;
case WIP_CEV_ERROR:
TRACE((TRACE_LEVEL_HTTP, "HTTP_hdl_c(): WIP_CEV_ERROR"));
wip_close(http_channel_pers);
break;
//write request body
case WIP_CEV_WRITE:
TRACE((TRACE_LEVEL_HTTP, "HTTP_hdl_c(): WIP_CEV_WRITE"));
ret = wip_write(http_channel_pers, "some=request", 13);
TRACE((TRACE_LEVEL_HTTP, "wip_write ret: %d", ret));
wip_shutdown(http_channel_pers,FALSE,TRUE);
break;
}
}
void HTTP_SendRequest()
{
ascii* req;
http_channel_pers = wip_HTTPClientCreateOpts(NULL, NULL, WIP_COPT_HTTP_HEADER, "User-Agent", "WIP-HTTP-Client/1.0", WIP_COPT_END);
if (http_channel_pers == NULL)
{
return;
}
req = "http://xxx/xxx/test.php";
// do post request
wip_getFileOpts(http_channel_pers, req, HTTP_hdl_c, NULL,
WIP_COPT_HTTP_METHOD, WIP_HTTP_METHOD_POST,
WIP_COPT_HTTP_HEADER, "Accept", "*",
WIP_COPT_END);
}
static void gprsBearerHandler(wip_bearer_t br,s8 event,void *context){
switch (event) {
case WIP_BEV_IP_CONNECTED:
HTTP_SendRequest();
break;
case WIP_BEV_IP_DISCONNECTED:
break;
default:
break;
}
}
//*********************************************************************************************************
// This functions will create the bearer for the GPRS
//*********************************************************************************************************
/** This functions will create the bearer for the GPRS.
@return TRUE if successfull.
@return FALSE if failure.
*/
bool createBearer( ){
wip_bearer_t gprsBearer;
s8 resp = 0;
if (wip_bearerOpen(&gprsBearer,"GPRS", gprsBearerHandler, NULL) != 0 ){
// cannot open the bearer
return FALSE;
}
//configure the gprs connection
if (wip_bearerSetOpts(gprsBearer,WIP_BOPT_GPRS_APN, Configuration.apnServer, WIP_BOPT_LOGIN,
Configuration.gprsUser, WIP_BOPT_PASSWORD, Configuration.gprsPassword, WIP_BOPT_END) !=0){
//cannot configure the bearer
wip_bearerClose(gprsBearer);
return FALSE;
}
// start connection
wip_debug( "try to start bearer\n");
resp = wip_bearerStart(gprsBearer);
switch (resp) {
case WIP_BERR_OK_INPROGRESS:
wip_debug( "Bearer starting\n");
break;
case WIP_BERR_BAD_HDL:
wip_debug( "Invalid bearer handle\n");
break;
case WIP_BERR_BAD_STATE:
wip_debug( "WIP_BERR_BAD_STATE\n");
break;
case WIP_BERR_DEV:
wip_debug( "The bearer is not stoped\n");
break;
default:
wip_debug( "Unknown error when starting bearer\n");
break;
}
if (resp !=WIP_BERR_OK_INPROGRESS){
wip_bearerClose(gprsBearer);
return FALSE;
}
return TRUE;
}
/***************************************************************************/
// Function that handles all the events related to the SIM
/***************************************************************************/
/** Handles all the events related to the SIM.
@param Event The events that occurs related to the SIM.
@return nothing.
*/
void ftp_simHandler(u8 Event) {
bool rsp;
switch ( Event ) {
case ADL_SIM_EVENT_PIN_OK :
TRACE (( TRACE_LEVEL_HTTP, "ADL_SIM_EVENT_PIN_OK" ));
break;
case ADL_SIM_EVENT_REMOVED :
TRACE (( TRACE_LEVEL_HTTP, "ADL_SIM_EVENT_REMOVED" ));
break;
case ADL_SIM_EVENT_INSERTED :
TRACE (( TRACE_LEVEL_HTTP, "ADL_SIM_EVENT_INSERTED" ));
break;
case ADL_SIM_EVENT_FULL_INIT :
TRACE (( TRACE_LEVEL_HTTP, "ADL_SIM_EVENT_FULL_INIT" ));
createBearer( );
break;
case ADL_SIM_EVENT_PIN_ERROR :
TRACE (( TRACE_LEVEL_HTTP, "ADL_SIM_EVENT_PIN_ERROR" ));
break;
case ADL_SIM_EVENT_PIN_NO_ATTEMPT :
TRACE (( TRACE_LEVEL_HTTP, "ADL_SIM_EVENT_PIN_NO_ATTEMPT" ));
break;
case ADL_SIM_EVENT_PIN_WAIT :
TRACE (( TRACE_LEVEL_HTTP, "ADL_SIM_EVENT_PIN_WAIT" ));
break;
default :
TRACE (( TRACE_LEVEL_HTTP, "other PIN event" ));
break;
}
}
/***************************************************************************/
// initialize the SIM
/***************************************************************************/
void ftp_initSIM(void){
adl_simState_e simState;
ascii buf[50];
simState = adl_simGetState();
adl_atSendResponse(ADL_AT_RSP,"\n\rShould enter pin...\r\n");
adl_simSubscribe((adl_simHdlr_f)ftp_simHandler, ftp_Configuration.pinCode);
if (simState == ADL_SIM_STATE_PIN_WAIT){
adl_atSendResponse(ADL_AT_RSP,"Entering pin");
} else {
adl_atSendResponse(ADL_AT_RSP,"Sim state:");
wm_sprintf(buf,"%d",simState);
adl_atSendResponse(ADL_AT_RSP,buf);
}
}
/***************************************************************************/
// initialize the IP stack needed to put data on ftp
/***************************************************************************/
/** Initializes the IP stack needed to put data on ftp.
@return nothing.
*/
void initIPStack(void){
int r;
/* Initialize the stack */
r = wip_netInitOpts(
WIP_NET_OPT_DEBUG_PORT, WIP_NET_DEBUG_PORT_UART1,
WIP_NET_OPT_END);
if (r !=0 ){
}
}
void init(finit_config_t * initStruct){
Configuration = *initStruct;
initIPStack();
initSIM();
}
What am i doing wrong?