Newer
Older
#ifndef LIBMOBILE_ZTE_H
#define LIBMOBILE_ZTE_H
#include <curl/curl.h>
#include <json-c/json.h>
#include <string.h>
Jakob Olsson
committed
/***************************************************
* Libmobile - A 4G Dongle library
*
* Libmobile provides a library to perform basic functionality for a 4G dongle through
* the use of HTTP GET/POST.
*
* All library calls will prepare the GET or POST query, and send the request to the dongle.
* The response from the server is parsed through a callback, <write_func>. The dongle's response
* is then returned. For POST requests the dongle responds with {"result": "success"} on a
* successful query execution, and with {"result": failure"} on an unsuccessful query execution,
* note that an unsuccessful query execution can mean a variety of things such as: incorrect pin,
* wrong input format, value already set, etc. For a GET request the variable's requested for with
* their corresponding values are returned, important to note that even variables that are not
* available within the system will be returned, but with no value set. The return string for all
* calls is the servers response pointed to by a char pointer.
*
*
* How to extend libmobile
*
* To extend this library add a new function with the corresponding documentation. The naming scheme
* should follow the format <mobile_get_{variables}> for GET requests and <mobile_{action_performed}>
* for POST requests. The structure of the calls are that the <mobile_...> functions prepare the query,
* for GET this means providing the variables to request from the dongle, provided as an input to
* <mobile_get_request>, for POST this means providing the POSTFIELDS argument query to the method
* <mobile_post_request>. The dongle's response is parsed through a callback, a pointer is then returned
* pointing to the response.
*
***************************************************/
/***************************************************
* IMPORTANT NOTE
*
* The library calls will allocate memory for the dongle's response and return the pointer to this memory,
* the caller is then responsible for freeing this memory by calling free(returned_pointer).
Jakob Olsson
committed
***************************************************/
/**
* Function: mobile_unlock_sim
*
* Unlocks the SIM card and sets a new PIN in case of that it has been locked.
*
* Parameters:
* pin - a character pointer to the PIN string.
* puk - a character pointer to the PUK code.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
* NULL on failure.
*/
struct json_object *mobile_unlock_sim_zte(char *ip_addr, char *pin, char *puk);
Jakob Olsson
committed
/**
* Function: mobile_connect_network
*
* Connects the dongle's network.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_connect_network_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_disconnect_network
*
* Disconnects the dongle's network.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_disconnect_network_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_delete_apn
*
* Deletes an existing APN profile from the APN list.
*
* Parameters:
* name - The name of the APN profile to be removed.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_delete_apn_profile_zte(char *ip_addr, char *name);
Jakob Olsson
committed
/**
* Function: mobile_enable_roaming
*
* Enables the roaming option on the dongle.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_enable_roaming_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_disable_roaming
*
* Disables the roaming option on the dongle.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_disable_roaming_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_disable_roaming
*
* Gets the current roam status of the dongle.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"roam_setting_option": "on"/"off" }
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_get_roam_status_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_get_current_apn
*
* Gets the currently active APN profile.
*
* Returns:
* A pointer to a json_object containing the JSON profile on success.
* NULL on failure.
*/
struct json_object *mobile_get_current_apn_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_get_remaining_tries
Jakob Olsson
committed
*
* Gets the pinnumber variable, indicating how many tries are remaining before the SIM card is locked.
Jakob Olsson
committed
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"pinnumber": {1..3} } on success.
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_get_remaining_tries_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_get_pin_status
*
* Gets the pinnumber, indicating whether pin is enabled or not.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"pinnumber": {0..1} } on success.
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_get_pin_status_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_get_rssi
*
* Gets the rssi, indicating the signal strength.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"rssi": {} } on success.
struct json_object *mobile_get_rssi_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_get_modem_state
*
* Gets a variety of variables related to the modems state, i.e. network.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_get_modem_state_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_get_apn_profiles
*
* Gets all available APN profile names.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_get_apn_profiles_zte(char *ip_addr);
Jakob Olsson
committed
/**
* Function: mobile_create_apn_profile
*
* Creates a new APN profile.
*
* Parameter:
Jakob Olsson
committed
* name - Name of the APN profile to create.
* wan_apn - Name of the wan.
* pdp_type - The pdp type to use IPv4/IPv6.
Jakob Olsson
committed
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_create_apn_profile_zte(char *ip_addr, char *profile_name, char *wan_apn, char *pdp_type);
Jakob Olsson
committed
/**
* Function: mobile_set_apn_profile
*
* Sets a name APN profile to be activate.
*
* Parameter:
* name - Name of the APN profile to activate.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_set_apn_profile_zte(char *ip_addr, char *name);
Jakob Olsson
committed
/**
* Function: mobile_enable_pin
*
* Enables pin on the SIM card.
*
* Parameter:
* pin - The current pin card of the SIM.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_enable_pin_zte(char *ip_addr, char *pin);
Jakob Olsson
committed
/**
* Function: mobile_verify_pin
*
* Verifies whether input pin is the active one.
*
* Parameter:
* ip_addr - host addr of mobile dongle
* pin - pin to verify
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
* NULL on failure.
*/
struct json_object *mobile_verify_pin_zte(char *ip_addr, char *pin);
Jakob Olsson
committed
/**
* Function: mobile_set_pin
*
* Sets a new pin for the SIM card.
*
* Parameter:
* current_pin - The currently active pin for the SIM card.
* new_pin - The pin code which to set as the active pin for the SIM card.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_set_pin_zte(char *ip_addr, char *current_pin, char *new_pin);
Jakob Olsson
committed
/**
* Function: mobile_disable_pin
*
* Disables pin for the SIM card.
*
* Parameter:
* pin - Currently active pin.
*
* Returns:
* A pointer to a json_object containing the JSON response from the server. {"result": "success"/"failure"}
Jakob Olsson
committed
* NULL on failure.
*/
struct json_object *mobile_disable_pin_zte(char *ip_addr, char *pin);