
int main(int argc, char* argv[])
{
signal(SIGINT, Exit);
int num = 0;
printf("Debug tx for role %d.\n", TRANSMITTER);
char** uriList = ScanFileName(SEND_PATH, &num);
if (InitShareKit(NULL) != 0) {
goto done;
}
ShareTransHandle transHandle;
memset(&transHandle, 0, sizeof(ShareTransHandle));
transHandle.statusCb = SharekitStatusChangeCbFunc;
if (StartShareService(TRANSMITTER, &transHandle) != 0) {
goto done;
}
ShareDeviceInfo* dev = NULL;
dev = SelectDev();
ShareFileInfo files;
memset(&files, 0, sizeof(ShareFileInfo));
files.uriList = uriList;
files.fileNum = num;
if (dev != NULL) {
(void)TransFile(dev, &files);
}
FreeFileList(uriList, num);
StopShareService();
UninitShareKit();
sleep(1);
printf("main exit. \n");
return 0;
} Starts the request for initializing device resources for Share Engine.
Function Declaration | int InitShare Kit(void* handle) | ||
|---|---|---|---|
Parameter | void* | handle |
|
Return Value | int | 0: success; other values: failure | |
Notify the user of the file sending progress.
Function Declaration | typedef void(*ShareProgressCallback)(int process) | ||
|---|---|---|---|
Parameter | int | process | Sending progress |
Return Value | void | NA | |
Notify the user of any status change, for example, when the sending is complete or has been canceled.
Function Declaration | typedef void(*ShareStatusCallback)(ShareStatus* status) | ||
|---|---|---|---|
Parameter | ShareStatus* | status | Current state |
Return Value | void | NA | |
The sending device discovers available devices in close proximity using BLE advertising.
Function Declaration | int GetAvailableDevice(ShareDeviceInfo** devInfo, int* devNum) | ||
|---|---|---|---|
Parameter | ShareDeviceInfo** | devInfo |
|
int* | devNum |
| |
Return Value | int | 0: success; other values: failure | |
Select a connected device to share specific files with it.
Function Declaration | int TransFile(const ShareDeviceInfo* device, const ShareFileInfo* files) | ||
|---|---|---|---|
Parameter | const ShareDeviceInfo* | device | Information about the receiving device, such as its MAC address |
const ShareFileInfo* | files | Information about the files to share | |
Return Value | int | 0: success; other values: failure | |
Cancel sending.
Function Declaration | void CancelTransFile(void) | |
|---|---|---|
Return Value | void | - |
End the searching service.
Function Declaration | int StopShareService(void) | |
|---|---|---|
Return Value | int | 0: success; other values: failure |
Release the system resources occupied by Share Engine.
Function Declaration | int UninitShare Kit(void) | |
|---|---|---|
Return Value | int | 0: success; other values: failure |
For details about the APIs, please refer to the API Reference.
For details about the code example, please refer to the Sample Code.