Issue in physics body collision cocos2d-x v3.2

I have two dynamic physics bodies, bodyA and bodyB. I have set bodyB->setGravityEnabled(false) and applied a linear velocity on it. And at the same time applied impulse on bodyA. My goal is bodyA should hit bodyB and bounce randomly while bodyB should not be impacted by the collision. I read the collision bitmask but couldnt understand properly. Please help.

PhysicsBody *bodyA = PhysicsBody::createCircle(spriteA->getContentSize().width/2);
bodyA->setDynamic(true);
bodyA->setMass(0.5f);
bodyA->setCategoryBitmask(1);
bodyA->setContactTestBitmask(true);

PhysicsBody *bodyB = PhysicsBody::createCircle(spriteB->getContentSize().width/2);
bodyB->setDynamic(true);
bodyB->setGravityEnable(false);
bodyB->setVelocity(Vect(100,0));
bodyB->setCollisionBitmask(2);
bodyB->setContactTestBitmask(true);
bodyB->setMass(5.0f);