Changes

Line 254: Line 254:     
This is used by [[BTM_services|btm]].
 
This is used by [[BTM_services|btm]].
 +
 +
This first calls an interface funcptr, on failure 0xCA71 is returned.
 +
 +
A global fixed [[#Address]] is copied to stack, this stack data is then overwritten with the output from [[Settings_services|GetBluetoothBdAddress]]. If GetBluetoothBdAddress fails, this will Abort. Then the same funcptr used by [[#SetAdapterProperty]] is called with this stack data, with [[#BluetoothPropertyType|type2]]. A converted error is returned if needed.
 +
 +
The last two bytes of the stack [[#Address]] are inverted (byteval = ~byteval), then the above funcptr is called with this for [[#BluetoothPropertyType|type3]]. Error conversion is handled if needed, then this returns 0.
 +
 +
The first funcptr called above does the following:
 +
* Calls a GPIO func with param=0, [[SVC|sleeps]] for 10000000 nanoseconds, then calls the GPIO func again with param=1.
 +
* Calls a func for initializing the paired-devices table (empty).
 +
* Calls a modified version of BSA_Boot, which handles BSA server initialization.
 +
* Calls a func which uses <code>nn::os::InitializeEvent</code> and <code>nn::os::InitializeMutex</code> with global state.
 +
* Calls a func which handles BSA client initialization. This also sends a message to another thread for enabling bluetooth (which updates the interface funcptr tables, etc).
 +
* Calls a func which enables HID-Host with BSA, and opens the UIPC channel where the registered funcptr is used for writing HID DATA [[#GetHidReportEventInfo|reports]] which were received.
 +
* Calls a func which initializes global state and uses the BSA API for initializing Security.
 +
* If the output flag from [[Settings_services#GetBluetoothBoostEnableFlag|GetBluetoothBoostEnableFlag]] is set, a func is called.
 +
* If the output flag from [[Settings_services#GetBluetoothAfhEnableFlag|GetBluetoothAfhEnableFlag]] is not set, a func is called.
 +
 +
The GPIO func does the following:
 +
* Initializes the [[Bus_services|gpio]] service.
 +
* Uses [[Bus_services#OpenSession|OpenSession]] with value 0x03 (BtRst).
 +
* Uses SetDirection with value 0x1.
 +
* Uses SetValue with the param which was passed to this func.
 +
* Does cleanup for the session object and exits the service.
    
== DisableBluetooth ==
 
== DisableBluetooth ==