Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement a bridge #32

Closed
leonrinkel opened this issue Jan 27, 2020 · 2 comments
Closed

How to implement a bridge #32

leonrinkel opened this issue Jan 27, 2020 · 2 comments

Comments

@leonrinkel
Copy link
Contributor

Hi,

I'm trying a to implement a simple bridge including a bridged light bulb accessory. I basically added two accessories and used HAPAccessoryServerStartBridge instead of HAPAccessoryServerStart like in the following snippets. The bridge accessory works as expected, I successfully added it in the Apple Home app. Unfortunately the light bulb does not show up in the app. Instead it says "Additional Setup Required", "Add related accessories with Acme Bridge in the manufacturers app." Does a bridge really need a separate app to add accessories or is the issue somewhere else?

static HAPAccessory bridgeAccessory = { .aid = 1,
                                        .category = kHAPAccessoryCategory_Bridges,
                                        .name = "Acme Bridge",
                                        .manufacturer = "Acme",
                                        .model = "Bridge1,1",
                                        .serialNumber = "ABCDEFGH0001",
                                        .firmwareVersion = "1",
                                        .hardwareVersion = "1",
                                        .services = (const HAPService* const[]) { &bridgeAccessoryInformationService,
                                                                                  &hapProtocolInformationService,
                                                                                  &pairingService,
                                                                                  NULL },
                                        .callbacks = { .identify = IdentifyAccessory } };

static HAPAccessory lightBulbAccessory = { .aid = 2,
                                           .category = kHAPAccessoryCategory_BridgedAccessory,
                                           .name = "Acme Light Bulb",
                                           .manufacturer = "Acme",
                                           .model = "LightBulb1,1",
                                           .serialNumber = "ABCDEFGH0002",
                                           .firmwareVersion = "1",
                                           .hardwareVersion = "1",
                                           .services = (const HAPService* const[]) { &lightBulbAccessoryInformationService,
                                                                                     &lightBulbService,
                                                                                     NULL },
                                           .callbacks = { .identify = IdentifyAccessory } };
void AppAccessoryServerStart(void) {
    HAPAccessoryServerStartBridge(
        accessoryConfiguration.server, &bridgeAccessory,
        (const HAPAccessory* const[]) { &lightBulbAccessory,
                                        NULL },
        true
    );
}

Full source is available here.

Thanks!

@leonrinkel
Copy link
Contributor Author

Ok I just tried the same scenario using the HomeKit Accessory Simulator and the light bulb shows up immediately, so I guess a separate bridge app is not required and the issue is somewhere else.

@leonrinkel
Copy link
Contributor Author

I found out it has to be like this:

const HAPAccessory* _Nullable const* _Nullable bridgedAccessories =
    (const HAPAccessory* const[]) { &lightBulbAccessory,
                                    NULL };

void AppAccessoryServerStart(void) {
    HAPAccessoryServerStartBridge(
        accessoryConfiguration.server, &bridgeAccessory,
        bridgedAccessories, true
    );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant