FUS (Firmware Update Server) API#

Note

Additional documentation on the whole FUS API is provided here: samsung-loki.github.io/samsung-docs/docs/FUS/.

class samloader3.fus.AuthenticationError[source]#

Custom exception for authentication errors.

class samloader3.fus.FUSAuthorization(encrypted_nonce: str = '', signature: str = '', nc: str = '', type: str = '', realm: str = '', newauth: str = '1')[source]#

Represents FUS (Firmware Update Server ?) authorization information.

Parameters:
  • encrypted_nonce (str) – The encrypted nonce.

  • signature (str) – The signature.

  • nc (str) – The nonce count.

  • type (str) – The authorization type.

  • realm (str) – The authentication realm.

  • newauth (str) – Flag indicating new authentication.

class samloader3.fus.FUSClient(user_agent: str | None = None, timeout: int = 25000)[source]#

Represents a client for interacting with the Firmware Update Server (FUS).

Parameters:
  • user_agent (str, optional) – The user agent to use in HTTP requests.

  • timeout (int, optional) – The timeout for HTTP requests in seconds.

property authv: str#

The string representation of the authentication information.

firmware_exists(model_name: str, local_code: str) bool[source]#

Checks if firmware exists for a given model and local code.

Parameters:
  • model_name (str) – The model name.

  • local_code (str) – The local code.

Returns:

True if firmware exists, False otherwise.

Return type:

bool

fw_info(version: str, model_name: str, local_code: str, imei: str, nature: BinaryNature = BinaryNature.FACTORY, client_product: str | None = None) FirmwareInfo[source]#

Retrieves firmware information from the FUS server.

Parameters:
  • version (str) – The firmware version.

  • model_name (str) – The model name.

  • local_code (str) – The local code.

  • imei (str) – The imei/serial number.

  • nature (BinaryNature, optional) – The binary nature.

  • client_product (str, optional) – The client product name (default is “Smart Switch”).

Returns:

The firmware information.

Return type:

FirmwareInfo

get_firmware_specs(model_name: str, local_code: str) VersionInfo[source]#

Retrieves firmware specifications for a given model and local code.

Parameters:
  • model_name (str) – The model name.

  • local_code (str) – The local code.

Returns:

The firmware version information.

Return type:

VersionInfo

init_download(info: FirmwareInfo) None[source]#

Initializes the firmware download.

Parameters:

info (FirmwareInfo) – The firmware information.

Returns:

None

request(key: str, method='POST', payload: str | None = None, query: str | None = None, headers: Dict[str, Any] | None = None, as_stream=False, from_cloud=False) Response[source]#

Makes a request to the FUS server.

Parameters:
  • key (str) – The key for the request.

  • method (str, optional) – The HTTP method for the request (default is “POST”).

  • payload (str, optional) – The payload for the request.

  • query (str, optional) – The query parameters for the request.

  • headers (dict, optional) – Additional headers for the request.

  • as_stream (bool, optional) – Flag indicating if the response should be streamed.

  • from_cloud (bool, optional) – Flag indicating if the request is to the cloud domain.

Returns:

The response from the FUS server.

Return type:

requests.Response

setup() None[source]#

Sets up the FUS client by generating a nonce.

Returns:

None

start_download(info: FirmwareInfo, start=0) Response[source]#

Starts the firmware download.

Parameters:
  • info (FirmwareInfo) – The firmware information.

  • start (int, optional) – The starting position for the download (default is 0).

Returns:

The response from the FUS server.

Return type:

requests.Response

samloader3.fus.FUSHdr(message: Element, version: str = '1.0') None[source]#

Adds a header to the given XML message.

Parameters:
  • message (ElementTree.Element) – The XML message to which the header is added.

  • version (str) – The protocol version for the header.

samloader3.fus.FUSBody(message: Element, data: Dict[str, Any]) None[source]#

Adds a body with specified data to the given XML message.

Parameters:
  • message (ElementTree.Element) – The XML message to which the body is added.

  • data (dict) – A dictionary containing data to be included in the body.

samloader3.fus.FUSMsg(data: Dict[str, Any], version: str = '1.0') Element[source]#

Creates an XML message with the specified data.

Parameters:
  • data (dict) – A dictionary containing data to be included in the message body.

  • version (str) – The protocol version for the header.

Returns:

The created XML message.

Return type:

ElementTree.Element

samloader3.fus.firmware_spec_url(model_name: str, local_code: str) str[source]#

Generates the URL for fetching firmware specifications.

Parameters:
  • model_name (str) – The model name for the firmware.

  • local_code (str) – The local code for the firmware.

Returns:

The generated URL for fetching firmware specifications.

Return type:

str

samloader3.fus.v4_key(info: FirmwareInfo, nature: BinaryNature = BinaryNature.FACTORY) Tuple[str, bytes][source]#

Generates a version 4 key for the provided firmware information.

Parameters:
Returns:

A tuple containing the key as a string and its MD5 digest.

Return type:

tuple[str, bytes]

samloader3.fus.v2_key(version: str, model_name: str, local_code: str) Tuple[str, bytes][source]#

Generates a version 2 key for the specified parameters.

Parameters:
  • version (str) – The firmware version.

  • model_name (str) – The model name for the firmware.

  • local_code (str) – The local code for the firmware.

Returns:

A tuple containing the key as a string and its MD5 digest.

Return type:

tuple[str, bytes]