odyshewroman / AndroidTVRemoteControl

MIT License
31 stars 9 forks source link

Need code every time #13

Closed Jacky154 closed 10 months ago

Jacky154 commented 11 months ago

Hi Kindly I need the answer quickly. I want to show the code every time on tv and connect. I don't want to skip the pairing process in case if already connected. I want to pair and connect again and again. But In your code if I already connected then code not shown on smart tv screen Thanks

Jacky154 commented 11 months ago

I also tried your disconnect method to disconnect and reconnect but still if I already connected then code not shown on. Actually I am not understanding that which state shows that I am already connected and how to know that I need to connect if I am not already connected.

odyshewroman commented 11 months ago

@Jacky154 you should modify the connect function in RemoteTVManager as follows:

queue.async {
            self.remoteManager.stateChanged = { [weak self] remoteState in
                self?.remoteStateChanged?(remoteState.toString())
            }

            self.pairingManager.stateChanged = { [weak self] pairingState in
                self?.pairingStateChanged?(pairingState.toString())

                if case .successPaired = pairingState {
                    self?.remoteManager.connect(host)
                }
            }

            self.pairingManager.connect(host, "client", "iPhone")
        }
Jacky154 commented 11 months ago

Ok I am going to try it. Thanks for reply

Jacky154 commented 11 months ago

Hey bro can you tell me the password of p12 certificate I am opening it in keychain access I am getting this error "TVController.AndroidTVRemoteControlError.noServerPublicCertificate"

code being shown everytime but not reaching at successpaird state "func connect(host: String) { queue.async { self.remoteManager.stateChanged = { [weak self] remoteState in

                self?.remoteStateChanged?(remoteState.toString())
                if case .connected = remoteState {
                    self?.pairingSuccess?()
                }
            }

            self.pairingManager.stateChanged = { [weak self] pairingState in
                print(pairingState)
                self?.pairingStateChanged?(pairingState.toString())

                if case .successPaired = pairingState {
                    self?.remoteManager.connect(host)
                    self?.pairingSuccess?()

// self?.pairedback?() }

                if case .waitingCode = pairingState {
                    self?.codeSent?()
                }
            }

            self.pairingManager.connect(host, "client", "iPhone")
        }
    }"
Jacky154 commented 11 months ago

Its urgent can you give any suggestions. Please I am not understanding anything. It generate code but Now after entering code it is not reaching at successpaired state

Jacky154 commented 11 months ago

Bro I just want that code should show everytime when call connect method and in connect method I am calling .Pairingsuccess method to check whether pairedsuccess then when pairingsuccess callback function call then I am navigating to another screen. I can't navigate until pairingsuccess not call. And the error is that it is not being called. Kindly check the code and give some suggestions

func connect(host: String) { queue.async { self.remoteManager.stateChanged = { [weak self] remoteState in

self?.remoteStateChanged?(remoteState.toString()) if case .connected = remoteState { self?.pairingSuccess?() } } self.pairingManager.stateChanged = { [weak self] pairingState in print(pairingState) self?.pairingStateChanged?(pairingState.toString()) if case .successPaired = pairingState { self?.remoteManager.connect(host) self?.pairingSuccess?() }

if case .waitingCode = pairingState { self?.codeSent?() } } self.pairingManager.connect(host, "client", "iPhone") } }"

Jacky154 commented 11 months ago

And If the above code not works then I am implementing logic in which I duplicate the certificates cert.p12 and cert.der then whenever user open app I duplicate the certificates and pair and connect. Does this work for each time for showing code on screen and pairing then connect.

Please I need your reply.

Thanks for your help

odyshewroman commented 11 months ago

Hey bro can you tell me the password of p12 certificate I am opening it in keychain access I am getting this error "TVController.AndroidTVRemoteControlError.noServerPublicCertificate"

Password is empty, you can loot in source code.

In my opinion, you do not understand the working principles of this library. The README document describes in detail the process of pairing and sending commands; you need to familiarize yourself with it.