;TODO: maybe make this dynamic so the driver will use whatever RAM you want BluetoothCallbackLoc EQU appBackUpScreen ptrInputBuffer EQU BluetoothCallbackLoc+50 ; 50; HACK: make sure the runner never grows beyond 50 bytes responseFlag EQU ptrInputBuffer+2 ; 1; basePage EQU responseFlag+1 ; 1; responseDataLeft EQU basePage+1 ; 1; ptrData EQU responseDataLeft+1 ; 2; interruptPipe EQU ptrData+2 ; 1; dataOutPipe EQU interruptPipe+1 ; 1; dataInPipe EQU dataOutPipe+1 ; 1; ptrInputStart EQU dataInPipe+1 ; 2; RAMPage EQU ptrInputStart+2 ; 1; ptrACLBuffer EQU RAMPage+1 ; 2; ptrACLStart EQU ptrACLBuffer+2 ; 2; ptrTempStorage EQU ptrACLStart+2 ; 2; ptrInquiryResults EQU ptrTempStorage+2 ; 2; ;These three must be grouped together. deviceRequestInfo EQU ptrInquiryResults+2 BD_ADDR EQU deviceRequestInfo ; 6; classOfDevice EQU BD_ADDR+6 ; 3; linkType EQU classOfDevice+3 ; 1; ; eventDataBuffer EQU linkType+1 ;255; ;Link Control Commands hciInquiry EQU 01h hciInquiryCancel EQU 02h hciCreateConnection EQU 05h hciDisconnect EQU 06h hciAcceptConnectionRequest EQU 09h hciRejectConnectionRequest EQU 0Ah hciRemoteNameRequest EQU 19h ;HCI Policy Commands hciHoldMode EQU 01h ;HCI/Baseband Commands hciReset EQU 03h hciWriteLocalName EQU 13h hciReadLocalName EQU 14h hciWriteScanEnable EQU 1Ah hciWriteClassOfDevice EQU 24h ogfLinkControl EQU 1 << 2 ;04h ogfHCIPolicy EQU 2 << 2 ;08h ogfHCBaseband EQU 3 << 2 ;0Ch ogfInformation EQU 4 << 2 ;10h ogfStatus EQU 5 << 2 ;14h ogfTesting EQU 6 << 2 ;18h ;HCI inquiry result block ;DoInquiryScan returns an array of these objects offBD_ADDR EQU 0 ;6 bytes offPageScanRepetitionMode EQU 6 ;1 byte offReserved1 EQU 7 ;1 byte offReserved2 EQU 8 ;1 byte offClassOfDevice EQU 9 ;3 bytes offClockOffset EQU 12 ;2 bytes Event_InquiryComplete EQU 01h Event_InquiryResult EQU 02h Event_ConnectionComplete EQU 03h Event_ConnectionRequest EQU 04h Event_DisconnectionComplete EQU 05h Event_AuthenticationComplete EQU 06h Event_RemoteNameRequestComplete EQU 07h Event_EncryptionChange EQU 08h Event_ChangeConnectionLinkKeyComplete EQU 09h Event_MasterLinkKeyComplete EQU 0Ah Event_ReadRemoteSupportedFeaturesComplete EQU 0Bh Event_ReadRemoteVersionComplete EQU 0Ch Event_QoSSetupComplete EQU 0Dh Event_CommandComplete EQU 0Eh Event_CommandStatus EQU 0Fh Event_HardwareError EQU 10h Event_FlushOccurred EQU 11h Event_RoleChange EQU 12h Event_NumberOfCompletedPackets EQU 13h Event_ModeChange EQU 14h Event_ReturnLinkKeys EQU 15h Event_PINCodeRequest EQU 16h Event_LinkKeyRequest EQU 17h Event_LinkKeyNotification EQU 18h Event_LoopbackCommand EQU 19h Event_DataBufferOverflow EQU 1Ah Event_MaxSlotsChange EQU 1Bh Event_ReadClockOffsetComplete EQU 1Ch Event_ConnectionPacketTypeChanged EQU 1Dh Event_QoSViolation EQU 1Eh Event_PageScanModeChange EQU 1Fh Event_PageScanRepetitionModeChange EQU 20h ;Custom error codes errHCICommandFailedSend EQU 0FFh ;we couldn't even send the control packet errInvalidDeviceClass EQU 0FEh ;this doesn't show as a Bluetooth device (0E0h, 01h, 01h) errOnAborted EQU 0FDh ;the operation was canceled because the user pressed ON ;HCI error codes errUnknownHCICommand EQU 01h errNoConnection EQU 02h errHardwareFailure EQU 03h errPageTimeout EQU 04h errAuthenticationFailure EQU 05h errKeyMissing EQU 06h errMemoryFull EQU 07h errConnectionTimeout EQU 08h errMaxNumberOfConnections EQU 09h errMaxNumberOfSCOConns EQU 0Ah errACLConnAlreadyExists EQU 0Bh errCommandDisallowed EQU 0Ch errHostRejectedLimitedRes EQU 0Dh errHostRejectedSecurity EQU 0Eh errHostRejectedPersonal EQU 0Fh errHostTimeout EQU 10h errUnsupportedFeature EQU 11h errInvalidHCICmdParameters EQU 12h errUserTerminatedConnection EQU 13h errLowResTerminatedConn EQU 14h errPowerOffTerminatedConn EQU 15h errLocalHostTerminatedConn EQU 16h errRepeatedAttempts EQU 17h errPairingNotAllowed EQU 18h errUnknownLMPPDU EQU 19h errUnsupportedRemoteFeature EQU 1Ah errSCOOffsetRejected EQU 1Bh errSCOIntervalRejected EQU 1Ch errSCOAirModeRejected EQU 1Dh errInvalidLMPParameters EQU 1Eh errUnspecifiedError EQU 1Fh errUnsupportedLMPParameter EQU 20h errRoleChangeNotAllowed EQU 21h errLMPResponseTimeout EQU 22h errLMPErrorTransactionColl EQU 23h errLMPPDUNotAllowed EQU 24h errEncryptionModeNotAccept EQU 25h errUnitKeyUsed EQU 26h errQoSNotSupported EQU 27h errInstantPassed EQU 28h errNoPairingWithUnitKey EQU 29h ;Flags cmdComplete EQU 0 cmdStarted EQU 1 deviceConnected EQU 2 inDiscoverableMode EQU 3 receivedConnRequest EQU 4 L2CAPDataReceived EQU 5 ACLDataReceived EQU 6 ACLPacketStarted EQU 7