⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jnw_stream.c

📁 java 1.1 gemini 08_16
💻 C
📖 第 1 页 / 共 3 页
字号:
    }

    send_req = (wps_stream_data_send_req_struct*) construct_local_para(sizeof(wps_stream_data_send_req_struct), TD_CTRL);

    send_req->channel_id = channel_id;
    send_req->seq_num = seq_num;

    send_req_var.length = (kal_uint32) length;
    send_req_var.data = (kal_uint8*) data;

    pdu_length = wps_pun_var_part(WPS_PUN_SIZE, MSG_ID_WPS_STREAM_DATA_SEND_REQ, &send_req_var, NULL);

    /* Add one more byte to avoid allocating empty peer buffer */
    peer_buff_ptr = construct_peer_buff((pdu_length + 1), 0, 0, TD_CTRL);
    wps_pun_var_part(WPS_PUN_PACK, MSG_ID_WPS_STREAM_DATA_SEND_REQ, &send_req_var, get_pdu_ptr(peer_buff_ptr, &pdu_length));

    j2me_stream_send_ilm(send_req, peer_buff_ptr, MSG_ID_WPS_STREAM_DATA_SEND_REQ, MOD_WPS);

    return JNW_STREAM_OK;
}


/*****************************************************************************
 * FUNCTION
 *  jnw_stream_read_data_req
 * DESCRIPTION
 *  
 * PARAMETERS
 *  conn_id     [IN]        
 *  seq_no      [IN]        
 * RETURNS
 *  
 *****************************************************************************/
int jnw_stream_read_data_req
        (kal_uint8 channel_id, 
         kal_uint8 seq_num, 
         kal_uint32 read_length )
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    int i = 0;
    wps_stream_data_read_req_struct *read_req;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_READ_STREAM_REQ, channel_id, read_length);
    
    i = j2me_stream_search((kal_int16) channel_id);

    if (i >= J2ME_STREAM_MAX_NUMBER)
    {
        return JNW_STREAM_CLOSED_STREAM;
    }
    
    if (read_length > 2000)
    {
        return JNW_STREAM_INVALID_PARAMETER;
    }
    
    read_req =
        (wps_stream_data_read_req_struct*) construct_local_para(sizeof(wps_stream_data_read_req_struct), TD_CTRL);

    read_req->channel_id = channel_id;

    read_req->seq_num = seq_num;
    read_req->read_length = read_length;

    j2me_stream_send_ilm(read_req, NULL, MSG_ID_WPS_STREAM_DATA_READ_REQ, MOD_WPS);

    return JNW_STREAM_OK;
}


/*****************************************************************************
 * FUNCTION
 *  jnw_stream_check_response_primitive
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
int jnw_stream_check_response_primitive(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    unsigned long message_id;
    int result = -1;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/    
    message_id = readStreamAsyncEvent();

    switch (message_id)
    {
        case MSG_ID_WPS_CREATE_STREAM_CONNECTION_RSP:
        {
            result = MSG_WPS_CREATE_STREAM_CONNECTION_RSP;
        }
            break;

        case MSG_ID_WPS_CLOSE_STREAM_CONNECTION_RSP:
        {
            result = MSG_WPS_CLOSE_STREAM_CONNECTION_RSP;
        }
            break;

        case MSG_ID_WPS_STREAM_DATA_SEND_RSP:
        {
            result = MSG_WPS_STREAM_DATA_SEND_RSP;
        }
            break;

        case MSG_ID_WPS_STREAM_DATA_READ_RSP:
        {
            result = MSG_WPS_STREAM_DATA_READ_RSP;
        }
            break;

        default:
        {
            result = -1;
        }
            break;

    }
    
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_CHECK_RESPONSE_PRIMITIVE, result);

    return result;
}


/*****************************************************************************
 * FUNCTION
 *  jnw_stream_open_stream_get_result
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
void jnw_stream_open_stream_get_result (jnw_stream_result_struct* result )

{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_OPEN_STREAM_RESULT);
    result->result = j2me_stream_result.result;
    result->channel_id = j2me_stream_result.channel_id;
}

/*****************************************************************************
 * FUNCTION
 *  jnw_stream_close_stream_get_result
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
void jnw_stream_close_stream_get_result	(jnw_stream_result_struct* result )
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_CLOSE_STREAM_RESULT);
    result->result = j2me_stream_result.result;
    result->channel_id = j2me_stream_result.channel_id;
}


/*****************************************************************************
 * FUNCTION
 *  jnw_stream_send_data_get_result
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
void jnw_stream_send_data_get_result (jnw_stream_send_result_struct* result )
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_SEND_RESULT);
    
    result->result = j2me_stream_send_result.result;
    result->channel_id =  j2me_stream_send_result.channel_id;
    result->seq_num = j2me_stream_send_result.seq_num;
}


/*****************************************************************************
 * FUNCTION
 *  jnw_stream_send_data_get_result
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
void jnw_stream_read_data_get_result (jnw_stream_read_result_struct* result,kal_uint8* data )
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_READ_RESULT);
    
    result->result = j2me_stream_read_result.result;
    result->channel_id =  j2me_stream_read_result.channel_id;
    result->seq_num = j2me_stream_read_result.seq_num;
    result->more = j2me_stream_read_result.more;
    result->read_data_length = j2me_stream_read_result.read_data_length;

    if (j2me_stream_read_data != NULL)
    {
        memcpy(data, j2me_stream_read_data, j2me_stream_read_result.read_data_length);
        j2me_stream_reset_read_data();
    }
    
    return;
}

/*****************************************************************************
 * FUNCTION
 *  finalizeStream
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void finalizeStream()
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    int i = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_FINALIZE_INTERNAL);

    for (; i < J2ME_STREAM_MAX_NUMBER; i++)
    {
        if (j2me_stream[i].id != J2ME_STREAM_INVALID)
        {
            j2me_stream_close_stream((kal_uint8)j2me_stream[i].id);
        }
    }
}


/*****************************************************************************
 * FUNCTION
 *  jnw_stream_finalize
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
void jnw_stream_finalize()
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_FINALIZE);
    finalizeStream();
}


/*****************************************************************************
 * FUNCTION
 *  is_stream_activated
 * DESCRIPTION
 *  get if there is any activated stream.
 * PARAMETERS
 *  void
 * RETURNS
 *  TRUE if some stream is activated, FALSE otherwise.
 *****************************************************************************/
kal_bool is_stream_activated(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    int i = 0;
    kal_bool result = KAL_FALSE;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (; i < J2ME_STREAM_MAX_NUMBER; i++)
    {
        if (j2me_stream[i].id != J2ME_STREAM_INVALID)
        {
            result = KAL_TRUE;
            break;
        }
    }
    
    kal_trace(TRACE_GROUP_3, FUNC_J2ME_STREAM_IS_ACTIVATE, result);
    
    return result;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -