There are two program languages to implement the Google tv pairing protocol library:
- JAVA version <-- my reference sample
- C++ version <-- my target
I am implementing the connecting task of my pairing program. I found some JAVA sample code to call the pairing library just like here .
A definition under the method 'attemptToPair' in the above link code :
PoloWireInterface protocol =
WireFormat.PROTOCOL_BUFFERS.getWireInterface(context);
I do not know how to implement this definition by calling the C++ version library.
Because the class 'PoloWireInterface' is just an abstract class under C++ version library.
In addition, no any other class extends PoloWireInterface under this library. (Check here)
I can't establish an instance of 'ClientPairingSession' without the PoloWireInterface instance.
My client part pairing task as following code, but it is not work :'(
using namespace polo::pairing;
using namespace polo::wire;
using namespace polo::encoding;
X509* peer_cert = // peer side certificate, load by openssl
X509* local_cert = // local side certificate, generate by openssl
PairingContext* context;
context = new PairingContext(local_cert,peer_cert,false);
// CPoloWireInterface extends abstract class PoloWireInterface
PoloWireInterface* protocol = new CPoloWireInterface();
PoloWireAdapter* wire = new protobuf::ProtobufWireAdapter(protocol);
PoloChallengeResponse* challenge;
challenge = new PoloChallengeResponse(local_cert,peer_cert);
ClientPairingSession* mClientPairingSession;
mClientPairingSession = new ClientPairingSession
(wire, context, challenge, service_name, "AnyMote");
EncodingOption hexEnc(EncodingOption::kHexadecimal, 4);
mClientPairingSession->AddInputEncoding(hexEnc);
mClientPairingSession->AddOutputEncoding(hexEnc);
// CPairingListener extends abstract class PairingListener
PairingListener* listener = new CPairingListener();
mClientPairingSession->DoPair(listener);