Damian Królik | 8dc7e7f | 2020-09-30 00:29:33 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020 Project CHIP Authors |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
Andrei Litvin | 1873e8c | 2020-10-12 10:52:26 -0400 | [diff] [blame] | 18 | #pragma once |
Damian Królik | 8dc7e7f | 2020-09-30 00:29:33 +0200 | [diff] [blame] | 19 | |
Kamil Kasperczyk | 04b4f07 | 2022-05-16 15:15:16 +0200 | [diff] [blame] | 20 | #include <lib/support/Span.h> |
Damian Królik | 8dc7e7f | 2020-09-30 00:29:33 +0200 | [diff] [blame] | 21 | #include <setup_payload/SetupPayload.h> |
| 22 | |
Kamil Kasperczyk | 07c3947 | 2021-04-17 01:06:26 +0200 | [diff] [blame] | 23 | void PrintOnboardingCodes(chip::RendezvousInformationFlags aRendezvousFlags); |
Kamil Kasperczyk | 04b4f07 | 2022-05-16 15:15:16 +0200 | [diff] [blame] | 24 | void PrintOnboardingCodes(const chip::PayloadContents & payload); |
Kamil Kasperczyk | 07c3947 | 2021-04-17 01:06:26 +0200 | [diff] [blame] | 25 | void ShareQRCodeOverNFC(chip::RendezvousInformationFlags aRendezvousFlags); |
Kamil Kasperczyk | 04b4f07 | 2022-05-16 15:15:16 +0200 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Creates a null-terminated QR code from the payload created based on rendezvous flag information. |
| 29 | * |
| 30 | * The resulting size of the QR code span will be the size of data written and not including the null terminator. |
| 31 | */ |
| 32 | CHIP_ERROR GetQRCode(chip::MutableCharSpan & aQRCode, chip::RendezvousInformationFlags aRendezvousFlags); |
| 33 | |
| 34 | /** |
| 35 | * Creates a null-terminated QR code based on the provided payload. |
| 36 | * |
| 37 | * The resulting size of the QR code span will be the size of data written and not including the null terminator. |
| 38 | */ |
| 39 | CHIP_ERROR GetQRCode(chip::MutableCharSpan & aQRCode, const chip::PayloadContents & payload); |
| 40 | |
| 41 | /** |
| 42 | * Creates a null-terminated QR code url. |
| 43 | */ |
| 44 | CHIP_ERROR GetQRCodeUrl(char * aQRCodeUrl, size_t aUrlMaxSize, const chip::CharSpan & aQRCode); |
| 45 | |
| 46 | /** |
| 47 | * Creates a null-terminated manual pairing code from the payload created based on rendezvous flag information. |
| 48 | * |
| 49 | * The resulting size of the manual pairing code span will be the size of data written and not including the null terminator. |
| 50 | */ |
| 51 | CHIP_ERROR GetManualPairingCode(chip::MutableCharSpan & aManualPairingCode, chip::RendezvousInformationFlags aRendezvousFlags); |
| 52 | |
| 53 | /** |
| 54 | * Creates a null-terminated manual pairing code based on the provided payload. |
| 55 | * |
| 56 | * The resulting size of the manual pairing code span will be the size of data written and not including the null terminator. |
| 57 | */ |
| 58 | CHIP_ERROR GetManualPairingCode(chip::MutableCharSpan & aManualPairingCode, const chip::PayloadContents & payload); |
| 59 | |
| 60 | CHIP_ERROR GetPayloadContents(chip::PayloadContents & aPayload, chip::RendezvousInformationFlags aRendezvousFlags); |
Kamil Kasperczyk | 034c37a | 2020-11-24 18:00:17 +0100 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Initialize DataModelHandler and start CHIP datamodel server, the server |
| 64 | * assumes the platform's networking has been setup already. |
| 65 | * |
| 66 | * Method verifies if every character of the QR Code is valid for the url encoding |
| 67 | * and otherwise it encodes the invalid character using available ones. |
| 68 | * |
Kamil Kasperczyk | 07c3947 | 2021-04-17 01:06:26 +0200 | [diff] [blame] | 69 | * @param aQRCode address of the array storing QR Code to encode. |
| 70 | * @param aLen length of the given QR Code. |
| 71 | * @param aUrl address of the location where encoded url should be stored. |
| 72 | * @param aMaxSize maximal size of the array where encoded url should be stored. |
Kamil Kasperczyk | 034c37a | 2020-11-24 18:00:17 +0100 | [diff] [blame] | 73 | * @return CHIP_NO_ERROR on success and other values on error. |
| 74 | */ |
Kamil Kasperczyk | 07c3947 | 2021-04-17 01:06:26 +0200 | [diff] [blame] | 75 | CHIP_ERROR EncodeQRCodeToUrl(const char * aQRCode, size_t aLen, char * aUrl, size_t aMaxSize); |