0

There are two program languages to implement the Google tv pairing protocol library:

  1. JAVA version <-- my reference sample
  2. 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);
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
summerdog
  • 71
  • 1
  • 6

1 Answers1

0

You will not find a exact match between the java and c++ library. You should try this tutorial for working with c++ library:

https://google-tv-chrome-extensions.googlecode.com/git/LearningExerciseInstructions/instructions.html

  • Do you mean I can't call the library of google pairing directly, because it is not ready yet? I found that APIs of 'google-tv-chrome-extension' are different with 'google-tv-pairing-protocol'. May I have the source code of Anymote library under 'google-tv-chrome-extension' project? I want to override some functions of pairing task. – summerdog Sep 25 '12 at 01:43