* Callback function type for editing bluetooth advertisement data before starting bluetooth advertisement.
* param[in] max_data_size Maximal size of advertisement data array
* param[out] data Advertisement data array
- * param[out] real_data_size Real size of advertisement data array
+ * param[out] data_size Actual Data size of advertisement data array
*/
-typedef void (*CAAdvertisementDataGetterCB)(int max_data_size, char *data, int *real_data_size);
+typedef void (*CAAdvertisementDataGetterCB)(int max_data_size, char *data, int *data_size);
#ifdef __cplusplus
} /* extern "C" */
//custom advertisement data setting
#if defined(__TIZEN__) && defined(LE_ADAPTER) && defined(BLE_CUSTOM_ADVERTISE)
+/**
+ * Sets Custom Advertisement Data.
+ * @param[in] data Advertisment Data buffer.
+ * @param[in] length Length of buffer.
+ *
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_INVALID_PARAM
+ */
CAResult_t CASetAdvertisementData(const char* data, int length);
+/**
+ * Set function that will be called before starting advertising.
+ * Provided data and length will be used to set advertisement data.
+ * @param[in] getter Custom advertisement data getter callback.
+ *
+ */
void CASetAdvertisementDataGetter(CAAdvertisementDataGetterCB getter);
+/**
+ * set if advertising should be started automatically.
+ * By default advertising is automatically started.
+ * @param[in] autoAdvertisement true for automatic start
+ */
void CASetAutoAdvertisement(bool autoAdvertisement);
+/**
+ * Scan and set data for custom bluetooth advertisement.
+ * @param[in] data Array with custom bluetooth advertisement data.
+ * @param[in] length Length of data array.
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_STATUS_INVALID_PARAM
+ */
CAResult_t CASetScanResponseData(const char* data, int length);
#endif
void CAsetServerAdvertisementDataGetter(CAAdvertisementDataGetterCB getter);
/**
- * Used to set auto advertisement feature on and off.
+ * Used to Start/Stop auto advertisement feature.
*
* @param[in] auto_advertisement Boolean flag to turn auto advertisement feature on and off.
*/
-void CAsetServerAutoAdvertisement(bool auto_advertisement);
+void CAsetServerAutoAdvertisement(bool autoAdvertisement);
/**
* Used to Start Server send response data
static int custom_scanrsp_data_length = 0;
/**
- * Maximum lenght of BLE advertisement packet data size is acctually 24 bytes,
+ * Maximum length of BLE advertisement packet data size is acctually 24 bytes,
* but for safety reason 1 additional byte is allocated.
*/
-const int max_ble_advertisement_packet_data_size = 25;
+const int g_leAdvPacketDataSizeMax = 25;
CAResult_t CAsetServerAdvertisementData(const char *data, int length)
OIC_LOG(DEBUG, TAG, "OUT");
}
-void CAsetServerAutoAdvertisement(bool auto_advertisement)
+void CAsetServerAutoAdvertisement(bool autoAdvertisement)
{
OIC_LOG(DEBUG, TAG, "IN");
oc_mutex_lock(g_leServerStateMutex);
- g_leServerAutoAdvertisement = auto_advertisement;
+ g_leServerAutoAdvertisement = autoAdvertisement;
oc_mutex_unlock(g_leServerStateMutex);
OIC_LOG(DEBUG, TAG, "OUT");
if(g_leServerAdvertisementDataGetter)
{
int length;
- data = (char*) malloc(max_ble_advertisement_packet_data_size);
- g_leServerAdvertisementDataGetter(max_ble_advertisement_packet_data_size, data, &length);
+ data = (char*) malloc(g_leAdvPacketDataSizeMax);
+ g_leServerAdvertisementDataGetter(g_leAdvPacketDataSizeMax, data, &length);
if(!data || length <= 0)
{
OIC_LOG(WARNING, TAG, "Invalid data. Custom advertisement data will not be set.");
}
//This array is freed here because it's used in CALEStartAdvertiseImpl() method (freeing earlier causes bluetooth to crash)
- free(data);
+ if(data)
+ free(data);
OIC_LOG(DEBUG, TAG, "OUT");
return res;
}