示例#1
0
bool CBondManager::ensure_bond(uint8_t *p_device_type) {
	//Todo find if this device is actually the bond we checked
	bond_data_t temp_bond_data;
	*p_device_type = device_type;
	if (!bond_loaded) {
		if (device_type == kDeviceTypeAndroid) {
			if (mac_len != 6)
				memcpy(temp_bond_data.central_addr.addr,Nrf51822BluetoothStack::_stack->_peer_addr.addr,6);
			else
				memcpy(temp_bond_data.central_addr.addr,mac_addr,6);
			return save_bond(&temp_bond_data,true);
		}
		else if (device_type == kDeviceTypeIonode) {
			memcpy(temp_bond_data.central_addr.addr,Nrf51822BluetoothStack::_stack->_peer_addr.addr,6);
			return save_bond(&temp_bond_data,true);
		}
		else if (device_type == kDeviceTypeApple) {

			ANCSHandler.enable_ANCS(true);
			return false;
		}
		else {
			return false;
			//we really shouldn't be here. Bad device_type;
		}
	}
	else
		return true;

	return false;
}
示例#2
0
void set_bond_state(tx_bond_t *bond, int state)
{
  if (!bond)
    return;
  if (bond->bond_state == state)
    return;
  bond->bond_state = state;

  /* remotely inform connected peers that bond state has updated. */
  local_broadcast_bond(bond);

  /* save the new state info persistently. */
  save_bond(bond);
}