Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
| File info |
| onehop_api.h |
| Header file that contains methods for upper-layer apps. |
| Return type | Method name |
| int | InitOneHop (const void context) Initializes the OneHop Engine SDK running environment. |
| void | UninitOneHop(void) Releases system resources. |
| int | StartOneHopService(const OneHopKitHandlers callBack) Starts the OneHop service. |
| int | StopOneHopService(void) Terminates the OneHop service. |
| int | ConfirmOneHopFileRecv(const char path) Confirms file receiving. |
| int | RefuseOneHopFileRecv(void) Refuses to receive the file. |
| int | GetConnectedDeviceName(char devName, int len) Obtains the name of the target device. |
| Struct |
| TransferResult |
| Enumerations of the file transfer results of the OneHop service. |
Members
| Member name | Member desc |
| RECV_SUCCESS = 0 | All files have been received. |
| RECV_FAIL = 1 | No file has been received. |
| RECV_PARTLY_SUCCESS = 2 | Some files have been received, but some are not. |
| Struct |
| OnehopErrorCode |
| OneHop service result code. |
Members
| Member name | Member desc |
| ONEHOP_ERR_INPUT_PARAM_INVALID = 2 | Invalid input parameters. |
| ONEHOP_ERR_CONFIG_INIT_FAIL = 3 | Failed to initialize the configuration of OneHop Engine. |
| ONEHOP_ERR_DRIVER_ADAPT_INIT_FAIL = 4 | Failed to initialize the device. |
| ONEHOP_ERR_SERVICE_STARTED = 5 | The OneHop service has been initialized, and there is no need to initialize again. |
| ONEHOP_ERR_SERVICE_START_FAIL = 6 | Failed to initiate the OneHop service. |
| ONEHOP_ERR_WIFI_WPA_CONNECT_FAIL = 2001 | Failed to connect to the Wi-Fi WPA. |
| ONEHOP_ERR_WIFI_P2P_ADD_FAIL = 2002 | Failed to add the Wi-Fi P2P group. |
| ONEHOP_ERR_TRANS_NO_SPACE = 3001 | Failed to transfer files. The disk space is insufficient. |
| Struct |
| OnehopStatus |
| Enumerations of the OneHop service status. |
Members
| Member name | Member desc |
| ONEHOP_P2P_CONNECT = 0 | P2P OneHop connection established. |
| ONEHOP_P2P_DISCONNECT = 1 | P2P OneHop connection disrupted. |
| ONEHOP_GO_STARTED = 2 | OneHop GO initiated. |
| ONEHOP_GO_REMOVED = 3 | OneHop P2P group removed. |
| ONEHOP_SERVICE_ABORT = 4 | OneHop service aborted abnormally. |
| ONEHOP_SERVICE_FINSHED = 5 | OneHop service completed. |
| Struct |
| OneHopHandlers |
| Defines the OneHop service callback function structure. |
Members
| Member name | Member desc |
| statusChangedCallback | Callback indicating the change of the connection status of the OneHop SDK. |
| fileTransferRequestCallback | Callback notifying the upper-layer app that the file for transfer is ready. |
| fileTransferProgressCallback | Callback indicating the OneHop Engine SDK's file transfer progress. |
| fileTransferResultCallback | Callback indicating the file transfer result. |
| Method |
| int InitOneHop(const void *context) |
| Initializes the OneHop service. Call this method before StartOneHopService(). |
Parameters
| Parameter name | Parameter desc |
| context | Reserved for extension |
Return
| type | desc |
| int | 0: Succeeded. Other values: error code. |
| Method |
| void UninitOneHop(void) |
| Uninitializes the OneHop service. Call this method before StartOneHopService(). |
| Method |
| int StartOneHopService(const OneHopKitHandlers *callBack) |
| Starts the OneHop service. Call this method after InitOneHop(). |
Parameters
| Parameter name | Parameter desc |
| callBack | OneHop service callback |
Return
| type | desc |
| int | 0: Succeeded. Other values: error code. |
| Method |
| int StopOneHopService(void) |
| Terminates the OneHop service. Call this method after InitOneHop(). |
Return
| type | desc |
| int | 0: Succeeded. -1: Failed. |
| Method |
| int ConfirmOneHopFileRecv(const char * path) |
| Confirms file receiving. Call this method when the user confirms the reception of files, to notify the OneHop service to initiate the file receiving operations, and notify OneHop of the file storage path. |
Parameters
| Parameter name | Parameter desc |
| path | Path for storing the file. The length of the path string cannot exceed 1024 bytes. |
Return
| type | desc |
| int | 0: Succeeded. -1: Failed. |
| Method |
| int RefuseOneHopFileRecv(void) |
| Refuses to receive the file. Call this method when the user refuses to receive files, to notify the OneHop service to perform related operations. |
Return
| type | desc |
| int | 0: Succeeded. -1: Failed. |
| Method |
| int GetConnectedDeviceName(char* devName, int len) |
| Obtains the name of the device connected via OneHop. |
Parameters
| Parameter name | Parameter desc |
| devName | Device name. |
| len | String length of the input parameter devName. The value should not be less than 256. |
Return
| type | desc |
| int | 0: Succeeded. -1: Failed. |
| Method |
| typedef void(*OnehopStatusCallback) (OnehopStatus status) |
| The OneHop service uses this callback to notify apps of the current connection status, when the P2P OneHop connection status changes. |
Parameters
| Parameter name | Parameter desc |
| status | Connection status. For details, see section 2.4.3. |
Return
| type | desc |
| void | No value is returned. |
| Method |
| typedef void(OnehopRequestFileTransferCallback)( const char* fileNames, int fileNum) |
| The OneHop service uses this callback to notify apps of the request, when a file transfer request is initiated on the phone. |
Parameters
| Parameter name | Parameter desc |
| fileNames | List of file names |
| fileNum | Number of files |
Return
| type | desc |
| void | No value is returned. |
| Method |
| typedef void(*OnehopTransferProgressCallback)(int finishedFileNum, int totalFileNum) |
| The OneHop service uses this callback to notify apps of the file transfer progress, including the number of the successfully transferred files and the total file number. |
Parameters
| Parameter name | Parameter desc |
| finishedFileNum | Number of files that have been transferred |
| totalFileNum | Total file number |
Return
| type | desc |
| void | No value is returned. |
| Method |
| typedef void (*OnehopTransferResultCallback)( TransferResult result, int failedNum) |
| The OneHop service uses this callback to notify apps of the transfer result, when the transfer completes. |
Parameters
| Parameter name | Parameter desc |
| result | Transfer results: Refer to section 2.4.1. |
| failedNum | If the value of result is RECV_SUCCESS, ignore failedNum. If the value of result is RECV_PARTLY_SUCCESS or RECV_FAIL, the value of failedNum indicates the number of files that fail to be transferred. |
Return
| type | desc |
| void | No value is returned. |