Embedded Systems Software Training Center

16
2011 Embedded Systems Software Training Center BluRapport SDK

description

Embedded Systems Software Training Center. BluRapport SDK. Agenda. Continue l earn how to work with BluRapport SDK PIN code OBEX API Implement FTP browser. Questions. What is the Inquiry process? What is the Service Discovery process?. Common API. - PowerPoint PPT Presentation

Transcript of Embedded Systems Software Training Center

Page 1: Embedded Systems Software Training Center

2011

Embedded Systems Software Training Center

BluRapport SDK

Page 2: Embedded Systems Software Training Center

Agenda

lContinue learn how to work with BluRapport SDKl PIN codel OBEX APIl Implement FTP browser

Page 3: Embedded Systems Software Training Center

Questions

lWhat is the Inquiry process?lWhat is the Service Discovery process?

Page 4: Embedded Systems Software Training Center

Common API

Main Functions that are used to work with PIN code:int rx_set_fixed_pin(TCHAR* pin) – setup pin code, After that call the stack will reply this PIN immediately, without calling PIN callback.

void rx_register_pin_request_callback(rx_pin_code_request_callback_t func, void *user_ptr) - install PIN callback.- func - user-supplied function which should return PIN- user_ptr - pointer to user's private data to pass into callback as 1-st parameter

typedef rx_ret_t (*rx_pin_code_request_callback_t)(void * user_data, unsigned timeout_ms,

rx_remote_device_user_t *remote_device, TCHAR *out_pin_code) - callback to answer on PIN request- user_data - pointer passed to rx_register_pin_request_callback.- timeout_ms - time limit for PIN code request- remote_device - information about device which requested PIN.- out_pin_code PIN to pass to the stack

Page 5: Embedded Systems Software Training Center

Your Task 1

1. Prepare application with support fixed pin code (use rx_set_fixed_pin())

2. Prepare application with support user defined pin code (use rx_register_pin_request_callback())

Page 6: Embedded Systems Software Training Center

OBEX API

Main Functions that are used to work with OBEX profile:rx_ret_t rx_obex_initialize () - function initializes OBEX subsystem. This function must be called first, othewise OBEX APIs will not work. When you are done using OBEX call rx_obex_deinitialize

rx_ret_t rx_obex_deinitialize () – Frees the resources that are allocated by rx_obex_initialize. This function must be called if rx_obex_initialize return RET_OK. It also stops all services started by rx_obex_register_service without need of the handles.

Page 7: Embedded Systems Software Training Center

Demo FTP browser

Main Functions that are used to work with OBEX profile:rx_ret_t rx_obex_connect(rx_obex_handle_t *connection_handle, rx_obex_connection_info_t *connection_info) - Establish OBEX connection.connection_info - structure containing connection parameters.rx_ret_t ret = RET_OK;rx_obex_handle_t handle = NULL;rx_obex_connection_info_t connection_info;rx_bd_addr_t bd_addr;unsigned channel;...memset(&connection_info, 0, sizeof(connection_info));memcpy(connection_info.uuid, RX_OBEX_FTP_UUID, RX_OBEX_FTP_UUID_LEN);connection_info.address.proto = RX_PF_RFCOMM;connection_info.address.protocol.rfcomm.channel = channel;(see Task 2 from Lab03)memcpy(&connection_info.address.protocol.rfcomm.bd_addr, &bd_addr, sizeof(rx_bd_addr_t));connection_info.uuid_len = RX_OBEX_FTP_UUID_LEN;ret = rx_obex_connect(TRS_CALL &handle, &connection_info);

Page 8: Embedded Systems Software Training Center

Demo FTP browser

Main Functions that are used to work with OBEX profile:rx_ret_t rx_obex_ftp_put_file(rx_obex_handle_t connection_handle, TCHAR *file_name, TCHAR *src_dir, rx_obex_ftp_operation_progress_t *progress) - Copies a single file to the current directory for this connection on OBEX server- connection_handle - handle obtained by call to rx_obex_connect()- file_name - file name of the file to be pushed.- src_dir - the directory from where file will be taken. If this parameter is NULL, file is taken from the

current directory (specified in connection_info structure during connect).- progress - operation progress callback. Function will be called after sending every packet with file body.

This parameter could be null if information about progress is useless.

Page 9: Embedded Systems Software Training Center

Demo FTP browser

Main Functions that are used to work with OBEX profile:typedef struct rx_obex_ftp_operation_progress_s{ rx_obex_ftp_operation_progress_callback_t callback; /* user callback function to be called * during file operation */ void *user_data; /* pointer to user data. This pointer will be returned in file operation callback */}rx_obex_ftp_operation_progress_t;

typedef rx_bool_t (* rx_obex_ftp_operation_progress_callback_t)(void* user_data, rx_uint32_t rest_bts, rx_uint32_t total_rest_bts, TCHAR *file_name) - OBEX file operation progress function.- user_data - pointer to user data. Filled by user in rx_obex_ftp_operation_progress_t structure

before call FTP operation that support progress callbacks.- rest_bts - bytes rest to transfer current file.- total_rest_bts - total bytes rest to transfer.- file_name - pointer to the file name which is now transferred.

Page 10: Embedded Systems Software Training Center

Demo FTP browser

Main Functions that are used to work with OBEX profile:Example of using progress callback:

rx_bool_t operation_progress(void *d, rx_uint32_t rest_bts, rx_uint32_t total_rest_bts, TCHAR *name){ (void)d; xprintf(_T("file to transfer %s; %d bytes total; %d bytes left\n"), name, total_rest_bts, rest_bts); return RX_TRUE;}…prgs.callback = &operation_progress;prgs.user_data = NULL;ret = rx_obex_ftp_put_file(TRS_CALL gs_handle, gs_path, NULL, &prgs);

Page 11: Embedded Systems Software Training Center

Demo FTP browser

Main Functions that are used to work with OBEX profile:rx_ret_t rx_obex_ftp_get_file(TRS_PROTO rx_obex_handle_t connection_handle, TCHAR* file_name, TCHAR* dest_dir, rx_obex_ftp_operation_progress_t *progress) - Gets a single file from the server- connection_handle - handle obtained by call to rx_obex_connect.- file_name - file name to get from the server.- dest_dir - the directory where the file should land (with the same name as the source).- progress - operation progress callback. Function will be called after sending every packet with file

body. This parameter could be null if information about operation progress is useless.

NOTE: if dest_dir is NULL, the received file will be placed in the default directory (specified in connection_info structure during connect).

Page 12: Embedded Systems Software Training Center

Demo FTP browser

Main Functions that are used to work with OBEX profile:rx_ret_t rx_obex_ftp_chdir(rx_obex_handle_t connection_handle, TCHAR *dir) - Changes the current directory that the client sees on the server.- connection_handle - handle obtained by call to rx_obex_connect.- dir - path to the new directory.

rx_ret_t rx_obex_ftp_find_first(rx_obex_handle_t connection_handle, TCHAR *dir_name, rx_obex_ftp_find_data_t *data) - Gets remote directory information- connection_handle - handle obtained by call to rx_obex_connect.- dir_name - remote directory name.- data - data about the first file found.

rx_ret_t rx_obex_ftp_find_next(rx_obex_handle_t connection_handle, rx_obex_ftp_find_data_t *data) - Finds next remote file or folder.- connection_handle - handle obtained by call to rx_obex_connect.- data - data about the next file found.NOTE: return RET_OK on success, RET_END_OF_LIST on end of list file, or errorcode - otherwise.

rx_ret_t rx_obex_ftp_find_done(rx_obex_handle_t connection_handle) - Clear the informationallocated by rx_obex_ftp_find_first.- connection_handle - handle obtained by call to rx_obex_connect.

Page 13: Embedded Systems Software Training Center

Demo FTP browser

Main Functions that are used to work with OBEX profile:Example of getting contents of folder:

rx_ret_t ret = RET_OK;rx_obex_handle_t handle = NULL;rx_obex_ftp_find_data_t data;...ret = rx_obex_ftp_find_first(TRS_CALL handle, &data);while(ret != RET_OK){ ret = rx_obex_ftp_find_next(TRS_CALL handle, &data);}ret = rx_obex_ftp_find_done(TRS_CALL handle);

Page 14: Embedded Systems Software Training Center

Your Task 2

Prepare simple application for support FTP browsing on remote device. Use OBEX API:- rx_obex_ftp_find_xxx()- rx_obex_ftp_chdir()

Page 15: Embedded Systems Software Training Center

Your Task 3

Prepare simple application for support file transporting feature. Use OBEX API:- rx_obex_ftp_get_file()- rx_obex_ftp_put_file()

Additional:- add support showing progress bar on

sending/receiving process- Add supporting for "the interruption of send/recv

data"

Page 16: Embedded Systems Software Training Center

THANK YOU