--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of SAMSUNG
+ * ELECTRONICS ("Confidential Information"). You shall not disclose such
+ * Confidential Information and shall use it only in accordance with the terms
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
+ * make no representations or warranties about the suitability of the software,
+ * either express or implied, including but not limited to the implied
+ * warranties of merchantability, fitness for a particular purpose, or
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by
+ * licensee as a result of using, modifying or distributing this software or
+ * its derivatives.
+ * licensee arising out of or related to this software.
+ *
+ */
+#ifndef _FTINTERFACE_H_
+#define _FTINTERFACE_H_
+
+#include "SAPInterface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************************************************************//**
+ @brief The enum defines the status codes that may be used to convey generic result codes as needed for FT interaction.
+ @param TRANSFER_SUCCESS: FT Transfer is successfull.
+ @param TRANSFER_COMPLETE_FAIL_FILE_IO: This error is received when the file to be sent/received doesn't exist or the path is invalid
+ @param TRANSFER_COMPLETE_FAIL_PEER_UNRESPONSIVE: This error is received during file transfer the remote end is unresponsive
+ @param TRANSFER_COMPLETE_FAIL_PEER_CONN_LOST: This error is received when during file transfer service connection was lost (e.g. could be due to BT off)
+ @param TRANSFER_COMPLETE_FAIL_PEER_CANCELLED: This error is received when peer cancelled file transfer
+ @param TRANSFER_COMPLETE_FAIL_SPACE_NOT_AVAILABLE: This error is received when peer doesn't have enough space to store the file
+ ****************************************************************************/
+typedef enum tagFTResultVal
+{
+ TRANSFER_SUCCESS = 0,
+ TRANSFER_COMPLETE_FAIL_CHANNEL_IO = 1,
+ TRANSFER_COMPLETE_FAIL_FILE_IO = 2,
+ TRANSFER_COMPLETE_FAIL_CMD_DROPPED = 3,
+ TRANSFER_COMPLETE_FAIL_PEER_UNRESPONSIVE = 4,
+ TRANSFER_COMPLETE_FAIL_PEER_CONN_LOST = 5,
+ TRANSFER_COMPLETE_FAIL_PEER_CANCELLED = 9,
+ TRANSFER_COMPLETE_FAIL_SPACE_NOT_AVAILABLE = 11
+}FT_RESULT_VAL;
+
+/*********************************************************************************//**
+ @brief The function sendFile is called by app to send a file
+ @param pFilePath [in]: this is absolute file path for file to be send. If file doesn't exist, permission denied or invalid path,
+ App will be notified in FDefOnSendComplete() with error code TRANSFER_COMPLETE_FAIL_FILE_IO
+ @param pPeerAgent [in]: Peer Agent to which file is to be sent
+ @returns : returns file transfer dwTransactionId - Application should store this transaction id to track status of file transfer
+ ****************************************************************************/
+int sendFile(char* pFilePath, PeerAgent* pPeerAgent);
+
+/*********************************************************************************//**
+ @brief The function pushFile is called by app, which has multiple profile implementations in a single app.
+ @param pFilePath [in]: this is absolute file path for file to be send. If file doesn't exist, permission denied or invalid path,
+ App will be notified in FDefOnSendComplete() with error code TRANSFER_COMPLETE_FAIL_FILE_IO
+ @param pPeerAgent [in]: Peer Agent to which file is to be sent
+ @param dwLocalAgentId [in]: Local agent ID of the agent which intents to use file transfer utility.
+ @returns : returns file transfer dwTransactionId - Application should store this transaction id to track status of file transfer
+ ****************************************************************************/
+int pushFile(char* pFilePath, PeerAgent* pPeerAgent, unsigned int dwLocalAgentId);
+
+/**************************************************************************//**
+ @brief The function receiveFile is called by app to accept/reject a file req
+ @param dwTransactionId [in]: file transfer transaction Id
+ @param pFilePath [in]: this is absolute file path where file to be saved. If file path is invalid,
+ permission denied App will be notified in FDefOnReceiveComplete() with error code TRANSFER_COMPLETE_FAIL_FILE_IO
+ @param wConfirmReceive [in]: accept/reject status, for accept set 1, for reject set 0
+ @returns : returns SAP_RESULT_VAL with SAP_SUCCESS in case of success and appropriate failure error if any error as per the SAP_STATUS_CODE ENUM
+ ****************************************************************************/
+SAP_RESULT_VAL receiveFile(int dwTransactionId, char* pFilePath, short int wConfirmReceive);
+
+/**************************************************************************//**
+ @brief The function cancelFile is called by app to cancel the file transfer
+ @param dwTransactionId [in]: transaction Id - Identifies the File transfer transaction to be cancelled
+ file sender App will receive this transaction Id as return value of sendFile()
+ file receiver App will receive this transaction Id in FDefOnSendFile()
+ @returns : returns SAP_RESULT_VAL with SAP_SUCCESS in case of success and appropriate failure error if any error as per the SAP_STATUS_CODE ENUM
+ ****************************************************************************/
+SAP_RESULT_VAL cancelFile(int dwTransactionId);
+
+/**************************************************************************//**
+ @brief This callback function gets triggered when App receive a file req
+ @param dwTransactionId [in]: transaction Id for file transfer
+ @param pFilePath [in] : This is source file path at sender side
+ Receiver will call receiveFile() to accept/reject the file transfer request
+ In receiveFile(), pFilePath is destination file path (Note: Since source file path could be from different File System,
+ call receiveFile with a path valid in destination File System. Application should take care of this)
+ @param dwAgentId [in]: Agent ID to which the call back is intended.
+ @returns : returns void.
+* ***************************************************************************/
+typedef void (*FDefOnSendFile) (int dwTransactionId, char* pFilePath, unsigned int dwAgentId);
+
+
+/**************************************************************************//**
+ @brief This callback function gets triggered when sending file is completed or error occurred during File transfer
+ @param dwTransactionId [in]: transaction ID for file transfer
+ @param pFilePath [in] : file path.
+ @param uwResult [in] : FT_RESULT_VAL: TRANSFER_SUCCESS if transfer is successful or appropriate Error code
+ @param dwAgentId [in]: Agent ID to which the call back is intended.
+ @returns : returns void
+* ***************************************************************************/
+typedef void (*FDefOnSendComplete) (int dwTransactionId, char* pFilePath, unsigned short int uwResult, unsigned int dwAgentId);
+
+/**************************************************************************//**
+ @brief This callback function gets triggered when receive file is completed
+ @param dwTransactionId [in]: transaction ID for file transfer
+ @param pFilePath [in] : Received file path
+ @param uwResult [in] : FT_RESULT_VAL: TRANSFER_SUCCESS if transfer is successful or appropriate Error code
+ @param dwAgentId [in]: Agent ID to which the call back is intended.
+ @returns : returns void
+* ***************************************************************************/
+typedef void (*FDefOnReceiveComplete) (int dwTransactionId, char* pFilePath, unsigned short int uwResult, unsigned int dwAgentId);
+
+
+/**************************************************************************//**
+ @brief This callback function gets triggered to update file progress status to App
+ @param dwTransactionId [in]: transaction ID for file transfer
+ @param uwProgress [in] : send/receive file progress expressed as % (e.g. 10%, 90%)
+ @param dwAgentId [in]: Agent ID to which the call back is intended.
+ @returns : returns void
+* ***************************************************************************/
+typedef void (*FDefOnFileProgress) (int dwTransactionId, unsigned short int uwProgress, unsigned int dwAgentId);
+
+
+/***************************************************************************//**
+ @brief The structure tagFTNotification holds references to callback for application for various events from framework for file transfer
+ @param pFDefOnSendFile: Callback to indicate incoming file transfer request
+ @param pFDefOnSendComplete: Callback to indicate status of send file (both success and error)
+ @param pFDefOnReceiveComplete: Callback to indicate status of receive file (both success and error)
+ @param pFDefOnFileProgress: Callback to indicate progress of file transfer
+ ****************************************************************************/
+typedef struct tagFTNotification
+{
+ FDefOnSendFile pFDefOnSendFile;///<Register on send file request function pointer
+ FDefOnSendComplete pFDefOnSendComplete;///<Register on send complete function pointer
+ FDefOnReceiveComplete pFDefOnReceiveComplete;///<Register on receive complete function pointer
+ FDefOnFileProgress pFDefOnFileProgress;///<Register on file progress function pointer
+}FTNotification;
+
+/**************************************************************************//**
+@brief This function registers all the callbacks in FTNotification. This API needs to be called from the App to get File Transfer notifications.
+@param FTNotiFuncs [in] : Notification functions which are to be registered for getting callback.
+@returns : returns void
+* ***************************************************************************/
+void registerFTNotifications(FTNotification FTNotiFuncs);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_FTINTERFACE_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of SAMSUNG
+ * ELECTRONICS ("Confidential Information"). You shall not disclose such
+ * Confidential Information and shall use it only in accordance with the terms
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
+ * make no representations or warranties about the suitability of the software,
+ * either express or implied, including but not limited to the implied
+ * warranties of merchantability, fitness for a particular purpose, or
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by
+ * licensee as a result of using, modifying or distributing this software or
+ * its derivatives.
+ * licensee arising out of or related to this software.
+ *
+ */
+#ifndef _SAPINTERFACE_H_
+#define _SAPINTERFACE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************************************************************//**
+ @brief The enum defines the event codes for the Incremental Update Notification .
+ @param PEER_UNAVAILABLE: Defines that the peer has been uninstalled or Deregistered
+ @param PEER_AVAILABLE: Defines that the peer is installed or registered
+ ****************************************************************************/
+typedef enum PeerStatus{
+ PEER_AGENT_UNAVAILABLE, ///< Defines that the peer has been uninstalled or Deregistered
+ PEER_AGENT_AVAILABLE ///< Defines that the peer is installed or registered
+}PeerStatus;
+
+/***************************************************************************//**
+ @brief The enum defines the event codes for Broadcast Event from SAP.
+ @param DEVICE_ATTACH_EVENT : Device Attach Compeleted.
+ ****************************************************************************/
+typedef enum BroadcastEvent
+{
+ DEVICE_ATTACH_EVENT = 0
+}BroadcastEvent;
+
+
+enum device_status{
+
+ DEVICE_DETACHED = 0x00, /// device detached
+ DEVICE_ATTACHED = 0x01 /// device attached
+};
+//3 TBD: One of the above should be finalised after complete review.
+
+
+/***************************************************************************//**
+ @brief The enum defines the SAP Service Agent roles for Providers and Consumers across Peer Devices.
+ @param SERVICE_AGENT_ROLE_PROVIDER: The SERVICE AGENT PROVIDER Role can be played by an application connecting to SAP in order to achieve the service objectives, like accept/reject a service connection from a SERVICE AGENT CONSUMER and send/receive data.
+ @param SERVICE_AGENT_ROLE_CONSUMER: The SERVICE AGENT CONSUMER Role can be played by an application connecting to SAP in order to achieve the service objectives, like request a service connection to a SERVICE AGENT PROVIDER and send/receive data.
+ ****************************************************************************/
+typedef enum ServiceAgentRole {
+
+ SERVICE_AGENT_ROLE_PROVIDER = 0,
+ SERVICE_AGENT_ROLE_CONSUMER = 1
+}ServiceAgentRole;
+
+
+/***************************************************************************//**
+ @brief The enum defines the result of Service Connection Creation
+ @param CONNECTION_SUCCESS: Service Connection is successful. App can continue to send Data using sendData()
+ @param CONNECTION_ALREADY_EXIST: Service Connection already exists. Connection already exist use the same. If sendData fails again, create new connection
+ @param CONNECTION_FAILURE_DEVICE_UNREACHABLE: Device is not reachable. It is not connected or connection is lost. Need to wait for connection again to retry
+ @param CONNECTION_FAILURE_INVALID_PEERAGENT: The peer agent details (peer ID etc.) are invalid. Peer Agent is invalid, so do findPeerAgent() again and retry service connection
+ @param CONNECTION_FAILURE_NETWORK: Connection failed due to network error. Try again. If error keeps happening, wait for connection and then retry.
+ @param CONNECTION_FAILURE_PEERAGENT_NO_RESPONSE: The remote peer did not response to request. Since there is no response from peer, the other side might be down or service is not supported in the peer. App can retry later
+ @param CONNECTION_FAILURE_PEERAGENT_REJECTED: The remote peer rejected the service connection. Peer has rejected, App can retry again
+ ****************************************************************************/
+typedef enum ServiceConnectionResponseCode {
+
+ CONNECTION_SUCCESS = 0, ///< Service Connection is successful. App can continue to send Data using sendData()
+ CONNECTION_ALREADY_EXIST, ///< Service Connection already exists. Connection already exist use the same. If sendData fails again, create new connection
+ CONNECTION_FAILURE_DEVICE_UNREACHABLE, ///< Device is not reachable. It is not connected or connection is lost. Need to wait for connection again to retry
+ CONNECTION_FAILURE_INVALID_PEERAGENT, ///< The peer agent details (peer ID etc.) are invalid. Peer Agent is invalid, so do findPeerAgent() again and retry service connection
+ CONNECTION_FAILURE_NETWORK, ///< Connection failed due to network error. Try again. If error keeps happening, wait for connection and then retry.
+ CONNECTION_FAILURE_PEERAGENT_NO_RESPONSE, ///< The remote peer did not response to request. Since there is no response from peer, the other side might be down or service is not supported in the peer. App can retry later
+ CONNECTION_FAILURE_PEERAGENT_REJECTED ///< The remote peer rejected the service connection. Peer has rejected, App can retry again
+}ServiceConnectionResponseCode;
+
+
+/***************************************************************************//**
+ @brief The enum defines the status codes returned when findPeerAgent is attempted.
+ @param PEER_AGENT_FOUND: Peer agent found successfully. App can create service connection using createServiceConnection()
+ @param PEER_AGENT_DEVICE_NOT_CONNECTED: When findPeerAgent was called, remote device was not connected. Wait for connection before retrying again
+ @param PEER_AGENT_SERVICE_NOT_FOUND: ASP Id or service intended in findPeerAgent not found in remote device. Service not supported at other side. Chk valid Agent Id and retry again
+ @param PEER_AGENT_FIND_TIMEDOUT: Request timed out without any response from the peer device. Retry again, it will succeed if service comes up at other side
+ @param PEER_AGENT_FIND_END: Search for peer agent completed or some internal error. Recheck passed parameters and retry
+ ****************************************************************************/
+typedef enum FindPeerAgentResponseCode {
+
+ PEER_AGENT_FOUND = 0, ///< Peer agent found successfully. App can create service connection using createServiceConnection()
+ PEER_AGENT_DEVICE_NOT_CONNECTED, ///< When findPeerAgent was called, remote device was not connected. Wait for connection before retrying again
+ PEER_AGENT_SERVICE_NOT_FOUND, ///< ASP Id or service intended in findPeerAgent not found in remote device. Service not supported at other side. Chk valid Agent Id and retry again
+ PEER_AGENT_FIND_TIMEDOUT, ///< Request timed out without any response from the peer device. Retry again, it will succeed if service comes up at other side
+ PEER_AGENT_FIND_END ///< Search for peer agent completed or some internal error. Recheck passed parameters and retry
+}FindPeerAgentResponseCode;
+
+/***************************************************************************//**
+ @brief The enum defines the error codes that shall be sent with onError callback, called when error occurs in an already established service connection.
+ @param CONNECTION_LOST_PEER_DISCONNECTED : Connection loss due to Peer device disconnected. Based on App logic retry can be done with createServiceConnection()
+ @param CONNECTION_LOST_DEVICE_DETACHED : Connection loss due to Peer device lost. Wait for new connection again to retry
+ @param CONNECTION_LOST_UNKNOWN_REASON : Connection loss due to unknown reason. Mostly development error, app can retry
+ @remarks Error during the establishment of service connection shall be conveyed as response of service connection. onError shall not be called.
+ ****************************************************************************/
+typedef enum ServiceConnectionErrorCode {
+
+ CONNECTION_LOST_PEER_DISCONNECTED = 0, ///< Connection loss due to Peer device disconnected. Based on App logic retry can be done with createServiceConnection()
+ CONNECTION_LOST_DEVICE_DETACHED, ///< Connection loss due to Peer device lost. Wait for new connection again to retry
+ CONNECTION_LOST_UNKNOWN_REASON ///< Connection loss due to unknown reason. Mostly development error, app can retry
+}ServiceConnectionErrorCode;
+
+
+/***************************************************************************//**
+ @brief The enum defines the reponse codes that shall be sent with FDefOnRegisterServiceAgentConfirm callback.
+ @param REGISTER_SUCCESS: registration is success
+ @param DUPLICATE_REGISTRATION : App calls registerServiceAgent with same ASP ID again
+ @param INVALID_ARGUMENTS : Invalid arguments, like ASP ID NULL etc. Apps should check the input params & retry
+ @param INTERNAL_ERROR : Any other internal error. App can retry registration.
+ @remarks Each app can register multiple ASP ID, but they should be different
+ ****************************************************************************/
+typedef enum RegisterAgentResponseCode {
+ REGISTER_SUCCESS = 0,
+ DUPLICATE_REGISTRATION,
+ INVALID_IN_ARGUMENTS,
+ INTERNAL_SAP_ERROR
+}RegisterAgentResponseCode;
+
+
+/***************************************************************************//**
+ @brief The enum defines the status of data transfer operation
+ @param DATA_SUCCESS: Data is sent successfully. App can continue to sendData() again
+ @param INVALID_ARGUMENTS: Invalid arguments, like improper channel id etc. app need to recheck the passed param and retry
+ @param INVALID_SERVICE_CONNECTION: The service connection indicated by the service handle does not exists. So creater service createServiceConnection() and retry
+ @param NETWORK_FAILURE: Data transfer failed because of network error. Retry again
+ @param BUFFER_FULL: Send buffer full.On receiving this application should wait for FDefOnSpaceAvailable before sending further data.
+ @param SDK_ERROR: Any other internal sdk error. App should recheck the params passed and retry
+ ****************************************************************************/
+typedef enum DataTransferResultCode {
+
+ DATA_SUCCESS = 0, ///< Data is sent successfully. App can continue to sendData() again
+ INVALID_ARGUMENTS, ///< Invalid arguments, like improper channel id etc. app need to recheck the passed param and retry
+ INVALID_SERVICE_CONNECTION, ///< The service connection indicated by the service handle does not exists. So creater service createServiceConnection() and retry
+ NETWORK_FAILURE, ///< The service connection indicated by the service handle does not exists. So creater service createServiceConnection() and retry
+ BUFFER_FULL, ///< Send buffer full.On receiving this application should wait for FDefOnSpaceAvailable before sending further data.
+ SDK_ERROR ///< Any other internal sdk error. App should recheck the params passed and retry
+}DataTransferResultCode;
+
+
+/***************************************************************************//**
+ @brief The enum defines the various connectivity types
+ @param SAP_BT: BT connectivity
+ @param SAP_BLE: BLE connectivity
+ @param SAP_TCP: TCP connectivity
+ @param SAP_USB: USB connectivity
+ ****************************************************************************/
+typedef enum ConnectivityType {
+
+ SAP_ALL =0, ///< All connectivity
+ SAP_BT=4 , ///< BT connectivity
+ SAP_BLE=8, ///< BLE connectivity
+ SAP_TCP_IP=16, ///< TCP connectivity
+ SAP_USB=32, ///< USB connectivity
+ SAP_CONNECTIVITY_END = 0xFF ///< End of Connectivity
+}ConnectivityType;
+
+
+/***************************************************************************//**
+ @brief The enum defines the status codes that may be used to convey generic states as needed for SAP interaction.
+ @param RESULT_TIMEOUT: When a request has timeout.
+ @param RESULT_FAILURE: On failure of a request.
+ @param RESULT_SUCCESS: On successfull execution of the request.
+ @param RESULT_INPROGRESS: Progressive status of SAP to indicate reason for temporary failure.
+ ****************************************************************************/
+typedef enum{
+
+ RESULT_TIMEOUT = -2,
+ RESULT_FAILURE =-1,
+ RESULT_SUCCESS =0,
+ RESULT_INPROGRESS = 1
+}SAP_RESULT_VAL;
+
+
+/***************************************************************************//**
+ @brief The enum defines the various Payload types
+ @param SAP_NONE: None
+ @param SAP_BINARY: Binary Payload
+ @param SAP_JSON: JSON Payload
+ @param SAP_ALL_PAYLOAD: Other PayloadTypes
+ ****************************************************************************/
+typedef enum PayloadType {
+
+ SAP_NONE = 0x00,
+ SAP_BINARY = 0x01, //BINARY Payloadtype supported
+ SAP_JSON = 0x02, //JSON PayloadType supported
+ SAP_ALL_PAYLOAD = 0xFF // Any other payloadType
+}PayloadType;
+
+typedef enum ErrorCode {
+
+ UNKNOWN_REASON = 0x00,///<Reason Unknown
+ SAP_ERROR_IPC_DISCONNECTED = 0x01,
+}SAPErrorCode;
+
+
+/***************************************************************************//**
+ @brief The enum defines the Qos Priority value as required by service profile
+ @param PRIORITY_LOW: Low Channel priority
+ @param PRIORITY_MEDIUM: Medium Channel priority
+ @param PRIORITY_HIGH: High channel priority is generally not preferred
+ ****************************************************************************/
+typedef enum Priority {
+
+ PRIORITY_LOW = 0X00, //Low priority
+ PRIORITY_MEDIUM, //Medium priority
+ PRIORITY_HIGH //High priority
+}SAPPriority;
+
+
+/*****************************************************************************
+ @brief The enum defines the QOS-Arrival data rate values
+ @param DATARATE_LOW: Low data rate
+ @param DATARATE_HIGH: High data rate
+ ****************************************************************************/
+typedef enum DataRate {
+
+ DATARATE_LOW = 0X00, //Low data rate
+ DATARATE_HIGH //High data rate
+}SAPDataRate;
+
+
+/*****************************************************************************
+ @brief The enum indicates the type of QoS support being requested
+ @param UNRESTRICTED_INORDER: Unrestricted SDU and In-Order Delivery
+ @param UNRESTRICTED_UNORDER: Unrestricted SDU and Unordered Delivery
+ @param RESTRICTED_INORDER: Restricted SDU and In-Order Delivery
+ @param RESTRICTED_UNORDER: Restricted SDU and Unordered Delivery
+ @param RELIABLITY_DISABLE: Retransmission disabled
+ @param RELIABILITY_ENABLE: Retransmission enabled
+ ****************************************************************************/
+typedef enum QosType {
+
+ UNRESTRICTED_INORDER = 0X00, //Unrestricted SDU and In-Order Delivery
+ UNRESTRICTED_UNORDER = 0X01, //Unrestricted SDU and Unordered Delivery
+ RESTRICTED_INORDER = 0X02, //Restricted SDU and In-Order Delivery
+ RESTRICTED_UNORDER = 0X03, //Restricted SDU and Unordered Delivery
+ RELIABLITY_DISABLE = 0X04, //Retransmission disabled
+ RELIABILITY_ENABLE = 0X05 //Retransmission enabled
+}SAPQosType;
+
+
+/*****************************************************************************
+ @brief The enum defines the limit of connections restricted to a serivce agent
+ @param SERVICE_LIMIT_ANY: No restrictions
+ @param SERVICE_LIMIT_ONE_ACCESSORY: Can connect to multiple profiles in one Accessory
+ @param SERVICE_LIMIT_ONE_PEERAGENT: Can connect to a single profile in multiple accessories
+ ****************************************************************************/
+typedef enum ServiceLimit{
+
+ SERVICE_LIMIT_ANY = 0X00, //Default
+ SERVICE_LIMIT_ONE_ACCESSORY, //Can connect to multiple profiles in one Accessory
+ SERVICE_LIMIT_ONE_PEERAGENT //Can connect to a single profile in multiple accessories
+}SAPServiceLimit;
+
+
+/***************************************************************************//**
+ @brief The structure tagQoSObject stores the details of Qos parameters associated with a channel
+ @param ubType: indicates the type of QoS support being requested
+ @param ubPriority: defines the Qos Priority value as required by service profile
+ @param ubDataRate: defines the QOS-Arrival data rate values
+ ****************************************************************************/
+typedef struct tagQoSObject{
+
+ SAPQosType ubType; //Type of Qos support
+ SAPPriority ubPriority; //Priority of the messages on the new session
+ SAPDataRate ubDataRate; //Rate at which data is sent
+}QoSObj;
+
+
+/***************************************************************************//**
+ @brief The structure tagChannelDesc is used to store the details associated with a channel
+ @param wChannelID: channel identifier.
+ @param ubNoOfPayloadType: No of payload type as listed in payloadTypeList.
+ @param payloadTypeList: Payload type supported (0 for JSON, 1 for Binary).
+ @param Qos: Qos requested from App
+ ****************************************************************************/
+typedef struct tagChannelDesc{
+
+ unsigned short int wChannelID; ///< Channel identifier
+ unsigned short int ubNoOfPayloadType; ///< No of payload type as listed in payloadTypeList.
+ PayloadType payloadTypeList; ///< List of payload types supported (0 for JSON, 1 for Binary)
+ QoSObj Qos; ///< QoS requested from App
+}ChannelDesc;
+
+
+/***************************************************************************//**
+ @brief The structure tagServiceDesc is used to store the details associated with a specific service
+ @param pchASPID: ASP Identifier that uniquely represent a profile.
+ @param pchSPFName: Friendly name for the ASP ID.
+ @param wConnectionTypeMask: Connectivity types that application is interested to support upon as per ConnectivityType.
+ @param ubRole: specifies if the application shall be a consumer (1) or provider(0).The role should be opposite for the 2 peers for a profile
+ @param pChDescArray : List of channels associated in the Service description.
+ @param numChannels : number of channels listed in pChDescList.
+ @param ubServiceLimit : Restricting the service connection based on App need
+ @param uwSvcWaitTime : Timeout value for Service connection establishment
+ ****************************************************************************/
+typedef struct tagServiceDesc{
+
+ char* pchASPID; ///< ASP Identifier that uniquely represent a profile.
+ char* pchSPFName; ///< Friendly name for the ASP ID.
+ int wConnectionTypeMask; ///< Connectivity types that application is interested to support upon as per ConnectivityType.
+ unsigned char ubRole; ///< specifies if the application shall be a consumer (1) or provider(0). The role should be opposite for the 2 peers for a profile
+ ChannelDesc *pChDescArray; ///< Array of channels associated in the Service description.
+ short int numChannels; ///< number of channels listed in pChDescList.
+ SAPServiceLimit ubServiceLimit; ///< Restricting the service connection based on App need
+ unsigned short int uwSvcWaitTime; ///< Timeout value for Service connection establishment in seconds
+}ServiceDesc;
+
+
+/***************************************************************************//**
+ @brief The structure tagPeerAgent is used to store the Peer agent details associated with a service profile ID
+ @param udwPeerDeviceID: Peer device ID
+ @param udwPeerAgentId: Peer agent running the service
+ @param pchPeerDeviceName: Peer Device Name
+ @param pchMACAddress: MAC Address
+ @param pchALEName: ALE Name
+ @param pchASPID: ASP ID supported
+ @param pchProfileVersion: ASP version
+ @param uwSvcWaitTime : Timeout value for Service connection establishment
+ ****************************************************************************/
+typedef struct tagPeerAgent {
+
+ unsigned int udwPeerDeviceID; ///< Peer device ID
+ unsigned int udwPeerAgentId; ///< Peer agent running the service
+ char *pchPeerDeviceName; ///< Peer Device Name
+ char *pchMACAddress; ///< MAC Address
+ char *pchALEName; ///< ALE Name
+ char *pchASPID; ///< ASP ID supported
+ char *pchProfileVersion; ///< ASP version
+ unsigned short int uwSvcWaitTime; ///< Timeout value for Service connection establishment
+}PeerAgent;
+
+
+/**************************************************************************//**
+ @brief To check the status of SAP connection
+ @returns : Returns integer value for sap connected status (Connected:1, Disconnected:0, Error:-1)
+* ************************************************************************** */
+int isSapConnected(void);
+
+/**************************************************************************//**
+@brief This function is called by the application to get the agent id assigned for its service profiles
+@param pchASPID [in] : Profile id of the service
+@param role [in] : Role (provider/consumer)
+@returns Returns SAP_RESULT_VAL with RESULT_SUCCESS if get agent id request initiated successfully
+@remarks registerNotifications() needs to be called prior to calling this API. It needs to be called from App context
+ The Agent Id will be returned to the application in the registerServiceAgentConfirm() callback
+* ************************************************************************** */
+SAP_RESULT_VAL getRegisteredServiceAgent(char* pchASPID, ServiceAgentRole role);
+
+/**************************************************************************//**
+@brief This function is called by the application for initialization operations. This will register the service id and links with corresponding agent Id .Result of this operation will be informed using FDefOnRegisterServiceAgentConfirm() callback.
+@param pRegServiceRequest [in] : Service Registration of the provider/consumer
+@returns Returns SAP_RESULT_VAL with RESULT_SUCCESS in case of successfully intiated registration or appropriate failure error if any error as per the SAP_RESULT_VAL ENUM.
+@remarks registerNotifications() needs to be called prior to calling this API. It needs to be called from App context
+* ************************************************************************** */
+ SAP_RESULT_VAL registerServiceAgent(ServiceDesc *pRegServiceRequest);
+
+/**************************************************************************//**
+ @brief This callback function gets triggered after registration of service agent registerServiceAgent() is completed .
+ @param wStatusCode [in] : int shall be returned with RESULT_SUCCESS in case of success and appropriate error code in case of failure.
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier of the application represented to the SAP framework locally. It needs to be used in API as needed.
+**************************************************************************** */
+typedef void (*FDefOnRegisterServiceAgentConfirm) (int wStatusCode, unsigned int uwLocalAgentId);
+
+/**************************************************************************//**
+@brief This will de-register the service from the SAP framework. Result of this operation will be informed using FDefOnDeregisterServiceAgentConfirm() callback.
+@param uwLocalAgentId [in]: LocalAgentId is unique identifier of the application represented to the SAP framework locally, which was returned as part of FDefOnRegisterServiceAgentComplete.
+@returns returns SAP_RESULT_VAL with RESULT_SUCCESS in case of successfully intiated deregistration or appropriate failure error if any error as per the SAP_RESULT_VAL ENUM.
+@remarks The API needs to be called from App context
+* ************************************************************************** */
+ SAP_RESULT_VAL deRegisterServiceAgent(unsigned int uwLocalAgentId);
+
+/**************************************************************************//**
+ @brief This is the callback function.This function gets triggerd after deregister profile deRegisterServiceAgent() is completed
+ @param wStatusCode [in] : SAP_RESULT_VAL shall be returned with RESULT_SUCCESS in case of success and appropriate error code in case of failure.
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier of the application represented to the SAP framework locally. It needs to be used in API as needed.
+ @returns returns SAP_VOID.
+* ************************************************************************** */
+typedef void (*FDefOnDeregisterServiceAgentConfirm) (int wStatusCode, unsigned int uwLocalAgentId);
+
+
+/**************************************************************************//**
+ @brief The function findPeerAgent fetches handle to the associated PeerAgent as per ones own ASP ID as specified in ServiceDesc. uwLocalAgentId shall be indicate the same.
+ The user will get the handle to remote PeerAgent in callback FDefOnPeerAgent.
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier that was received when FDefOnRegisterServiceAgentComplete callback was called.
+ @returns returns SAP_RESULT_VAL with RESULT_SUCCESS in case of success or appropriate failure error if any error as per the SAP_RESULT_VAL ENUM.
+ @remarks The API needs to be called from App context
+ ****************************************************************************/
+SAP_RESULT_VAL findPeerAgent(unsigned int uwLocalAgentId);
+
+
+/**************************************************************************//**
+ @brief This callback function gets triggered as a result of findPeerAgent() called by application.
+ @param pPeerAgent [in] : The handle to the PeerAgent that has been discovered on call of findPeerAgent.
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier of the application represented to the SAP framework locally. Should be same as one received in FDefOnRegisterServiceAgentConfirm callback.
+ @param wStatusCode[in] : Status code indicating success or failure on call of findPeerAgent as per the FindPeerAgentResponseCode ENUM.
+ @returns : returns SAP_VOID.
+* ************************************************************************** */
+typedef void (*FDefOnPeerAgent) (unsigned int uwLocalAgentId, PeerAgent* pPeerAgent, int wStatusCode);
+
+
+/**************************************************************************//**
+ @brief This callback function gets triggered when a matching Service Agent is registered in a connected peer.
+ @param pPeerAgent [in] : The handle to the PeerAgent that has a new service agent.
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier of the application represented to the SAP framework locally. This should be same as one received in FDefOnRegisterServiceAgentConfirm callback.
+ @returns : returns SAP_VOID.
+ @remarks: Upon receiving the PEER_AGENT_AVAILABLE the App can initiate a service Connection , Upon receiving the PEER_AGENT UNAVAILABLE the App has to wait for the PEER_AVAILABLE.
+* ************************************************************************** */
+typedef void (*FDefOnPeerAgentIndication) (unsigned int uwLocalAgentId, PeerAgent* pPeerAgent, PeerStatus peerStatus);
+
+
+/**************************************************************************//**
+ @brief The function createServiceConnection establishes service connection with specified peer agent.The service connection success/failure is indicated via callback FDefOnServiceConnectionConfirm().
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier that was received in FDefOnRegisterServiceAgentComplete callback.
+ @param pPeerAgent [in]:Peer Agent containing the Service Id, App Id and Device id received in FDefOnPeerAgent callback.
+ @returns Returns SAP_RESULT_VAL with RESULT_SUCCESS in case of success or appropriate failure error if any error as per the SAP_RESULT_VAL ENUM.
+ @remarks RESULT_SUCCESS indicates that request for service connection has been successfully initiated. The actual service connection creation success/failure is indicated in callback FDefOnServiceConnectionConfirm(). The API needs to be called from App context
+*************************************************************************** */
+SAP_RESULT_VAL createServiceConnection(unsigned int uwLocalAgentId, PeerAgent* pPeerAgent);
+
+
+/**************************************************************************//**
+ @brief This callback function will get triggered when a new incoming service connection request is received from a remote peer.
+ The application shall call the function acceptServiceConnection to accept or rejectServiceConnection to reject the connection.
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier that conveys local identifier of the Agent for which which service connection indication was received.
+ @param uwServiceHandle [in] : The handle for the service connection indicated.
+ @param pPeerAgent [in]:Peer Agent containing the Service Id, App Id and Device id.
+ @returns Returns SAP_VOID.
+*************************************************************************** */
+typedef void (*FDefOnServiceConnectionIndication) (unsigned int uwLocalAgentId, unsigned int uwServiceHandle, PeerAgent* pPeerAgent);
+
+
+/**************************************************************************//**
+ @brief Accept an incoming service connection request. This is typically called from the registered callback FDefOnServiceConnectionIndication().
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier that may be used to convey the specific identifier of the localAgentId with which service connection request was received.
+ @param uwServiceHandle [in] : The handle for the incoming service connection request.
+ @param pPeerAgent [in]:Peer Agent containing the Service Id, App Id and Device id
+ @returns Returns SAP_RESULT_VAL with RESULT_SUCCESS in case of success or appropriate failure error if any error as per the SAP_RESULT_VAL ENUM.
+ @remarks The API needs to be called from App context
+**************************************************************************** */
+SAP_RESULT_VAL acceptServiceConnection(unsigned int uwLocalAgentId, unsigned int uwServiceHandle, PeerAgent* pPeerAgent);
+
+
+/**************************************************************************//**
+ @brief Reject an incoming service connection request. This is typically called from the registered callback FDefOnServiceConnectionIndication().
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier that may be used to convey the specific identifier of the localAgentId with which service connection request was received.
+ @param uwServiceHandle [in] : The handle for the incoming service connection request.
+ @param pPeerAgent [in]:Peer Agent containing the Service Id, App Id and Device id
+ @returns : Returns SAP_RESULT_VAL with RESULT_SUCCESS in case of success or appropriate failure error if any error as per the SAP_RESULT_VAL ENUM.
+ @remarks The API needs to be called from App context
+* ************************************************************************** */
+
+SAP_RESULT_VAL rejectServiceConnection(unsigned int uwLocalAgentId, unsigned int uwServiceHandle, PeerAgent* pPeerAgent);
+
+
+/**************************************************************************//**
+ @brief This callback function gets triggerd to notify the success or failure of service connection request initiated by the application. Will be sent only to the initiator of the connection.
+ @param uwLocalAgentId [in]: LocalAgentId is unique identifier that may be used to convey the specific identifier of the localAgentId with which service connection was established.
+ @param uwServiceHandle [in] : The handle for the service connection.
+ @param pPeerAgent [in]:Peer Agent containing the Service Id, App Id and Device id
+ @param wResponseCode [in]: status code: Status code value is one of the ServiceConnectionResponseCode enum.
+ @returns Returns SAP_VOID.
+* ************************************************************************** */
+typedef void (*FDefOnServiceConnectionConfirm) (unsigned int uwLocalAgentId, unsigned int uwServiceHandle, PeerAgent* pPeerAgent, int wResponseCode);
+
+
+/**************************************************************************//**
+ @brief Send data over a service connection. If send fails with BUFFER_FULL app should wait for FDefOnSpaceAvailable() callback
+ @param uwServiceHandle [in] : The handle for the service connection.
+ @param ubChannelId [in] : The channel id on which data has to be sent
+ @param uwPayloadLength [in] : The length of payload data..
+ @param pvBuffer [in]: The data buffer to be sent
+ @returns Returns one of the status codes in DataTransferResultCode ENUM.
+ @remarks Max 65528 bytes can be sent . sendData should not be called in SAP callback and sendData should not be called simulataneous from different threads.
+* ************************************************************************** */
+DataTransferResultCode sendData(unsigned int uwServiceHandle, unsigned short int ubChannelId, unsigned int uwPayloadLength,void *pvBuffer);
+
+
+/**************************************************************************//**
+ @brief Send Secure data over a service connection. If send fails with BUFFER_FULL app should wait for FDefOnSpaceAvailable() callback
+ @param uwServiceHandle [in] : The handle for the service connection.
+ @param ubChannelId [in] : The channel id on which data has to be sent
+ @param uwPayloadLength [in] : The length of payload data..
+ @param pvBuffer [in]: The data buffer to be sent
+ @returns Returns one of the status codes in DataTransferResultCode ENUM.
+ @remarks Max 65528 bytes can be sent . sendSecureData should not be called in SAP callback and sendSecureData should not be called simulataneous from different threads.
+* ************************************************************************** */
+DataTransferResultCode sendSecureData(unsigned int uwServiceHandle, unsigned short int ubChannelId, unsigned int uwPayloadLength,void *pvBuffer);
+
+
+/**************************************************************************//**
+ @brief This callback function gets triggered when the application receives data from an active service connection.
+ @param uwServiceHandle [in] : The handle for the service connection on which data has been received.
+ @param ubChannelId [in] : The channel id on which data has been received
+ @param uwPayloadLength [in] : The length of payload data.
+ @param pvBuffer [in]: The data buffer that has been received
+ @returns Returns SAP_VOID.
+* ************************************************************************** */
+typedef void (*FDefOnReceive) (unsigned int uwServiceHandle, unsigned short int uwChannelId, unsigned int uwPayloadLength, void *pvBuffer);
+
+
+/**************************************************************************//**
+@brief Terminate service connection corresponding to given service handle.
+@param uwServiceHandle [in] : The handle of the service Connection. The same handle returned in FDefOnServiceConnectionConfirm() should be used.
+@returns Returns RESULT_SUCCESS if successfully intitated the request else appropriate failure error code as specified in SAP_RESULT_VAL ENUM.
+@remarks RESULT_SUCCESS indicates that request for terminate service connection has been succesfully processed. The Api needs to be called in App context
+* ************************************************************************** */
+SAP_RESULT_VAL terminateServiceConnection(unsigned int uwServiceHandle);
+
+
+/**************************************************************************//**
+ @brief This callback function will get triggered when a service connection is terminated as a result of a trigger from remote peer.
+ @param uwServiceHandle [in] : The handle for the service connection.
+ @returns : returns SAP_VOID.
+* ************************************************************************* */
+typedef void (*FDefOnServiceTerminationIndication) (unsigned int uwServiceHandle,int wStatusCode);
+
+
+/**************************************************************************//**
+ @brief This callback function gets triggered when error occurs but was not relayed as part of a request-response transaction. Triggered also if the other side has called terminateServiceConnection()
+ @param uwServiceHandle [in] : The handle for the service connection on which data has been received.
+ @param dwErrorCode [in] : Error Code defined in SAPErrorCode Enum
+ @returns Returns SAP_VOID.
+* ************************************************************************** */
+typedef void (*FDefOnError) (unsigned int uwServiceHandle, unsigned int dwErrorCode);
+
+
+/**************************************************************************//**
+ @brief This callback function gets triggerd when space is avilable for application to write. Application should wait for this callback if send returns failure with BUFFER_FULL
+ @param uwServiceHandle [in] : The handle for the service connection on which data has been received.
+ @param uwChannelId [in] : The channel identifier on which the onSpaceAvailable callback is called.
+ @param ulSpaceAvailable [in] : How much space is available in bytes
+ @returns Returns DataTransferResultCode.
+* ************************************************************************** */
+typedef void (*FDefOnSpaceAvailable) (unsigned int uwServiceHandle, unsigned short int uwChannelId, unsigned int ulSpaceAvailable);
+
+/***************************************************************************//**
+ @brief The structure holds references to callback for application for various events from framework.
+ @param pfnOnRegisterServiceAgentConfirm: Register Service Agent Confirmation function pointer
+ @param pfnOnDataIndication: Data Indication function pointer
+ @param FDefOnServiceConnectionIndication: Service connection indication function pointer
+ @param pfnOnServiceTerminationIndication: Service termination indication function pointer
+ @param pfnOnServiceCreateConfirm: Service create confirm function pointer
+ @param pfnOnPeerAgent: Peer Agent availability function pointer
+ @param pfnOnSpaceAvailable: Space available for send function pointer
+ @param pfnOnError: Error function pointer
+ @param pfnOnDeRegisterServiceAgentConfirm: DeRegister service Agent function pointer
+ ****************************************************************************/
+typedef void (*FDefOnDeviceStatus) (ConnectivityType device_type, enum device_status status);
+
+typedef struct tagSAPNotification
+{
+ FDefOnRegisterServiceAgentConfirm pfnOnRegisterServiceAgentConfirm; ///< Register Service Agent Confirmation function pointer
+ FDefOnReceive pfnOnDataIndication; ///< Data Indication function pointer
+ FDefOnServiceConnectionIndication pfnOnServiceConnectionIndication; ///< Service connection indication function pointer
+ FDefOnServiceTerminationIndication pfnOnServiceTerminationIndication; ///< Service termination indication function pointer
+ FDefOnServiceConnectionConfirm pfnOnServiceCreateConfirm; ///< Service create confirm function pointer
+ FDefOnPeerAgent pfnOnPeerAgent; ///< Peer Agent availability function pointer
+ FDefOnSpaceAvailable pfnOnSpaceAvailable; ///< Space available for send function pointer
+ FDefOnError pfnOnError; ///< Error function pointer
+ FDefOnDeregisterServiceAgentConfirm pfnOnDeRegisterServiceAgentConfirm; ///< DeRegister service Agent function pointer
+ FDefOnDeviceStatus pfnDeviceStatus;
+ FDefOnPeerAgentIndication pfnOnPeerAgentNoti; ///< Peer Agent Notification
+}SAPNotification;
+
+
+ /**************************************************************************//**
+@brief This function registers all the callbacks in SAPNotification. This needs to be the first API that needs to be called from the App.
+@param notiFuncs [in] : Notification functions which are to be registered for getting callback.
+@returns Returns SAP_RESULT_VAL with RESULT_SUCCESS in case of success and appropriate failure error if any error as per the SAP_RESULT_VAL ENUM.
+* ************************************************************************** */
+SAP_RESULT_VAL registerNotifications(SAPNotification notiFuncs);
+
+
+/**************************************************************************//**
+@brief This function deregisters all the callbacks in SAPNotification. This should be called when App get FDefOnError callback.
+@returns Returns SAP_RESULT_VAL with RESULT_SUCCESS in case of success and appropriate failure error if any error as per the SAP_RESULT_VAL ENUM.
+* ************************************************************************** */
+SAP_RESULT_VAL deregisterNotifications(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_SAPINTERFACE_H_ */