[Adapt: OAL] Add LE Advertising API's in OAL 35/119835/1
authorAnupam Roy <anupam.r@samsung.com>
Mon, 20 Mar 2017 08:37:25 +0000 (14:07 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Mon, 20 Mar 2017 08:37:25 +0000 (14:07 +0530)
Change-Id: Ie017765df7dc506056880c8e542eb6eb66b0a335
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
bt-oal/CMakeLists.txt
bt-oal/common/oal-utils.c
bt-oal/common/oal-utils.h
bt-oal/include/oal-adapter-mgr.h
bt-oal/include/oal-event.h
bt-oal/include/oal-gatt.h [new file with mode: 0644]
bt-oal/oal-adapter-mgr.c
bt-oal/oal-gatt.c [new file with mode: 0644]

index dbe51fd..1b04e58 100755 (executable)
@@ -22,6 +22,7 @@ oal-avrcp-tg.c
 oal-avrcp-ctrl.c
 oal-hfp.c
 oal-hdp.c
+oal-gatt.c
 common/oal-utils.c
 common/oal-common.c
 common/oal-event-dispatcher.c
index 2d138de..1f53799 100755 (executable)
@@ -140,6 +140,28 @@ void uuid_to_string(service_uuid_t *p_uuid, char *str)
                        ntohl(uuid4), ntohs(uuid5));
 }
 
+void uuid_to_stringname(service_uuid_t *p_uuid, char *str)
+{
+       uint32_t uuid0, uuid4;
+       uint16_t uuid1, uuid2, uuid3, uuid5;
+       const char *uuid_name;
+
+       memcpy(&uuid0, &(p_uuid->uuid[0]), 4);
+       memcpy(&uuid1, &(p_uuid->uuid[4]), 2);
+       memcpy(&uuid2, &(p_uuid->uuid[6]), 2);
+       memcpy(&uuid3, &(p_uuid->uuid[8]), 2);
+       memcpy(&uuid4, &(p_uuid->uuid[10]), 4);
+       memcpy(&uuid5, &(p_uuid->uuid[14]), 2);
+
+       uuid_name = dump_uuid_name(ntohl(uuid0));
+
+       snprintf((char *)str, 2*BT_UUID_STRING_MAX, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x--%s",
+                       ntohl(uuid0), ntohs(uuid1),
+                       ntohs(uuid2), ntohs(uuid3),
+                       ntohl(uuid4), ntohs(uuid5),
+                       !(g_strcmp0(dump_uuid_name(ntohl(uuid0)), "--")) ? dump_uuid_name(((uuid4) >> 16)): uuid_name);
+}
+
 int hex2bin( const char *s )
 {
        int ret=0;
@@ -407,3 +429,346 @@ char* convert_property_type_2_str(bt_property_type_t prop_type)
        }
 }
 
+const char *dump_uuid_name(int uuid_no)
+{
+    switch(uuid_no)
+    {
+        CASE_RETURN_STR(BASE)
+        CASE_RETURN_STR(SDP)
+        CASE_RETURN_STR(UDP)
+        CASE_RETURN_STR(RFCOMM)
+        CASE_RETURN_STR(TCP)
+        CASE_RETURN_STR(TCS_BIN)
+        CASE_RETURN_STR(TCS_AT)
+        CASE_RETURN_STR(ATT)
+        CASE_RETURN_STR(OBEX)
+        CASE_RETURN_STR(IP)
+        CASE_RETURN_STR(FTP)
+        CASE_RETURN_STR(HTTP)
+        CASE_RETURN_STR(WSP)
+        CASE_RETURN_STR(BNEP)
+        CASE_RETURN_STR(UPNP)
+        CASE_RETURN_STR(HIDP)
+        CASE_RETURN_STR(HardcopyControlChannel)
+        CASE_RETURN_STR(HardcopyDataChannel)
+        CASE_RETURN_STR(HardcopyNotification)
+        CASE_RETURN_STR(AVCTP)
+        CASE_RETURN_STR(AVDTP)
+        CASE_RETURN_STR(CMTP)
+        CASE_RETURN_STR(MCAPControlChannel)
+        CASE_RETURN_STR(MCAPDataChannel)
+        CASE_RETURN_STR(L2CAP)
+        CASE_RETURN_STR(ServiceDiscoveryServerServiceClassID)
+        CASE_RETURN_STR(BrowseGroupDescriptorServiceClassID)
+        CASE_RETURN_STR(SerialPort)
+        CASE_RETURN_STR(LANAccessUsingPPP)
+        CASE_RETURN_STR(DialupNetworking)
+        CASE_RETURN_STR(IrMCSync)
+        CASE_RETURN_STR(OBEXObjectPush)
+        CASE_RETURN_STR(OBEXFileTransfer)
+        CASE_RETURN_STR(IrMCSyncCommand)
+        CASE_RETURN_STR(Headset)
+        CASE_RETURN_STR(CordlessTelephony)
+        CASE_RETURN_STR(AudioSource)
+        CASE_RETURN_STR(AudioSink)
+        CASE_RETURN_STR(AV_RemoteControlTarget)
+        CASE_RETURN_STR(AdvancedAudioDistribution)
+        CASE_RETURN_STR(AV_RemoteControl)
+        CASE_RETURN_STR(AV_RemoteControlController)
+        CASE_RETURN_STR(Intercom)
+        CASE_RETURN_STR(Fax)
+        CASE_RETURN_STR(Headset_Audio_Gateway)
+        CASE_RETURN_STR(WAP)
+        CASE_RETURN_STR(WAP_CLIENT)
+        CASE_RETURN_STR(PANU)
+        CASE_RETURN_STR(NAP)
+        CASE_RETURN_STR(GN)
+        CASE_RETURN_STR(DirectPrinting)
+        CASE_RETURN_STR(ReferencePrinting)
+        CASE_RETURN_STR(Basic_Imaging_Profile)
+        CASE_RETURN_STR(ImagingResponder)
+        CASE_RETURN_STR(ImagingAutomaticArchive)
+        CASE_RETURN_STR(ImagingReferencedObjects)
+        CASE_RETURN_STR(Handsfree)
+        CASE_RETURN_STR(HandsfreeAudioGateway)
+        CASE_RETURN_STR(DirectPrintingReferenceObjectsService)
+        CASE_RETURN_STR(ReflectedUI)
+        CASE_RETURN_STR(BasicPrinting)
+        CASE_RETURN_STR(PrintingStatus)
+        CASE_RETURN_STR(HumanInterfaceDeviceService)
+        CASE_RETURN_STR(HardcopyCableReplacement)
+        CASE_RETURN_STR(HCR_Print)
+        CASE_RETURN_STR(HCR_Scan)
+        CASE_RETURN_STR(Common_ISDN_Access)
+        CASE_RETURN_STR(SIM_Access)
+        CASE_RETURN_STR(Phonebook_Access_PCE)
+        CASE_RETURN_STR(Phonebook_Access_PSE)
+        CASE_RETURN_STR(Phonebook_Access)
+        CASE_RETURN_STR(Headset_HS)
+        CASE_RETURN_STR(Message_Access_Server)
+        CASE_RETURN_STR(Message_Notification_Server)
+        CASE_RETURN_STR(Message_Access_Profile)
+        CASE_RETURN_STR(GNSS)
+        CASE_RETURN_STR(GNSS_Server)
+        CASE_RETURN_STR(ThreeD_Display)
+        CASE_RETURN_STR(ThreeD_Glasses)
+        CASE_RETURN_STR(ThreeD_Synchronization)
+        CASE_RETURN_STR(MPS_Profile)
+        CASE_RETURN_STR(MPS_SC)
+        CASE_RETURN_STR(CTN_Access_Service)
+        CASE_RETURN_STR(CTN_Notification_Service)
+        CASE_RETURN_STR(CTN_Profile)
+        CASE_RETURN_STR(PnPInformation)
+        CASE_RETURN_STR(GenericNetworking)
+        CASE_RETURN_STR(GenericFileTransfer)
+        CASE_RETURN_STR(GenericAudio)
+        CASE_RETURN_STR(GenericTelephony)
+        CASE_RETURN_STR(UPNP_Service)
+        CASE_RETURN_STR(UPNP_IP_Service)
+        CASE_RETURN_STR(ESDP_UPNP_IP_PAN)
+        CASE_RETURN_STR(ESDP_UPNP_IP_LAP)
+        CASE_RETURN_STR(ESDP_UPNP_L2CAP)
+        CASE_RETURN_STR(VideoSource)
+        CASE_RETURN_STR(VideoSink)
+        CASE_RETURN_STR(VideoDistribution)
+        CASE_RETURN_STR(HDP)
+        CASE_RETURN_STR(HDP_Source)
+        CASE_RETURN_STR(HDP_Sink)
+               CASE_RETURN_STR(Generic_Access)
+               CASE_RETURN_STR(Generic_Attribute)
+               CASE_RETURN_STR(Immediate_Alert)
+               CASE_RETURN_STR(Link_Loss)
+               CASE_RETURN_STR(Tx_Power)
+               CASE_RETURN_STR(Current_Time)
+               CASE_RETURN_STR(Reference_Time_Update)
+               CASE_RETURN_STR(Next_Dst_Change)
+               CASE_RETURN_STR(Glucose)
+               CASE_RETURN_STR(Health_Thermometer)
+               CASE_RETURN_STR(Device_Information)
+               CASE_RETURN_STR(Heart_Rate)
+               CASE_RETURN_STR(Phone_Alert_Status)
+               CASE_RETURN_STR(Battery_Service)
+               CASE_RETURN_STR(Blood_Pressure)
+               CASE_RETURN_STR(Alert_Notification)
+               CASE_RETURN_STR(Human_Interface_Device)
+               CASE_RETURN_STR(Scan_Parameters)
+               CASE_RETURN_STR(Running_Speed_And_Cadence)
+               CASE_RETURN_STR(Automation_IO)
+               CASE_RETURN_STR(Cycling_Speed_And_Cadence)
+               CASE_RETURN_STR(Cycling_Power)
+               CASE_RETURN_STR(Location_And_Navigation)
+               CASE_RETURN_STR(Environmental_Sensing)
+               CASE_RETURN_STR(Body_Composition)
+               CASE_RETURN_STR(User_Data)
+               CASE_RETURN_STR(Weight_Scale)
+               CASE_RETURN_STR(Bond_Management)
+               CASE_RETURN_STR(Continuous_Glucose_Monitoring)
+               CASE_RETURN_STR(Internet_Protocol_Support)
+               CASE_RETURN_STR(Indoor_Positioning)
+               CASE_RETURN_STR(Pulse_Oximeter)
+               CASE_RETURN_STR(Http_Proxy)
+               CASE_RETURN_STR(Transport_Discovery)
+               CASE_RETURN_STR(Object_Transfer)
+               CASE_RETURN_STR(Gap_Device_Name)
+               CASE_RETURN_STR(Gap_Appearance)
+               CASE_RETURN_STR(Gap_Peripheral_Privacy_Flag)
+               CASE_RETURN_STR(Gap_Reconnection_Address)
+               CASE_RETURN_STR(Gap_Peripheral_Preferred_Connection_Parameters)
+               CASE_RETURN_STR(Gatt_Service_Changed)
+               CASE_RETURN_STR(Alert_Level)
+               CASE_RETURN_STR(Tx_Power_Level)
+               CASE_RETURN_STR(Date_Time)
+               CASE_RETURN_STR(Day_Of_Week)
+               CASE_RETURN_STR(Day_Date_Time)
+               CASE_RETURN_STR(Exact_Time_256)
+               CASE_RETURN_STR(Dst_Offset)
+               CASE_RETURN_STR(Time_Zone)
+               CASE_RETURN_STR(Local_Time_Information)
+               CASE_RETURN_STR(Time_With_Dst)
+               CASE_RETURN_STR(Time_Accuracy)
+               CASE_RETURN_STR(Time_Source)
+               CASE_RETURN_STR(Reference_Time_Information)
+               CASE_RETURN_STR(Time_Update_Control_Point)
+               CASE_RETURN_STR(Time_Update_State)
+               CASE_RETURN_STR(Glucose_Measurement)
+               CASE_RETURN_STR(Battery_Level)
+               CASE_RETURN_STR(Temperature_Measurement)
+               CASE_RETURN_STR(Temperature_Type)
+               CASE_RETURN_STR(Intermediate_Temperature)
+               CASE_RETURN_STR(Measurement_Interval)
+               CASE_RETURN_STR(Boot_Keyboard_Input_Report)
+               CASE_RETURN_STR(System_Id)
+               CASE_RETURN_STR(Model_Number_String)
+               CASE_RETURN_STR(Serial_Number_String)
+               CASE_RETURN_STR(Firmware_Revision_String)
+               CASE_RETURN_STR(Hardware_Revision_String)
+               CASE_RETURN_STR(Software_Revision_String)
+               CASE_RETURN_STR(Manufacturer_Name_String)
+               CASE_RETURN_STR(Regulatory_Certification_Data_List)
+               CASE_RETURN_STR(Current_Time_Charac)
+               CASE_RETURN_STR(Magnetic_Declination)
+               CASE_RETURN_STR(Scan_Refresh)
+               CASE_RETURN_STR(Boot_Keyboard_Output_Report)
+               CASE_RETURN_STR(Boot_Mouse_Input_Report)
+               CASE_RETURN_STR(Glucose_Measurement_Context)
+               CASE_RETURN_STR(Blood_Pressure_Measurement)
+               CASE_RETURN_STR(Intermediate_Cuff_Pressure)
+               CASE_RETURN_STR(Heart_Rate_Measurement)
+               CASE_RETURN_STR(Body_Sensor_Location)
+               CASE_RETURN_STR(Heart_Rate_Control_Point)
+               CASE_RETURN_STR(Alert_Status)
+               CASE_RETURN_STR(Ringer_Control_Point)
+               CASE_RETURN_STR(Ringer_Setting)
+               CASE_RETURN_STR(Alert_Category_Id_Bit_Mask)
+               CASE_RETURN_STR(Alert_Category_Id)
+               CASE_RETURN_STR(Alert_Notification_Control_Point)
+               CASE_RETURN_STR(Unread_Alert_Status)
+               CASE_RETURN_STR(New_Alert)
+               CASE_RETURN_STR(Supported_New_Alert_Category)
+               CASE_RETURN_STR(Supported_Unread_Alert_Category)
+               CASE_RETURN_STR(Blood_Pressure_Feature)
+               CASE_RETURN_STR(Hid_Information)
+               CASE_RETURN_STR(Report_Map)
+               CASE_RETURN_STR(Hid_Control_Point)
+               CASE_RETURN_STR(Report)
+               CASE_RETURN_STR(Protocol_Mode)
+               CASE_RETURN_STR(Scan_Interval_Window)
+               CASE_RETURN_STR(Pnp_Id)
+               CASE_RETURN_STR(Glucose_Feature)
+               CASE_RETURN_STR(Record_Access_Control_Point)
+               CASE_RETURN_STR(Rsc_Measurement)
+               CASE_RETURN_STR(Rsc_Feature)
+               CASE_RETURN_STR(Sc_Control_Point)
+               CASE_RETURN_STR(Digital)
+               CASE_RETURN_STR(Analog)
+               CASE_RETURN_STR(Aggregate)
+               CASE_RETURN_STR(Csc_Measurement)
+               CASE_RETURN_STR(Csc_Feature)
+               CASE_RETURN_STR(Sensor_Location)
+               CASE_RETURN_STR(Plx_Spot_Check_Measurement)
+               CASE_RETURN_STR(Plx_Continuous_Measurement)
+               CASE_RETURN_STR(Plx_Features)
+               CASE_RETURN_STR(Cycling_Power_Measurement)
+               CASE_RETURN_STR(Cycling_Power_Vector)
+               CASE_RETURN_STR(Cycling_Power_Feature)
+               CASE_RETURN_STR(Cycling_Power_Control_Point)
+               CASE_RETURN_STR(Location_And_Speed)
+               CASE_RETURN_STR(Navigation)
+               CASE_RETURN_STR(Position_Quality)
+               CASE_RETURN_STR(Ln_Feature)
+               CASE_RETURN_STR(Ln_Control_Point)
+               CASE_RETURN_STR(Elevation)
+               CASE_RETURN_STR(Pressure)
+               CASE_RETURN_STR(Temperature)
+               CASE_RETURN_STR(Humidity)
+               CASE_RETURN_STR(True_Wind_Speed)
+               CASE_RETURN_STR(True_Wind_Direction)
+               CASE_RETURN_STR(Apparent_Wind_Speed)
+               CASE_RETURN_STR(Apparent_Wind_Direction)
+               CASE_RETURN_STR(Gust_Factor)
+               CASE_RETURN_STR(Pollen_Concentration)
+               CASE_RETURN_STR(Uv_Index)
+               CASE_RETURN_STR(Irradiance)
+               CASE_RETURN_STR(Rainfall)
+               CASE_RETURN_STR(Wind_Chill)
+               CASE_RETURN_STR(Heat_Index)
+               CASE_RETURN_STR(Dew_Point)
+               CASE_RETURN_STR(Descriptor_Value_Changed)
+               CASE_RETURN_STR(Aerobic_Threshold)
+               CASE_RETURN_STR(Age)
+               CASE_RETURN_STR(Anaerobic_Heart_Rate_Lower_Limit)
+               CASE_RETURN_STR(Anaerobic_Heart_Rate_Upper_Limit)
+               CASE_RETURN_STR(Anaerobic_Threshold)
+               CASE_RETURN_STR(Aerobic_Heart_Rate_Upper_Limit)
+               CASE_RETURN_STR(Date_Of_Birth)
+               CASE_RETURN_STR(Date_Of_Threshold_Assessment)
+               CASE_RETURN_STR(Email_Address)
+               CASE_RETURN_STR(Fat_Burn_Heart_Rate_Lower_Limit)
+               CASE_RETURN_STR(Fat_Burn_Heart_Rate_Upper_Limit)
+               CASE_RETURN_STR(First_Name)
+               CASE_RETURN_STR(Five_Zone_Heart_Rate_Limits)
+               CASE_RETURN_STR(Gender)
+               CASE_RETURN_STR(Heart_Rate_Max)
+               CASE_RETURN_STR(Height)
+               CASE_RETURN_STR(Hip_Circumference)
+               CASE_RETURN_STR(Last_Name)
+               CASE_RETURN_STR(Maximum_Recommended_Heart_Rate)
+               CASE_RETURN_STR(Resting_Heart_Rate)
+               CASE_RETURN_STR(Sport_Type_For_Aerobic_And_Anaerobic_Thresholds)
+               CASE_RETURN_STR(Three_Zone_Heart_Rate_Limits)
+               CASE_RETURN_STR(Two_Zone_Heart_Rate_Limit)
+               CASE_RETURN_STR(Vo2_Max)
+               CASE_RETURN_STR(Waist_Circumference)
+               CASE_RETURN_STR(Weight)
+               CASE_RETURN_STR(Database_Change_Increment)
+               CASE_RETURN_STR(User_Index)
+               CASE_RETURN_STR(Body_Composition_Feature)
+               CASE_RETURN_STR(Body_Composition_Measurement)
+               CASE_RETURN_STR(Weight_Measurement)
+               CASE_RETURN_STR(Weight_Scale_Feature)
+               CASE_RETURN_STR(User_Control_Point)
+               CASE_RETURN_STR(Magnetic_Flux_Density_2D)
+               CASE_RETURN_STR(Magnetic_Flux_Density_3D)
+               CASE_RETURN_STR(Language)
+               CASE_RETURN_STR(Barometric_Pressure_Trend)
+               CASE_RETURN_STR(Bond_Management_Control_Point)
+               CASE_RETURN_STR(Bond_Management_Feature)
+               CASE_RETURN_STR(Gap_Central_Address_Resolution_Support)
+               CASE_RETURN_STR(Cgm_Measurement)
+               CASE_RETURN_STR(Cgm_Feature)
+               CASE_RETURN_STR(Cgm_Status)
+               CASE_RETURN_STR(Cgm_Session_Start_Time)
+               CASE_RETURN_STR(Cgm_Session_Run_Time)
+               CASE_RETURN_STR(Cgm_Specific_Ops_Control_Point)
+               CASE_RETURN_STR(Indoor_Positioning_Configuration)
+               CASE_RETURN_STR(Latitude)
+               CASE_RETURN_STR(Longitude)
+               CASE_RETURN_STR(Local_North_Coordinate)
+               CASE_RETURN_STR(Local_East_Coordinate)
+               CASE_RETURN_STR(Floor_Number)
+               CASE_RETURN_STR(Altitude)
+               CASE_RETURN_STR(Uncertainty)
+               CASE_RETURN_STR(Location_Name)
+               CASE_RETURN_STR(Uri)
+               CASE_RETURN_STR(Http_Headers)
+               CASE_RETURN_STR(Http_Status_Code)
+               CASE_RETURN_STR(Http_Entity_Body)
+               CASE_RETURN_STR(Http_Control_Point)
+               CASE_RETURN_STR(Https_Security)
+               CASE_RETURN_STR(Tds_Control_Point)
+               CASE_RETURN_STR(Ots_Feature)
+               CASE_RETURN_STR(Object_Name)
+               CASE_RETURN_STR(Object_Type)
+               CASE_RETURN_STR(Object_Size)
+               CASE_RETURN_STR(Object_First_Created)
+               CASE_RETURN_STR(Object_Last_Modified)
+               CASE_RETURN_STR(Object_Id)
+               CASE_RETURN_STR(Object_Properties)
+               CASE_RETURN_STR(Object_Action_Control_Point)
+               CASE_RETURN_STR(Object_List_Control_Point)
+               CASE_RETURN_STR(Object_List_Filter)
+               CASE_RETURN_STR(Object_Changed)
+               CASE_RETURN_STR(Fitness_Machine_Control_Point)
+               CASE_RETURN_STR(Gatt_Characteristic_Extended_Properties)
+               CASE_RETURN_STR(Gatt_Characteristic_User_Description)
+               CASE_RETURN_STR(Gatt_Client_Characteristic_Configuration)
+               CASE_RETURN_STR(Gatt_Server_Characteristic_Configuration)
+               CASE_RETURN_STR(Gatt_Characteristic_Presentation_Format)
+               CASE_RETURN_STR(Gatt_Characteristic_Aggregate_Format)
+               CASE_RETURN_STR(Valid_Range)
+               CASE_RETURN_STR(External_Report_Reference)
+               CASE_RETURN_STR(Report_Reference)
+               CASE_RETURN_STR(Number_Of_Digitals)
+               CASE_RETURN_STR(Value_Trigger_Setting)
+               CASE_RETURN_STR(Es_Configuration)
+               CASE_RETURN_STR(Es_Measurement)
+               CASE_RETURN_STR(Es_Trigger_Setting)
+               CASE_RETURN_STR(Time_Trigger_Setting)
+               CASE_RETURN_STR(Gatt_Primary_Service_Declaration)
+               CASE_RETURN_STR(Gatt_Secondary_Service_Declaration)
+               CASE_RETURN_STR(Gatt_Include_Declaration)
+               CASE_RETURN_STR(Gatt_Characteristic_Declaration)
+        default:
+            return "--";
+    }
+}
index 56e1fe4..682c620 100755 (executable)
@@ -30,6 +30,385 @@ extern "C" {
 #include <sys/types.h>
 #include "oal-internal.h"
 
+#define ADVANCED_AUDIO_UUID            "0000110d-0000-1000-8000-00805f9b34fb"
+#define A2DP_SOURCE_UUID               "0000110a-0000-1000-8000-00805f9b34fb"
+#define A2DP_SINK_UUID                 "0000110b-0000-1000-8000-00805f9b34fb"
+#define AVRCP_REMOTE_UUID              "0000110e-0000-1000-8000-00805f9b34fb"
+#define AVRCP_TARGET_UUID              "0000110c-0000-1000-8000-00805f9b34fb"
+#define DEVICE_INFORMATION_UUID        "0000180a-0000-1000-8000-00805f9b34fb"
+#define HID_UUID                               "00001124-0000-1000-8000-00805f9b34fb"
+#define SPP_UUID                               "00001101-0000-1000-8000-00805f9b34fb"
+#define BASE_UUID                              "00000000-0000-1000-8000-00805F9B34FB"
+
+#define CASE_RETURN_STR(const) case const: return #const;
+
+// List of Protocols
+#define BASE                                    0x0000          //Base
+#define SDP                                     0x0001          //Bluetooth Core Specification
+#define UDP                                     0x0002          //[NO USE BY PROFILES]
+#define RFCOMM                                  0x0003          //RFCOMM with TS 07.10
+#define TCP                                     0x0004          //[NO USE BY PROFILES]
+#define TCS_BIN                                 0x0005          //Telephony Control Specification / TCS Binary [DEPRECATED]
+#define TCS_AT                                  0x0006          //[NO USE BY PROFILES]
+#define ATT                                     0x0007          //Attribute Protocol
+#define OBEX                                    0x0008          //IrDA Interoperability
+#define IP                                      0x0009          //[NO USE BY PROFILES]
+#define FTP                                     0x000A          //[NO USE BY PROFILES]
+#define HTTP                                    0x000C          //[NO USE BY PROFILES]
+#define WSP                                     0x000E          //[NO USE BY PROFILES]
+#define BNEP                                    0x000F          //Bluetooth Network Encapsulation Protocol (BNEP)
+#define UPNP                                    0x0010          //Extended Service Discovery Profile (ESDP) [DEPRECATED]
+#define HIDP                                    0x0011          //Human Interface Device Profile (HID)
+#define HardcopyControlChannel                  0x0012          //Hardcopy Cable Replacement Profile (HCRP)
+#define HardcopyDataChannel                     0x0014          //See Hardcopy Cable Replacement Profile (HCRP)
+#define HardcopyNotification                    0x0016          //Hardcopy Cable Replacement Profile (HCRP)
+#define AVCTP                                   0x0017          //Audio/Video Control Transport Protocol (AVCTP)
+#define AVDTP                                   0x0019          //Audio/Video Distribution Transport Protocol (AVDTP)
+#define CMTP                                    0x001B          //Common ISDN Access Profile (CIP) [DEPRECATED]
+#define MCAPControlChannel                      0x001E          //Multi-Channel Adaptation Protocol (MCAP)
+#define MCAPDataChannel                         0x001F          //Multi-Channel Adaptation Protocol (MCAP)
+#define L2CAP                                   0x0100          //Bluetooth Core Specification
+
+//List of Services
+#define ServiceDiscoveryServerServiceClassID    0x1000          //Bluetooth Core Specification Service Class
+#define BrowseGroupDescriptorServiceClassID     0x1001          //Bluetooth Core Specification Service Class
+#define SerialPort                              0x1101          //Serial Port Profile (SPP)
+#define LANAccessUsingPPP                       0x1102          //LAN Access Profile
+#define DialupNetworking                        0x1103          //Dial-up Networking Profile (DUN)
+#define IrMCSync                                0x1104          //Synchronization Profile (SYNC)
+#define OBEXObjectPush                          0x1105          //Object Push Profile (OPP)
+#define OBEXFileTransfer                        0x1106          //File Transfer Profile (FTP)
+#define IrMCSyncCommand                         0x1107          //Synchronization Profile (SYNC)
+#define Headset                                 0x1108          //Headset Profile (HSP)
+#define CordlessTelephony                       0x1109          //Cordless Telephony Profile (CTP)
+#define AudioSource                             0x110A          //Advanced Audio Distribution Profile (A2DP) Service Class
+#define AudioSink                               0x110B          //Advanced Audio Distribution Profile (A2DP) Service Class
+#define AV_RemoteControlTarget                  0x110C          //Audio/Video Remote Control Profile (AVRCP) Service Class
+#define AdvancedAudioDistribution               0x110D          //Advanced Audio Distribution Profile (A2DP) Profile
+#define AV_RemoteControl                        0x110E          //Audio/Video Remote Control Profile (AVRCP)
+#define AV_RemoteControlController              0x110F          //Audio/Video Remote Control Profile (AVRCP)
+#define Intercom                                0x1110          //Intercom Profile (ICP)
+#define Fax                                     0x1111          //Fax Profile (FAX)
+#define Headset_Audio_Gateway                   0x1112          //Headset Profile (HSP) Service Class
+#define WAP                                     0x1113          //Interoperability Requirements for Bluetooth technology as a WAP, Bluetooth SIG [DEPRECATED] Service Class
+#define WAP_CLIENT                              0x1114          //Interoperability Requirements for Bluetooth technology as a WAP, Bluetooth SIG [DEPRECATED] Service Class
+#define PANU                                    0x1115          //Personal Area Networking Profile (PAN)
+#define NAP                                     0x1116          //Personal Area Networking Profile (PAN)
+#define GN                                      0x1117          //Personal Area Networking Profile (PAN)
+#define DirectPrinting                          0x1118          //Basic Printing Profile (BPP) Service Class
+#define ReferencePrinting                       0x1119          //See Basic Printing Profile (BPP) Service Class
+#define Basic_Imaging_Profile                   0x111A          //Basic Imaging Profile (BIP) Profile
+#define ImagingResponder                        0x111B          //Basic Imaging Profile (BIP) Service Class
+#define ImagingAutomaticArchive                 0x111C          //Basic Imaging Profile (BIP) Service Class
+#define ImagingReferencedObjects                0x111D          //Basic Imaging Profile (BIP) Service Class
+#define Handsfree                               0x111E          //Hands-Free Profile (HFP)
+#define HandsfreeAudioGateway                   0x111F          //Hands-free Profile (HFP) Service Class
+#define DirectPrintingReferenceObjectsService   0x1120          //Basic Printing Profile (BPP) Service Class
+#define ReflectedUI                             0x1121          //Basic Printing Profile (BPP) Service Class
+#define BasicPrinting                           0x1122          //Basic Printing Profile (BPP) Profile
+#define PrintingStatus                          0x1123          //Basic Printing Profile (BPP) Service Class
+#define HumanInterfaceDeviceService             0x1124          //Human Interface Device (HID)
+#define HardcopyCableReplacement                0x1125          //Hardcopy Cable Replacement Profile (HCRP) Profile
+#define HCR_Print                               0x1126          //Hardcopy Cable Replacement Profile (HCRP) Service Class
+#define HCR_Scan                                0x1127          //Hardcopy Cable Replacement Profile (HCRP) Service Class
+#define Common_ISDN_Access                      0x1128          //Common ISDN Access Profile (CIP)
+#define SIM_Access                              0x112D          //SIM Access Profile (SAP)
+#define Phonebook_Access_PCE                    0x112E          //Phonebook Access Profile (PBAP) Service Class
+#define Phonebook_Access_PSE                    0x112F          //Phonebook Access Profile (PBAP) Service Class
+#define Phonebook_Access                        0x1130          //Phonebook Access Profile (PBAP) Profile
+#define Headset_HS                              0x1131          //Headset Profile (HSP)
+#define Message_Access_Server                   0x1132          //Message Access Profile (MAP) Service Class
+#define Message_Notification_Server             0x1133          //Message Access Profile (MAP) Service Class
+#define Message_Access_Profile                  0x1134          //Message Access Profile (MAP) Profile
+#define GNSS                                    0x1135          //Global Navigation Satellite System Profile (GNSS) Profile
+#define GNSS_Server                             0x1136          // Global Navigation Satellite System Profile (GNSS) Service Class
+#define ThreeD_Display                          0x1137          //3D Synchronization Profile (3DSP) Service Class?
+#define ThreeD_Glasses                          0x1138          //3D Synchronization Profile (3DSP) ?Service Class
+#define ThreeD_Synchronization                  0x1139          //3D Synchronization Profile (3DSP) ?Profile
+#define MPS_Profile                             0x113A          //Multi-Profile Specification (MPS) ?Profile
+#define MPS_SC                                  0x113B          //Multi-Profile Specification (MPS) ?Service Class
+#define CTN_Access_Service                      0x113C          //Calendar, Task, and Notes (CTN) Profile ?Service Class
+#define CTN_Notification_Service                0x113D          //Calendar Tasks and Notes (CTN) Profile ?Service Class
+#define CTN_Profile                             0x113E          //Calendar Tasks and Notes (CTN) Profile ?Profile
+#define PnPInformation                          0x1200          //Device Identification (DID)
+#define GenericNetworking                       0x1201          //N/A Service Class
+#define GenericFileTransfer                     0x1202          //N/A Service Class
+#define GenericAudio                            0x1203          //N/A Service Class
+#define GenericTelephony                        0x1204          //N/A Service Class
+#define UPNP_Service                            0x1205          //Enhanced Service Discovery Profile (ESDP) [DEPRECATED] Service Class
+#define UPNP_IP_Service                         0x1206          //Enhanced Service Discovery Profile (ESDP) [DEPRECATED] Service Class
+#define ESDP_UPNP_IP_PAN                        0x1300          //Enhanced Service Discovery Profile (ESDP) [DEPRECATED] Service Class
+#define ESDP_UPNP_IP_LAP                        0x1301          //Enhanced Service Discovery Profile (ESDP)[DEPRECATED] Service Class
+#define ESDP_UPNP_L2CAP                         0x1302          //Enhanced Service Discovery Profile (ESDP)[DEPRECATED] Service Class
+#define VideoSource                             0x1303          //Video Distribution Profile (VDP) Service Class
+#define VideoSink                               0x1304          //Video Distribution Profile (VDP) Service Class
+#define VideoDistribution                       0x1305          //Video Distribution Profile (VDP) Profile
+#define HDP                                     0x1400          //Health Device Profile Profile
+#define HDP_Source                              0x1401          //Health Device Profile (HDP) Service Class
+#define HDP_Sink                                0x1402          //Health Device Profile (HDP) Service Class
+
+/* List of GATT Services UUID */
+#define Generic_Access                                                 0x1800                  //Generic Access Service
+#define Generic_Attribute                                              0x1801                  //Generic Attribute Service
+#define Immediate_Alert                                                        0x1802                  //Immediate Alert Service
+#define Link_Loss                                                              0x1803                  //Link Loss Service
+#define Tx_Power                                                               0x1804                  //Tx Power Service
+#define Current_Time                                                   0x1805                  //Current Time Service
+#define Reference_Time_Update                                  0x1806                  //Reference Time Update Service
+#define Next_Dst_Change                                                        0x1807                  //Next Destination Change Service
+#define Glucose                                                                        0x1808                  //Glucose Service
+#define Health_Thermometer                                             0x1809                  //Health Thermometer Service
+#define Device_Information                                             0x180A                  //Device Information Service
+#define Heart_Rate                                                             0x180D                  //Heart Rate Service
+#define Phone_Alert_Status                                             0x180E                  //Phone Alert Status Service
+#define Battery_Service                                                        0x180F                  //Battery Service
+#define Blood_Pressure                                                 0x1810                  //Blood Pressure Service
+#define Alert_Notification                                             0x1811                  //Alert Notification Service
+#define Human_Interface_Device                                 0x1812                  //HID Service
+#define Scan_Parameters                                                        0x1813                  //Scan Parameters Service
+#define Running_Speed_And_Cadence                              0x1814                  //Running Speed and Cadence Service
+#define Automation_IO                                                  0x1815                  //Automation IO Service
+#define Cycling_Speed_And_Cadence                              0x1816                  //Cycling Speed and Cadence Service
+#define Cycling_Power                                                  0x1818                  //Cycling Power Service
+#define Location_And_Navigation                                        0x1819                  //Location and Navigation Service
+#define Environmental_Sensing                                  0x181A                  //Environment Sensing Service
+#define Body_Composition                                               0x181B                  //Body Composition Service
+#define User_Data                                                              0x181C                  //User Data Service
+#define Weight_Scale                                                   0x181D                  //Weight Scale Service
+#define Bond_Management                                                        0x181E                  //Bond Management Service
+#define Continuous_Glucose_Monitoring                  0x181F                  //Continuous Glucose Monitoring Service
+#define Internet_Protocol_Support                              0x1820                  //Internet Protocol Support Service
+#define Indoor_Positioning                                             0x1821                  //Indoor Positioning Service
+#define Pulse_Oximeter                                                 0x1822                  //Pulse Oximeter Service
+#define Http_Proxy                                                             0x1823                  //Http Proxy Service
+#define Transport_Discovery                                            0x1824                  //Transport Discovery Service
+#define Object_Transfer                                                        0x1825                  //Object Transfer Service
+
+/* List of GATT Characteristics UUID */
+#define Gap_Device_Name                                                                                0x2A00
+#define Gap_Appearance                                                                         0x2A01
+#define Gap_Peripheral_Privacy_Flag                                                    0x2A02
+#define Gap_Reconnection_Address                                                       0x2A03
+#define Gap_Peripheral_Preferred_Connection_Parameters         0x2A04
+#define Gatt_Service_Changed                                                           0x2A05
+#define Alert_Level                                                                                    0x2A06
+#define Tx_Power_Level                                                                         0x2A07
+#define Date_Time                                                                                      0x2A08
+#define Day_Of_Week                                                                                    0x2A09
+#define Day_Date_Time                                                                          0x2A0A
+#define Exact_Time_256                                                                         0x2A0C
+#define Dst_Offset                                                                                     0x2A0D
+#define Time_Zone                                                                                      0x2A0E
+#define Local_Time_Information                                                         0x2A0F
+#define Time_With_Dst                                                                          0x2A11
+#define Time_Accuracy                                                                          0x2A12
+#define Time_Source                                                                                    0x2A13
+#define Reference_Time_Information                                                     0x2A14
+#define Time_Update_Control_Point                                                      0x2A16
+#define Time_Update_State                                                                      0x2A17
+#define Glucose_Measurement                                                                    0x2A18
+#define Battery_Level                                                                          0x2A19
+#define Temperature_Measurement                                                                0x2A1C
+#define Temperature_Type                                                                       0x2A1D
+#define Intermediate_Temperature                                                       0x2A1E
+#define Measurement_Interval                                                           0x2A21
+#define Boot_Keyboard_Input_Report                                                     0x2A22
+#define System_Id                                                                                      0x2A23
+#define Model_Number_String                                                                    0x2A24
+#define Serial_Number_String                                                           0x2A25
+#define Firmware_Revision_String                                                       0x2A26
+#define Hardware_Revision_String                                                       0x2A27
+#define Software_Revision_String                                                       0x2A28
+#define Manufacturer_Name_String                                                       0x2A29
+#define Regulatory_Certification_Data_List                                     0x2A2A
+#define Current_Time_Charac                                                                    0x2A2B
+#define Magnetic_Declination                                                           0x2A2C
+#define Scan_Refresh                                                                           0x2A31
+#define Boot_Keyboard_Output_Report                                                    0x2A32
+#define Boot_Mouse_Input_Report                                                                0x2A33
+#define Glucose_Measurement_Context                                                    0x2A34
+#define Blood_Pressure_Measurement                                                     0x2A35
+#define Intermediate_Cuff_Pressure                                                     0x2A36
+#define Heart_Rate_Measurement                                                         0x2A37
+#define Body_Sensor_Location                                                           0x2A38
+#define Heart_Rate_Control_Point                                                       0x2A39
+#define Alert_Status                                                                           0x2A3F
+#define Ringer_Control_Point                                                           0x2A40
+#define Ringer_Setting                                                                         0x2A41
+#define Alert_Category_Id_Bit_Mask                                                     0x2A42
+#define Alert_Category_Id                                                                      0x2A43
+#define Alert_Notification_Control_Point                                       0x2A44
+#define Unread_Alert_Status                                                                    0x2A45
+#define New_Alert                                                                                      0x2A46
+#define Supported_New_Alert_Category                                           0x2A47
+#define Supported_Unread_Alert_Category                                                0x2A48
+#define Blood_Pressure_Feature                                                         0x2A49
+#define Hid_Information                                                                                0x2A4A
+#define Report_Map                                                                                     0x2A4B
+#define Hid_Control_Point                                                                      0x2A4C
+#define Report                                                                                         0x2A4D
+#define Protocol_Mode                                                                          0x2A4E
+#define Scan_Interval_Window                                                           0x2A4F
+#define Pnp_Id                                                                                         0x2A50
+#define Glucose_Feature                                                                                0x2A51
+#define Record_Access_Control_Point                                                    0x2A52
+#define Rsc_Measurement                                                                                0x2A53
+#define Rsc_Feature                                                                                    0x2A54
+#define Sc_Control_Point                                                                       0x2A55
+#define Digital                                                                                                0x2A56
+#define Analog                                                                                         0x2A58
+#define Aggregate                                                                                      0x2A5A
+#define Csc_Measurement                                                                                0x2A5B
+#define Csc_Feature                                                                                    0x2A5C
+#define Sensor_Location                                                                                0x2A5D
+#define Plx_Spot_Check_Measurement                                                     0x2A5E
+#define Plx_Continuous_Measurement                                                     0x2A5F
+#define Plx_Features                                                                           0x2A60
+#define Cycling_Power_Measurement                                                      0x2A63
+#define Cycling_Power_Vector                                                           0x2A64
+#define Cycling_Power_Feature                                                          0x2A65
+#define Cycling_Power_Control_Point                                                    0x2A66
+#define Location_And_Speed                                                                     0x2A67
+#define Navigation                                                                                     0x2A68
+#define Position_Quality                                                                       0x2A69
+#define Ln_Feature                                                                                     0x2A6A
+#define Ln_Control_Point                                                                       0x2A6B
+#define Elevation                                                                                      0x2A6C
+#define Pressure                                                                                       0x2A6D
+#define Temperature                                                                                    0x2A6E
+#define Humidity                                                                                       0x2A6F
+#define True_Wind_Speed                                                                                0x2A70
+#define True_Wind_Direction                                                                    0x2A71
+#define Apparent_Wind_Speed                                                                    0x2A72
+#define Apparent_Wind_Direction                                                                0x2A73
+#define Gust_Factor                                                                                    0x2A74
+#define Pollen_Concentration                                                           0x2A75
+#define Uv_Index                                                                                       0x2A76
+#define Irradiance                                                                                     0x2A77
+#define Rainfall                                                                                       0x2A78
+#define Wind_Chill                                                                                     0x2A79
+#define Heat_Index                                                                                     0x2A7A
+#define Dew_Point                                                                                      0x2A7B
+#define Descriptor_Value_Changed                                                       0x2A7D
+#define Aerobic_Threshold                                                                      0x2A7F
+#define Age                                                                                                    0x2A80
+#define Anaerobic_Heart_Rate_Lower_Limit                                       0x2A81
+#define Anaerobic_Heart_Rate_Upper_Limit                                       0x2A82
+#define Anaerobic_Threshold                                                                    0x2A83
+#define Aerobic_Heart_Rate_Upper_Limit                                         0x2A84
+#define Date_Of_Birth                                                                          0x2A85
+#define Date_Of_Threshold_Assessment                                           0x2A86
+#define Email_Address                                                                          0x2A87
+#define Fat_Burn_Heart_Rate_Lower_Limit                                                0x2A88
+#define Fat_Burn_Heart_Rate_Upper_Limit                                                0x2A89
+#define First_Name                                                                                     0x2A8A
+#define Five_Zone_Heart_Rate_Limits                                                    0x2A8B
+#define Gender                                                                                         0x2A8C
+#define Heart_Rate_Max                                                                         0x2A8D
+#define Height                                                                                         0x2A8E
+#define Hip_Circumference                                                                      0x2A8F
+#define Last_Name                                                                                      0x2A90
+#define Maximum_Recommended_Heart_Rate                                         0x2A91
+#define Resting_Heart_Rate                                                                     0x2A92
+#define Sport_Type_For_Aerobic_And_Anaerobic_Thresholds                0x2A93
+#define Three_Zone_Heart_Rate_Limits                                           0x2A94
+#define Two_Zone_Heart_Rate_Limit                                                      0x2A95
+#define Vo2_Max                                                                                                0x2A96
+#define Waist_Circumference                                                                    0x2A97
+#define Weight                                                                                         0x2A98
+#define Database_Change_Increment                                                      0x2A99
+#define User_Index                                                                                     0x2A9A
+#define Body_Composition_Feature                                                       0x2A9B
+#define Body_Composition_Measurement                                           0x2A9C
+#define Weight_Measurement                                                                     0x2A9D
+#define Weight_Scale_Feature                                                           0x2A9E
+#define User_Control_Point                                                                     0x2A9F
+#define Magnetic_Flux_Density_2D                                                       0x2AA0
+#define Magnetic_Flux_Density_3D                                                       0x2AA1
+#define Language                                                                                       0x2AA2
+#define Barometric_Pressure_Trend                                                      0x2AA3
+#define Bond_Management_Control_Point                                          0x2AA4
+#define Bond_Management_Feature                                                                0x2AA5
+#define Gap_Central_Address_Resolution_Support                         0x2AA6
+#define Cgm_Measurement                                                                                0x2AA7
+#define Cgm_Feature                                                                                    0x2AA8
+#define Cgm_Status                                                                                     0x2AA9
+#define Cgm_Session_Start_Time                                                         0x2AAA
+#define Cgm_Session_Run_Time                                                           0x2AAB
+#define Cgm_Specific_Ops_Control_Point                                         0x2AAC
+#define Indoor_Positioning_Configuration                                       0x2AAD
+#define Latitude                                                                                       0x2AAE
+#define Longitude                                                                                      0x2AAF
+#define Local_North_Coordinate                                                         0x2AB0
+#define Local_East_Coordinate                                                          0x2AB1
+#define Floor_Number                                                                           0x2AB2
+#define Altitude                                                                                       0x2AB3
+#define Uncertainty                                                                                    0x2AB4
+#define Location_Name                                                                          0x2AB5
+#define Uri                                                                                                    0x2AB6
+#define Http_Headers                                                                           0x2AB7
+#define Http_Status_Code                                                                       0x2AB8
+#define Http_Entity_Body                                                                       0x2AB9
+#define Http_Control_Point                                                                     0x2ABA
+#define Https_Security                                                                         0x2ABB
+#define Tds_Control_Point                                                                      0x2ABC
+#define Ots_Feature                                                                                    0x2ABD
+#define Object_Name                                                                                    0x2ABE
+#define Object_Type                                                                                    0x2ABF
+#define Object_Size                                                                                    0x2AC0
+#define Object_First_Created                                                           0x2AC1
+#define Object_Last_Modified                                                           0x2AC2
+#define Object_Id                                                                                      0x2AC3
+#define Object_Properties                                                                      0x2AC4
+#define Object_Action_Control_Point                                                    0x2AC5
+#define Object_List_Control_Point                                                      0x2AC6
+#define Object_List_Filter                                                                     0x2AC7
+#define Object_Changed                                                                         0x2AC8
+#define Fitness_Machine_Control_Point                                          0xEE1D
+
+/* List of GATT Descriptors UUID */
+#define Gatt_Characteristic_Extended_Properties                        0x2900
+#define Gatt_Characteristic_User_Description                   0x2901
+#define Gatt_Client_Characteristic_Configuration               0x2902
+#define Gatt_Server_Characteristic_Configuration               0x2903
+#define Gatt_Characteristic_Presentation_Format                        0x2904
+#define Gatt_Characteristic_Aggregate_Format                   0x2905
+#define Valid_Range                                                                            0x2906
+#define External_Report_Reference                                              0x2907
+#define Report_Reference                                                               0x2908
+#define Number_Of_Digitals                                                             0x2909
+#define Value_Trigger_Setting                                                  0x290A
+#define Es_Configuration                                                               0x290B
+#define Es_Measurement                                                                 0x290C
+#define Es_Trigger_Setting                                                             0x290D
+#define Time_Trigger_Setting                                                   0x290E
+
+/* List of GATT Declarations UUID */
+#define Gatt_Primary_Service_Declaration                               0x2800
+#define Gatt_Secondary_Service_Declaration                             0x2801
+#define Gatt_Include_Declaration                                               0x2802
+#define Gatt_Characteristic_Declaration                                        0x2803
+
+
+/* Characteristic properties
+*/
+#define  BROADCAST    (1 << 0)
+#define  READ         (1 << 1)
+#define  WRITE_NR     (1 << 2)
+#define  WRITE        (1 << 3)
+#define  NOTIFY       (1 << 4)
+#define  INDICATE     (1 << 5)
+#define  AUTH         (1 << 6)
+#define  EXT_PROP     (1 << 7)
+
+/* Characteristic permissions
+*/
+#define RD     (1 << 0)
+#define WR     (1 << 1)
+#define ENCRYPT_RD     (1 << 2)
+#define ENCRYPT_WR     (1 << 3)
+#define ENC_AUTH_RD    (1 << 4)
+#define ENC_AUTH_WR    (1 << 5)
 
 #define MENU_PRINT_ERROR(format, arg...) MENUPRINT(RED(format), ##arg)
 
@@ -47,6 +426,7 @@ char* bdt_bd2str(const bt_address_t *bdaddr, bdstr_t *bdstr);
 char* bdaddr_2_str(const bt_bdaddr_t *bd_addr);
 void string_to_uuid(char *str, service_uuid_t *p_uuid);
 void uuid_to_string(service_uuid_t *p_uuid, char *str);
+void uuid_to_stringname(service_uuid_t *p_uuid, char *str);
 void oal_print_device_address_t(const bt_address_t *addr);
 void oal_convert_addr_string_to_type(unsigned char *addr, const char *address);
 int oal_is_address_zero(unsigned char *addr1);
@@ -61,6 +441,7 @@ char* convert_device_type_2_str(bt_device_type_t device_type);
 char* convert_bdaddr_2_str(const bt_bdaddr_t *bd_addr, char *buf);
 
 void local_le_feat_2_string(char *str, const bt_local_le_features_t *f);
+const char *dump_uuid_name(int uuid_no);
 
 #ifdef __cplusplus
 }
index 9d8e059..3c91bee 100755 (executable)
@@ -24,6 +24,7 @@
 #include <sys/types.h>
 
 #include <oal-manager.h>
+#include <oal-gatt.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -251,6 +252,67 @@ oal_status_t adapter_set_discoverable(void);
  */
 oal_status_t adapter_set_discoverable_timeout(int timeout);
 
+/**
+ * @brief Set Advertising data on specific Instance ID
+ *
+ * @param instance_id Multi advertising slot ID initialized by stack
+ *
+ * @details Event  OAL_EVENT_BLE_MULTI_ADVERTISING_SET_INST_DATA will be generated.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ *
+ * @see  gatts_multi_adv_set_inst_data()
+ */
+oal_status_t adapter_ble_multi_adv_set_inst_data(int instance_id, oal_ble_multi_adv_param_setup_t *adv_param_setup);
+
+/**
+ * @brief Set Advertising parameters on specific Instance ID
+ *
+ * @param instance_id Multi advertising slot ID initialized by stack
+ *
+ * @details Event  OAL_EVENT_BLE_MULTI_ADVERTISING_UPDATE event will be generated.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ *
+ * @see  gatts_multi_adv_set_inst_data()
+ */
+oal_status_t adapter_ble_multi_adv_update(int Ins_id, int min_intv, int max_intv,
+                        int adv_type, int chnl_map, int tx_power, int timeout_s);
+
+/**
+ * @brief Enable Multi Advertising on specific Instance ID
+ *
+ * @param instance_id Multi advertising slot ID initialized by stack
+ *
+ * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_ENABLE will be generated.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ */
+oal_status_t adapter_ble_multi_adv_enable(int instance_id);
+
+/**
+ * @brief Disable Multi Advertising on specific Instance ID
+ *
+ * @param instance_id Multi advertising slot ID initialized by stack
+ *
+ * @details Event OAL_EVENT_BLE_MULTI_ADVERTISING_DISABLE will be generated.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ */
+oal_status_t adapter_ble_multi_adv_disable(int instance_id);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 379118d..e86a1d0 100755 (executable)
@@ -116,6 +116,13 @@ extern "C" {
        EVENT(OAL_EVENT_HDP_APP_UNREGISTERED)                   /* HDP APP un-registered */ \
        EVENT(OAL_EVENT_HDP_CHANNEL_CONNECTED)                  /* HDP channel connected */ \
        EVENT(OAL_EVENT_HDP_CHANNEL_DESTROYED)                  /* HDP channel destroyed */ \
+       EVENT(OAL_EVENT_BLE_SERVER_INSTANCE_INITIALISED)    /*event_ble_adv_status */ \
+        EVENT(OAL_EVENT_BLE_ADVERTISING_STARTED)                        /* NULL */\
+        EVENT(OAL_EVENT_BLE_ADVERTISING_STOPPED)                        /* NULL*/\
+        EVENT(OAL_EVENT_BLE_MULTI_ADVERTISING_ENABLE)           /* NULL*/\
+        EVENT(OAL_EVENT_BLE_MULTI_ADVERTISING_DISABLE)          /* NULL*/\
+        EVENT(OAL_EVENT_BLE_MULTI_ADVERTISING_SET_INST_DATA)            /* NULL*/\
+        EVENT(OAL_EVENT_BLE_MULTI_ADVERTISING_UPDATE)           /* NULL*/\
        EVENT(OAL_EVENT_END)                                /* End of event*/\
 
 
@@ -228,6 +235,25 @@ typedef struct {
        bt_address_t address;
 } event_hdp_channel_conn_t;
 
+typedef struct {
+       int server_inst;
+       oal_uuid_t server_uuid;
+} event_gatts_register_t;
+
+typedef struct{
+       int conn_id;
+       int mtu_size;
+} event_gatts_mtu_changed_t;
+
+typedef struct {
+        int server_inst;
+} event_ble_adv_status;
+
+typedef struct {
+        int server_inst;
+        int status;
+} event_ble_multiadv_status;
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/bt-oal/include/oal-gatt.h b/bt-oal/include/oal-gatt.h
new file mode 100644 (file)
index 0000000..8e27cff
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * Open Adaptation Layer (OAL)
+ *
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *              http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef OAL_GATT_H_
+#define OAL_GATT_H_
+
+#include <oal-manager.h>
+
+typedef struct {
+       uint8_t  server_if;
+       uint8_t  set_scan_rsp;
+       uint8_t  include_name;
+       uint8_t  include_txpower;
+       uint16_t  appearance;
+       char*    manufacturer_data;
+       uint16_t manufacturer_data_len;
+       char*    service_data;
+       uint16_t service_data_len;
+       char*    service_uuid;
+       uint16_t service_uuid_len;
+       char*    solicit_uuid;
+        uint16_t solicit_uuid_len;
+       uint16_t min_interval;
+       uint16_t max_interval;
+       uint8_t  adv_type;
+       uint8_t  chnl_map;
+       uint16_t  tx_power;
+       uint8_t  timeout_s;
+} oal_ble_multi_adv_param_setup_t;
+
+/**
+ * @brief Enable Bluetooth Low Energy GATT Feature
+ *
+ * @remarks  Application will be able to advertise and scan other Low Energy devices.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre OAL API must be initialized with oal_bt_init().
+ *
+ * @see  gatt_disable()
+ */
+oal_status_t gatt_enable(void);
+
+/**
+ * @brief Disable Bluetooth Low Energy GATT Feature
+ *
+ * @remarks  Application will not be able to advertise or scan other Low Energy devices.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre OAL API should be enabled with gatt_enable().
+ *
+ * @see  gatt_enable()
+ */
+oal_status_t gatt_disable(void);
+
+/**
+ * @brief Register the GATT Server
+ *
+ * @remarks  Application will register the GATT Server
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre OAl API should be enabled with gatt_enable().
+ *
+ * @see  gatt_enable()
+ */
+oal_status_t gatts_register(oal_uuid_t* server_uuid);
+
+/**
+ * @brief UnRegister the GATT Server
+ *
+ * @remarks  Application will unregister the GATT Server
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre OAl API should be enabled with gatti_enable().
+ *
+ * @see  gatts_register()
+ */
+oal_status_t gatts_unregister(int instance_id);
+
+/**
+ * @brief Start BLE Advertising feature
+ *
+ * @remarks  Application will start advertising and behave as a peripheral device
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre OAl API should be enabled with gatt_enable().
+ *
+ * @see  gatt_enable()
+ */
+oal_status_t gatts_start_listen(int instance_id, gboolean enable);
+
+/**
+ * @brief Stop BLE Advertising feature
+ *
+ * @remarks  Application will stop advertising and will no longer behave as a peripheral device.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre Advertising should have been started with gatts_start_advertising().
+ *
+ * @see  gatts_start_listen()
+ */
+oal_status_t gatts_stop_advertising(int instance_id);
+
+/**
+ * @brief Enables the Bluetooth Low Energy Multiple advertisement feature
+ *
+ * @remarks  The application will be able to do multiple advertising
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre OAL API must be initialized with oal_bt_init().
+ *
+ * @see  gatts_multi_adv_disable()
+ */
+oal_status_t gatts_multi_adv_enable(int instance_id);
+
+/**
+ * @brief Disables the Bluetooth Low Energy Multiple advertisement feature
+ *
+ * @remarks  The application will not be able to do multiple advertising
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre OAL API must be initialized with oal_bt_init().
+ *
+ * @see  gatts_multi_adv_enable()
+ */
+oal_status_t gatts_multi_adv_disable(int instance_id);
+
+/**
+ * @brief Updates the parameters to configure the Multiple Advertising Features
+ *
+ * @remarks  The parameters like min and max interval, advertising type,
+ * channel map, tx power and timeout will be updated.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre OAL API should be enabled with gatts_multi_adv_enable().
+ *
+ * @see  gatts_multi_adv_enable()
+ */
+oal_status_t gatts_multi_adv_update(int instance_id, int min_intv, int max_intv,
+               int adv_type, int chnl_map,
+               int tx_power, int timeout_s);
+
+/**
+ * @brief Sets the the Multiple Advertising Data
+ *
+ * @remarks  The Multiple advertising data will be set.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ * @pre OAL API should be enabled with gatts_multi_adv_enable().
+ *
+ * @see  gatts_multi_adv_enable()
+ */
+oal_status_t gatts_multi_adv_set_inst_data(int instance_id,
+               oal_ble_multi_adv_param_setup_t *adv_param_setup);
+
+/**
+ * @brief Get current ATT MTU size of the connection
+ *
+ * @remarks  The application will get current ATT MTU size of the connection
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS>-Successful
+ *
+ * @pre OAL API must be initialized with oal_bt_init().
+ *
+ * @param conn_id: active connection id (input)
+ * mtu: att mtu size of the connection (output)
+ *
+ * @see  gatts_multi_adv_enable()
+ */
+oal_status_t gatts_get_att_mtu(int conn_id, int *mtu);
+
+#endif /* OAL_GATT_H_ */
index cf18a28..affd1db 100755 (executable)
@@ -32,6 +32,7 @@
 #include "oal-hardware.h"
 #include "oal-common.h"
 #include "oal-utils.h"
+#include "oal-gatt.h"
 
 #define CHECK_MAX(max, x) (((max) > (x)) ? (x) : (max))
 
@@ -426,6 +427,69 @@ oal_status_t adapter_set_discoverable_timeout(int timeout)
        return OAL_STATUS_SUCCESS;
 }
 
+oal_status_t adapter_ble_multi_adv_update(int Ins_id, int min_intv, int max_intv,
+                       int adv_type, int chnl_map, int tx_power, int timeout_s)
+{
+       int res;
+       CHECK_OAL_INITIALIZED();
+       API_TRACE();
+
+       res = gatts_multi_adv_update(Ins_id, min_intv, max_intv,
+                       adv_type, chnl_map, tx_power, timeout_s);
+       if (res != OAL_STATUS_SUCCESS) {
+               BT_ERR("gatts_multi_adv_update: [%d]", res);
+               return res;
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t adapter_ble_multi_adv_set_inst_data(int instance_id,
+                       oal_ble_multi_adv_param_setup_t * adv_param_setup)
+{
+       int res;
+       CHECK_OAL_INITIALIZED();
+       OAL_CHECK_PARAMETER(adv_param_setup, return);
+
+       API_TRACE();
+
+       res = gatts_multi_adv_set_inst_data(instance_id, adv_param_setup);
+       if (res != OAL_STATUS_SUCCESS) {
+               BT_ERR("failed: [%d]", res);
+               return res;
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t adapter_ble_multi_adv_enable(int instance_id)
+{
+       int res;
+       CHECK_OAL_INITIALIZED();
+       API_TRACE();
+
+       res = gatts_multi_adv_enable(instance_id);
+       if (res != OAL_STATUS_SUCCESS) {
+               BT_ERR("failed: [%d]", res);
+               return res;
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t adapter_ble_multi_adv_disable(int instance_id)
+{
+        int res;
+        CHECK_OAL_INITIALIZED();
+        API_TRACE();
+
+        res = gatts_multi_adv_disable(instance_id);
+        if (res != OAL_STATUS_SUCCESS) {
+                BT_ERR("failed: [%d]", res);
+                return res;
+        }
+
+        return OAL_STATUS_SUCCESS;
+}
+
 static void cb_adapter_properties(bt_status_t status,
                                                int num_properties,
                                                bt_property_t *properties)
diff --git a/bt-oal/oal-gatt.c b/bt-oal/oal-gatt.c
new file mode 100644 (file)
index 0000000..3e0c047
--- /dev/null
@@ -0,0 +1,711 @@
+/*
+ * Open Adaptation Layer (OAL)
+ *
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *              http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <dlog.h>
+#include <bluetooth.h>
+#include "bt_gatt.h"
+#include "oal-event.h"
+#include "oal-internal.h"
+#include "oal-manager.h"
+#include "oal-adapter-mgr.h"
+#include "oal-utils.h"
+#include "oal-gatt.h"
+#include "oal-common.h"
+
+#define DEV_APPEARANCE  0x0000
+
+#define NUM_SERVER_INST 10 // Maximum slots supported by stack is set to 10
+#define CHECK_OAL_GATT_ENABLED() \
+       do { \
+               if (gatt_api == NULL) { \
+                       BT_ERR("GATT Not Enabled"); \
+                       return OAL_STATUS_NOT_READY; \
+               } \
+       } while (0)
+
+#define CHECK_SERVER_INSTANCE(instance_id) \
+       do { \
+               if (instance_id < 1 || instance_id > NUM_SERVER_INST) { \
+                       BT_ERR("Invalid Instance"); \
+                       return OAL_STATUS_INVALID_PARAM; \
+               } \
+       } while (0)
+
+#define CHECK_SERVER_REGISTRATION(instance_id) \
+       do { \
+               if (gatt_servers[instance_id - 1].server_id < 0) \
+               {\
+                       BT_INFO("GATT server registeration is not done for server Instance : %d", instance_id);\
+                       return OAL_STATUS_INTERNAL_ERROR;\
+               }\
+       } while (0)
+
+#define CHECK_CORRECT_SERVER_ID(instance_id, server_if, server_inst)\
+       do { \
+               for(instance_id = 1 ; instance_id <= NUM_SERVER_INST; instance_id++){ \
+                       if(gatt_servers[instance_id - 1].server_id == server_if) { \
+                               server_inst = instance_id; \
+                               goto sendevent;\
+                       }\
+               }\
+       } while(0)
+
+#define PRINT_ADV_DATA(length,manuf_data,data_type) \
+       do { \
+               char * buf_str = g_malloc0(3*length + 1);\
+               if (NULL != buf_str) { \
+                       convert_hex_2_str(manuf_data, length, buf_str);\
+                       if (TRUE == data_type) \
+                       BT_INFO("Scan Response Data:%s\n", buf_str);\
+                       else \
+                       BT_INFO("Advertising Data:%s\n", buf_str);\
+                       g_free(buf_str);\
+               }\
+       } while (0)
+
+typedef enum {
+       GATT_INS_DISABLED,
+       GATT_INS_DATA_SETTING,
+       GATT_INS_DATA_SET,
+       GATT_INS_ENABLING,
+       GATT_INS_ENABLED,
+} gatt_data_state;
+
+typedef struct {
+       int server_id;
+       oal_uuid_t uuid;
+       int state;
+} gatt_server_t;
+
+const char *oal_device_type[]={
+       "UNKNOWN",
+       "BR/EDR",
+       "BLE",
+       "DUAL_MODE",
+};
+
+static const btgatt_interface_t * gatt_api;
+static gboolean cur_adv_state[NUM_SERVER_INST];
+static gatt_server_t gatt_servers[NUM_SERVER_INST];
+
+/* Forward declarations of GATT Server callbacks */
+static void cb_gatts_register_app(int status, int server_if, bt_uuid_t *uuid);
+static void cb_gatts_multi_adv_enable(int server_if, int status);
+static void cb_gatts_multi_adv_set_inst_data(int server_if, int status);
+static void cb_gatts_multi_adv_disable(int server_if, int status);
+static void cb_gatts_multi_adv_update(int server_if, int status);
+
+static void cb_gatts_listen(int status, int server_if);
+
+/************************************HAL Interface *************************************/
+
+/*TODO GATT Server callbacks will be implemented in subsequent patches */
+static const btgatt_server_callbacks_t btgatt_server_callbacks = {
+       cb_gatts_register_app,
+       NULL, /*cb_gatts_connection,*/
+       NULL, /*cb_gatts_service_added,*/
+       NULL, /*cb_gatts_included_service_added,*/
+       NULL, /*cb_gatts_characteristic_added,*/
+       NULL, /*cb_gatts_descriptor_added,*/
+       NULL, /*cb_gatts_service_started,*/
+       NULL, /*cb_gatts_service_stopped,*/
+       NULL, /*cb_gatts_service_deleted,*/
+       NULL, /*cb_indication_confirmation*/
+       NULL, /*cb_gatts_request_read,*/
+       NULL, /*cb_gatts_request_write,*/
+       NULL, /*cb_gatts_request_exec_write,*/
+       NULL, /*cb_gatts_response_confirmation,*/
+       cb_gatts_listen,
+       cb_gatts_multi_adv_enable,
+       cb_gatts_multi_adv_update,
+       cb_gatts_multi_adv_set_inst_data,
+       cb_gatts_multi_adv_disable,
+       NULL, /*cb_gatts_mtu_changed*/
+};
+
+/*TODO GATT CLient callbacks will be implemented in subsequent patches */
+static const btgatt_client_callbacks_t btgatt_client_callbacks = {
+       NULL, /*cb_gattc_register_app*/
+       NULL, /*cb_gattc_scan_result*/
+       NULL, /*cb_gattc_connection*/
+       NULL, /*cb_gattc_disconnect*/
+       NULL, /*cb_gattc_search_complete*/
+       NULL, /*cb_gattc_search_result*/
+       NULL, /*cb_gattc_get_characteristics*/
+       NULL, /*cb_gattc_get_descriptor*/
+       NULL, /*cb_gattc_get_included_service*/
+       NULL, /*cb_gattc_register_for_notification*/
+       NULL, /*cb_gattc_notify*/
+       NULL, /*cb_gattc_read_characteristic*/
+       NULL, /*cb_gattc_write_characteristic*/
+       NULL, /*cb_gattc_read_descriptor*/
+       NULL, /*cb_gattc_write_descriptor*/
+       NULL, /*cb_gattc_execute_write*/
+       NULL, /*cb_gattc_remote_rssi*/
+       NULL, /*cb_gattc_configure_mtu_cmpl*/
+#ifdef PLATFORM_ANDROID_HAL
+       NULL, /*cb_scan_filter_cfg*/
+       NULL, /*cb_scan_filter_param*/
+       NULL, /*cb_scan_filter_status*/
+       NULL, /*cb_congestion*/
+       NULL, /*cb_batchscan_cfg_storag*/
+       NULL, /*cb_batchscan_enb_disable*/
+       NULL, /*cb_batchscan_reports*/
+       NULL, /*cb_batchscan_threshold*/
+       NULL, /*cb_track_adv_event*/
+#endif
+};
+
+static btgatt_callbacks_t btgatt_callbacks = {
+       sizeof(btgatt_callbacks_t),
+       &btgatt_client_callbacks,
+       &btgatt_server_callbacks
+};
+
+/*******************************GATT Initialisation - Deinitialisation********************************/
+oal_status_t gatt_enable(void)
+{
+       const bt_interface_t * blued_api;
+       int ret;
+       int i = 0;
+
+       for (i = 0; i < NUM_SERVER_INST; i++) {
+               gatt_servers[i].server_id = -1;
+               gatt_servers[i].state = GATT_INS_DISABLED;
+               memset(&gatt_servers[i].uuid, 0, sizeof(oal_uuid_t));
+               cur_adv_state[i] = FALSE;
+       }
+
+       /* Get stack interface */
+       blued_api = (const bt_interface_t *) adapter_get_stack_interface();
+
+       if (blued_api == NULL) {
+               BT_ERR("Stack is not initialized");
+               return OAL_STATUS_NOT_READY;
+       }
+
+       if (gatt_api) {
+               BT_WARN("GATT Interface is already initialized...");
+               return OAL_STATUS_ALREADY_DONE;
+       }
+
+       gatt_api = (const btgatt_interface_t *)blued_api->get_profile_interface(BT_PROFILE_GATT_ID);
+
+       if (gatt_api == NULL) {
+               BT_ERR("GATT interface failed");
+               return OAL_STATUS_INTERNAL_ERROR;
+       }
+
+       if ((ret = gatt_api->init(&btgatt_callbacks)) != BT_STATUS_SUCCESS) {
+               BT_ERR("Error: Unable to initialise GATT :%s",status2string(ret));
+               gatt_api->cleanup();
+               gatt_api = NULL;
+               return convert_to_oal_status(ret);
+       }
+
+       BT_INFO("GATT successfully initialized");
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gatt_disable(void)
+{
+       int i;
+       if (gatt_api) {
+               gatt_api->cleanup();
+               gatt_api = NULL;
+       }
+
+       for(i = 0; i < NUM_SERVER_INST; i++) {
+               gatt_servers[i].server_id = -1;
+               gatt_servers[i].state = GATT_INS_DISABLED;
+               memset(&gatt_servers[i].uuid, 0, sizeof(oal_uuid_t));
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+/************************************GATT Server Functions*************************************/
+/*Public */
+oal_status_t gatts_register(oal_uuid_t* server_uuid)
+{
+       char str[2*BT_UUID_STRING_MAX];
+       int ret = OAL_STATUS_SUCCESS;
+       int i;
+
+       CHECK_OAL_GATT_ENABLED();
+       uuid_to_stringname((service_uuid_t*)server_uuid->uuid, str);
+       API_TRACE("Register the server instance: UUID: [%s]",str);
+
+       for (i = 0; i < NUM_SERVER_INST; i++) {
+               if (memcmp(server_uuid->uuid, gatt_servers[i].uuid.uuid, sizeof(oal_uuid_t)) == 0) {
+                       if (gatt_servers[i].server_id != -1) {
+                               BT_ERR("This is resevered UUID for easy set up application i = %d \
+                                               gatt_servers[i].server_id = %d", i, gatt_servers[i].server_id);
+                               return OAL_STATUS_ALREADY_DONE;
+                       }
+               }
+       }
+
+       ret = gatt_api->server->register_server((bt_uuid_t*)server_uuid);
+
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("GATT server registration with UUID:%s failed: %s", str, status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gatts_unregister(int instance_id)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       API_TRACE("Unregister the registered server, instance_id: %d", instance_id);
+
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       ret = gatt_api->server->unregister_server(gatt_servers[instance_id - 1].server_id);
+
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("GATT server unregistration failed: %d", instance_id);
+               return convert_to_oal_status(ret);
+       }
+
+       gatt_servers[instance_id-1].server_id = -1;
+       gatt_servers[instance_id-1].state = GATT_INS_DISABLED;
+
+       if (instance_id != 1 && instance_id != 2) {
+               memset(&gatt_servers[instance_id-1].uuid, 0, sizeof(oal_uuid_t));
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
+/* Legacy Advertisement */
+oal_status_t gatts_start_listen(int instance_id, gboolean enable)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       API_TRACE("server-id:%d enable: %d", gatt_servers[instance_id-1].server_id, enable);
+
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       ret = gatt_api->server->listen(gatt_servers[instance_id-1].server_id, enable);
+
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("Error:Advertising start/stop on server-id:%d failed With Status: [%s]",
+                               gatt_servers[instance_id-1].server_id, status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gatts_stop_advertising(int instance_id)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       API_TRACE("Stop advertising");
+
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       ret = gatt_api->server->listen(gatt_servers[instance_id - 1].server_id, FALSE);
+
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("Stop Advertising failed for server Instance:%d With Status: %s",
+                       instance_id, status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+#if 0
+/* Below API's need to be removed as they are hardcoded API's.
+   If at all, product specific API's are required to set specific data, then new naming should
+   be adopted for these API's */
+oal_status_t gatts_set_advertising_params(int instance_id, float min_intv, float max_intv)
+{
+       int ret = OAL_STATUS_SUCCESS;
+
+       API_TRACE("Set advertising params min_int:%f, max_int:%f", min_intv,max_intv);
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       /* Historically used for Legacy Advertising */
+       return OAL_STATUS_NOT_SUPPORT;
+}
+
+oal_status_t gatts_set_advertising_data(int instance_id, uint16_t manufac_len, char* manufac_data) {
+       int ret = OAL_STATUS_SUCCESS;
+
+       API_TRACE("Set advertising data");
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       /* Historically used for Legacy Advertising */
+       return OAL_STATUS_NOT_SUPPORT;
+}
+
+oal_status_t gatts_set_scan_response(int instance_id, uint16_t manufac_len, char* manufac_data)
+{
+       int ret = OAL_STATUS_SUCCESS;
+
+       API_TRACE("Set Scan Response data");
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       /* Historically used for Legacy Advertising */
+       return OAL_STATUS_NOT_SUPPORT;
+}
+#endif
+
+oal_status_t gatts_multi_adv_enable(int instance_id)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       API_TRACE("Start Multi advertising, srv_if: %d, instance_id: %d",
+                       gatt_servers[instance_id - 1].server_id, instance_id);
+
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       if (gatt_api->server->multi_adv_enable == NULL)
+               return OAL_STATUS_NOT_SUPPORT;
+
+       if (gatt_servers[instance_id - 1].state != GATT_INS_DATA_SET){
+               BT_ERR("Not allowed, state: %d, instance_id: %d",
+                               gatt_servers[instance_id - 1].state, instance_id);
+               return OAL_STATUS_BUSY;
+       }
+
+       gatt_servers[instance_id - 1].state = GATT_INS_ENABLING;
+
+       ret = gatt_api->server->multi_adv_enable(gatt_servers[instance_id - 1].server_id);
+
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("GATT enable multi advertising failed for server Instance: %d With Status: %s",
+                               instance_id, status2string(ret));
+               gatt_servers[instance_id - 1].state = GATT_INS_DATA_SET;
+               return convert_to_oal_status(ret);
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gatts_multi_adv_disable(int instance_id)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       API_TRACE("Stop Multi advertising, srv_if: %d, instance_id: %d",
+                       gatt_servers[instance_id - 1].server_id, instance_id);
+
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       if (gatt_api->server->multi_adv_disable == NULL)
+               return OAL_STATUS_NOT_SUPPORT;
+
+       if ((gatt_servers[instance_id - 1].state != GATT_INS_ENABLED)) {
+               BT_ERR("Not Allowed, state: %d, instance_id: %d",
+                       gatt_servers[instance_id - 1].state, instance_id);
+               return OAL_STATUS_BUSY;
+       }
+
+       ret = gatt_api->server->multi_adv_disable(gatt_servers[instance_id - 1].server_id);
+
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("GATT disable multi advertising failed for server Instance: %d With Status: %s",
+                               instance_id, status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gatts_multi_adv_update(int instance_id,
+               int min_intv, int max_intv,
+               int adv_type, int chnl_map,
+               int tx_power, int timeout_s)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       API_TRACE("Multi advertising Update");
+
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       if (gatt_api->server->multi_adv_update == NULL)
+               return OAL_STATUS_NOT_SUPPORT;
+
+       ret = gatt_api->server->multi_adv_update(gatt_servers[instance_id - 1].server_id,
+                       min_intv, max_intv,
+                       adv_type, chnl_map,
+                       tx_power, timeout_s);
+
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("GATT update multi advertising failed for server Instance: %d With Status: %s",
+                               instance_id, status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+oal_status_t gatts_multi_adv_set_inst_data(int instance_id,
+               oal_ble_multi_adv_param_setup_t *adv_param_setup)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       btgatt_adv_param_setup_t adv_setup;
+       API_TRACE("Set Multi advertising data, srv_if: %d, instance_id: %d",
+                       gatt_servers[instance_id - 1].server_id, instance_id);
+
+       CHECK_OAL_GATT_ENABLED();
+       CHECK_SERVER_INSTANCE(instance_id);
+       CHECK_SERVER_REGISTRATION(instance_id);
+
+       if (gatt_api->server->multi_adv_set_inst_data == NULL)
+               return OAL_STATUS_NOT_SUPPORT;
+
+       if ((gatt_servers[instance_id - 1].state >= GATT_INS_DATA_SETTING) && (gatt_servers[instance_id - 1].state != GATT_INS_DATA_SET)) {
+               BT_ERR("Not Allowed, state: %d, instance_id: %d", gatt_servers[instance_id - 1].state, instance_id);
+               return OAL_STATUS_BUSY;
+       }
+
+       gatt_servers[instance_id - 1].state = GATT_INS_DATA_SETTING;
+
+
+       adv_setup.set_scan_rsp = adv_param_setup->set_scan_rsp;
+       adv_setup.include_name = adv_param_setup->include_name;
+       adv_setup.include_txpower = adv_param_setup->include_txpower;
+       adv_setup.appearance = adv_param_setup->appearance;
+       adv_setup.manufacturer_data = adv_param_setup->manufacturer_data;
+       adv_setup.manufacturer_data_len = adv_param_setup->manufacturer_data_len;
+       adv_setup.service_data = adv_param_setup->service_data;
+       adv_setup.service_data_len = adv_param_setup->service_data_len;
+       adv_setup.service_uuid = adv_param_setup->service_uuid;
+       adv_setup.service_uuid_len = adv_param_setup->service_uuid_len;
+       /* Solicit UUID handler: Start */
+       adv_setup.solicit_uuid = adv_param_setup->solicit_uuid;
+       adv_setup.solicit_uuid_len = adv_param_setup->solicit_uuid_len;
+       /* Solicit UUID handler: End */
+       adv_setup.min_interval = adv_param_setup->min_interval;
+       adv_setup.max_interval = adv_param_setup->min_interval;
+       adv_setup.adv_type = adv_param_setup->adv_type;
+       adv_setup.chnl_map = adv_param_setup->chnl_map;
+       adv_setup.tx_power = adv_param_setup->tx_power;
+       adv_setup.timeout_s = adv_param_setup->timeout_s;
+
+       adv_setup.server_if = gatt_servers[instance_id - 1].server_id;
+       if(adv_setup.manufacturer_data_len > 0 && adv_setup.manufacturer_data != NULL) {
+               BT_INFO("Manufacture data.....\n");
+               PRINT_ADV_DATA(adv_setup.manufacturer_data_len,adv_setup.manufacturer_data,adv_setup.set_scan_rsp);
+       }
+
+       if(adv_setup.service_uuid_len > 0 && adv_setup.service_uuid != NULL) {
+               BT_INFO("Service uuid.....\n");
+               PRINT_ADV_DATA(adv_setup.service_uuid_len,adv_setup.service_uuid, FALSE);
+       }
+
+
+       ret = gatt_api->server->multi_adv_set_inst_data(adv_setup);
+
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("GATT Set Multi advertising data failed: %s", status2string(ret));
+               gatt_servers[instance_id - 1].state = GATT_INS_DISABLED;
+               return convert_to_oal_status(ret);
+       }
+       return OAL_STATUS_SUCCESS;
+}
+
+/************************************GATT Server Functions*************************************/
+/*Server Callbacks*/
+static void cb_gatts_register_app(int status, int server_if, bt_uuid_t *uuid)
+{
+       int i;
+       char str[2*BT_UUID_STRING_MAX];
+       uuid_to_stringname((service_uuid_t*)uuid, str);
+
+       event_gatts_register_t *event = g_malloc0(sizeof(event_gatts_register_t));
+
+       BT_INFO("BTGATT SERVER REGISTER APP CB, status:%d, server_if:%d", status,server_if);
+       BT_INFO("UUID: [%s]", str);
+
+       for (i=0; i < NUM_SERVER_INST; i++) {
+               if (gatt_servers[i].server_id == -1) {
+                       BT_INFO("Server Instance registered with stack [%d]", i+1);
+                       gatt_servers[i].server_id = server_if;
+                       event->server_inst = i+1;
+                       memcpy(gatt_servers[i].uuid.uuid, uuid->uu, sizeof(bt_uuid_t));
+                       memcpy(event->server_uuid.uuid, uuid->uu, sizeof(bt_uuid_t));
+                       break;
+               }
+       }
+       send_event(OAL_EVENT_BLE_SERVER_INSTANCE_INITIALISED, event, sizeof(event_gatts_register_t));
+}
+
+static void cb_gatts_listen(int status, int server_if)
+{
+       gboolean prev_state[NUM_SERVER_INST];
+       gboolean new_state;
+       event_ble_adv_status *event = g_malloc0(sizeof(event_ble_adv_status));
+       int instance_id;
+
+       for (instance_id = 1 ; instance_id <= NUM_SERVER_INST ; instance_id++) {
+               if (gatt_servers[instance_id - 1].server_id == server_if) {
+                       event->server_inst = instance_id;
+                       break;
+               } else {
+                       BT_WARN("Server ID:%d recevied server Id:%d\n", gatt_servers[instance_id - 1].server_id, server_if);
+               }
+       }
+       if (event->server_inst > 0) {
+               prev_state[event->server_inst - 1] = cur_adv_state[event->server_inst - 1];
+               new_state = (status == BT_STATUS_SUCCESS)?!(prev_state[event->server_inst - 1]):(prev_state[event->server_inst - 1]);
+               cur_adv_state[event->server_inst - 1] = new_state;
+       } else {
+               BT_ERR("Invalid Callback...");
+               return;
+       }
+
+       BT_INFO("Adv State of server instance %d :%d",instance_id,new_state);
+
+       if (TRUE == new_state)
+               send_event(OAL_EVENT_BLE_ADVERTISING_STARTED, event, sizeof(event_ble_adv_status));
+       else
+               send_event(OAL_EVENT_BLE_ADVERTISING_STOPPED, event, sizeof(event_ble_adv_status));
+}
+
+static void cb_gatts_multi_adv_enable(int server_if, int status)
+{
+
+       BT_INFO("BTGATT SERVER MULTI ADV ENABLE CB, status:%d, srv_if: %d", status, server_if);
+       event_ble_multiadv_status *event = g_malloc0(sizeof(event_ble_multiadv_status));
+       int instance_id;
+
+       if (status != BT_STATUS_SUCCESS) {
+               BT_ERR("MULTI ADV ENABLE failed, status:%d, srv_if: %d", status, server_if);
+       }
+
+       for (instance_id = 1 ; instance_id <=NUM_SERVER_INST ; instance_id++) {
+               if (gatt_servers[instance_id - 1].server_id == server_if) {
+                       event->server_inst = instance_id;
+                       gatt_servers[instance_id - 1].state = GATT_INS_ENABLED;
+                       goto sendevent;
+               }
+       }
+       BT_ERR("Invalid Interface, srv_if: %d", server_if);
+       event->server_inst = -1;
+sendevent:
+       event->status = convert_to_oal_status(status);
+       send_event(OAL_EVENT_BLE_MULTI_ADVERTISING_ENABLE, event, sizeof(event_ble_multiadv_status));
+}
+
+static void cb_gatts_multi_adv_disable(int server_if, int status)
+{
+       BT_INFO("BTGATT SERVER MULTI ADV DISABLE CB, status:%d, srv_if: %d", status, server_if);
+       event_ble_multiadv_status *event = g_malloc0(sizeof(event_ble_multiadv_status));
+       int instance_id;
+
+       if (status != BT_STATUS_SUCCESS) {
+               BT_ERR("MULTI ADV DISABLE failed, status:%d, srv_if: %d", status, server_if);
+       }
+
+       for (instance_id = 1 ; instance_id <= NUM_SERVER_INST; instance_id++) {
+               if (gatt_servers[instance_id - 1].server_id == server_if) {
+                       event->server_inst = instance_id;
+                       gatt_servers[instance_id - 1].state = GATT_INS_DISABLED;
+                       goto sendevent;
+               }
+       }
+       BT_ERR("Invalid Interface, srv_if: %d", server_if);
+       event->server_inst = -1;
+sendevent:
+       event->status = convert_to_oal_status(status);
+       send_event(OAL_EVENT_BLE_MULTI_ADVERTISING_DISABLE, event, sizeof(event_ble_multiadv_status));
+}
+
+static void cb_gatts_multi_adv_update(int server_if, int status)
+{
+       BT_INFO("BTGATT SERVER MULTI ADV UPDATE CB, status:%d, srv_if: %d", status, server_if);
+       event_ble_multiadv_status *event = g_malloc0(sizeof(event_ble_multiadv_status));
+       int instance_id;
+
+       if (status != BT_STATUS_SUCCESS) {
+               BT_ERR("MULTI ADV UPDATE failed, status:%d, srv_if: %d", status, server_if);
+       }
+
+       for (instance_id = 1 ; instance_id <=NUM_SERVER_INST ; instance_id++) {
+               if (gatt_servers[instance_id - 1].server_id == server_if) {
+                       event->server_inst = instance_id;
+                       goto sendevent;
+               }
+       }
+       BT_ERR("Invalid Interface, srv_if: %d", server_if);
+       event->server_inst = -1;
+sendevent:
+       event->status = convert_to_oal_status(status);
+       send_event(OAL_EVENT_BLE_MULTI_ADVERTISING_UPDATE, event, sizeof(event_ble_multiadv_status));
+}
+
+static void cb_gatts_multi_adv_set_inst_data(int server_if, int status)
+{
+       BT_INFO("BTGATT SERVER MULTI ADV SET INST DATA CB, status:%d, srv_if: %d", status, server_if);
+       event_ble_multiadv_status *event = g_malloc0(sizeof(event_ble_multiadv_status));
+       int instance_id;
+
+       if (status != BT_STATUS_SUCCESS) {
+               BT_ERR("MULTI ADV SET DATA failed, status:%d, srv_if: %d", status, server_if);
+       }
+
+       for (instance_id = 1 ; instance_id <=NUM_SERVER_INST ; instance_id++) {
+               if (gatt_servers[instance_id - 1].server_id == server_if) {
+                       event->server_inst = instance_id;
+                       gatt_servers[instance_id - 1].state = GATT_INS_DATA_SET;
+                       goto sendevent;
+               }
+       }
+       BT_ERR("Invalid Interface, srv_if: %d", server_if);
+       event->server_inst = -1;
+sendevent:
+       event->status = convert_to_oal_status(status);
+       send_event(OAL_EVENT_BLE_MULTI_ADVERTISING_SET_INST_DATA, event, sizeof(event_ble_multiadv_status));
+}
+
+oal_status_t gatts_get_att_mtu(int conn_id, int *mtu)
+{
+       int ret = OAL_STATUS_SUCCESS;
+       API_TRACE("Get ATT MTU, conn_id: %d", conn_id);
+       CHECK_OAL_GATT_ENABLED();
+       OAL_CHECK_PARAMETER(mtu, return);
+
+       /* To prevent crash in case other libraries not support this api */
+       if (gatt_api->server->get_att_mtu == NULL) {
+               BT_WARN("get_att_mtu is NULL");
+               return OAL_STATUS_NOT_SUPPORT;
+       }
+
+       ret = gatt_api->server->get_att_mtu(conn_id, mtu);
+       if (ret != BT_STATUS_SUCCESS) {
+               BT_ERR("GATT MTU Size failed, status: %d", status2string(ret));
+               return convert_to_oal_status(ret);
+       }
+
+       BT_INFO("Current ATT MTU Size: %d", *mtu);
+       return OAL_STATUS_SUCCESS;
+}