def connection_gsm(gsm_client, network_apn, network_user, network_password):
    """
    This function waits for the network to be available and opens a gprs connection

    Args:
        gsm_client      (GsmClient): An object of the GsmClient class
        network_apn        (string): The network apn
        network_user       (string): The network user
        network_password   (string): The network password

    Returns:
        bool: True if successful, False otherwise.

    """
    if not gsm_client.waitForNetwork():
        return False
    return gsm_client.gprsConnect(network_apn, network_user, network_password)