Electronic device and method for uploading data of external electronic device in electronic device
An electronic device includes a communication circuit, and at least one processor connected to the communication circuit. The at least one processor may be configured to broadcast a device identification (ID) of the electronic device and an Internet protocol (IP) address of the electronic device through the communication circuit. The at least one processor may be configured to receive a token encrypted by an external electronic device and data of the external electronic device through the communication circuit. The at least one processor may be configured to decrypt the encrypted token by using a private key of the electronic device. The at least one processor may be configured to transmit the data of the external electronic device to a server in a cloud by using the decrypted token through the communication circuit.
1 . An electronic device comprising:
a communication circuit;
a processor; and
memory storing instructions that, when executed by the processor, cause the electronic device to:
receive, via the communication circuit, a device identification (ID) of an external electronic device and an Internet protocol (IP) address of the external electronic device, wherein the device ID and the IP address are broadcasted periodically,
receive, via the communication circuit, from a server in a cloud, a token related to the device ID of the external electronic device,
encrypt the token related to the device ID of the external electronic device,
attempt to upload data of the electronic device to the server in the cloud, and
based on the attempt to upload the data of the electronic device to the server in the cloud resulting in a failure to upload the data of the electronic device, transmit, via the communication circuit to the external electronic device, the encrypted token and the data of the electronic device,
wherein the data of the electronic device is uploaded to the server in the cloud through the external electronic device based on the encrypted token.
2 . The electronic device of claim 1 , wherein the processor is further configured to:
receive, through the communication circuit from the server, a certificate related to a private key of the external electronic device and a root certificate authority (CA) used for generating a transport layer security (TLS) session, and
generate the TLS session with the external electronic device in order to transmit the data to the external electronic device.
3 . The electronic device of claim 1 , wherein the instructions, when executed by the processor, further cause the electronic device to encrypt the token related to the device ID of the external electronic device by using a certificate related to a private key of the external electronic device.
4 . The electronic device of claim 1 , wherein the electronic device is an IP video camera that records video in real time and periodically uploads the data for the video to the server, and
based on the electronic device failing to upload the data for the video to the server, wherein the processor is further configured to identify at least one external electronic device that transmits the data to the server instead.
5 . The electronic device of claim 4 , wherein the processor is further configured to store a list about the at least one external electronic device broadcasting at least one device ID and at least one IP address.
6 . A method for operating an electronic device, the method comprising:
receiving a device identification (ID) of an external electronic device and an Internet protocol (IP) address of the external electronic device, wherein the device ID and the IP address are broadcasted periodically;
receiving, from a server in a cloud, a token related to the device ID of the external electronic device;
encrypting the token related to the device ID of the external electronic device;
attempting to upload data of the electronic device to the server in the cloud; and
based on the attempt to upload the data of the electronic device to the server in the cloud resulting in a failure to upload the data of the electronic device, transmitting, to the external electronic device, the encrypted token and the data of the electronic device,
wherein the data of the electronic device is uploaded to the server in the cloud through the external electronic device based on the encrypted token.
7 . The method of claim 6 , further comprising:
receiving a certificate related to a private key of the external electronic device and a root certificate authority (CA) used for generating a transport layer security (TLS) session; and
generating the TLS session with the external electronic device in order to transmit the data to the external electronic device.
8 . The method of claim 7 , further comprising:
encrypting the token related to the device ID of the external electronic device by using a certificate related to a private key of the external electronic device.
9 . A non-transitory computer-readable storage medium storing computer-executable instructions that, when executed by a processor of an electronic device, configure the electronic device to perform operations, the operations comprising:
receiving a device identification (ID) of an external electronic device and an Internet protocol (IP) address of the external electronic device, wherein the device ID and the IP address are broadcasted periodically;
receiving, from a server in a cloud, a token related to the device ID of the external electronic device;
encrypting the token related to the device ID of the external electronic device;
attempting to upload data of the electronic device to the server in the cloud; and
based on the attempt to upload the data of the electronic device to the server in the cloud resulting in a failure to upload the data of the electronic device, transmitting, to the external electronic device, the encrypted token and the data of the electronic device,
wherein the data of the electronic device is uploaded to the server in the cloud through the external electronic device based on the encrypted token.