Skip to content

Commit

Permalink
[Demo] [ESP32] Add discriminator, rendezvousInformation and setupPINC…
Browse files Browse the repository at this point in the history
…ode to the QRCode payload (#1234)
  • Loading branch information
vivien-apple authored Jun 24, 2020
1 parent 56c7c48 commit f01110e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions examples/wifi-echo/server/esp32/main/QRCodeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@
#define MAX_SSID_LEN 32
// A temporary value assigned for this example's QRCode
// Spells CHIP on a dialer
#define EXAMPLE_VENDOR_ID 3447
#define EXAMPLE_VENDOR_ID 2447
// Spells ESP32 on a dialer
#define EXAMPLE_PRODUCT_ID 37732
// Used to have an initial shared secret
#define EXAMPLE_SETUP_CODE 123456789
// Used to indicate that the device supports both Soft-AP and BLE for rendezvous
#define EXAMPLE_RENDEZVOUS_INFO 3
// Used to indicate that an SSID has been added to the QRCode
#define EXAMPLE_VENDOR_TAG_SSID 1
// Used to indicate that an IP address has been added to the QRCode
Expand Down Expand Up @@ -88,12 +94,19 @@ void GetGatewayIP(char * ip_buf, size_t ip_len)

string createSetupPayload()
{
// The discriminator is generated randomly so different devices can be turned on at the same time for testing.
uint16_t discriminator = (esp_random() * 1.0 / UINT32_MAX * ((1 << kPayloadDiscriminatorFieldLengthInBits) + 1));

SetupPayload payload;
payload.version = 1;
payload.discriminator = discriminator;
payload.setUpPINCode = EXAMPLE_SETUP_CODE;
payload.rendezvousInformation = EXAMPLE_RENDEZVOUS_INFO;
payload.vendorID = EXAMPLE_VENDOR_ID;
payload.productID = EXAMPLE_PRODUCT_ID;

char ap_ssid[MAX_SSID_LEN];
GetAPName(ap_ssid, sizeof(ap_ssid));
SetupPayload payload;
payload.version = 1;
payload.vendorID = EXAMPLE_VENDOR_ID;
payload.productID = 1;
payload.addOptionalVendorData(EXAMPLE_VENDOR_TAG_SSID, ap_ssid);

char gw_ip[INET6_ADDRSTRLEN];
Expand Down

0 comments on commit f01110e

Please sign in to comment.