Comments (4)
Oh, here is an idea: for characteristic you can create your mega wrapper structure like so:
typedef struct {
union {
HAPDataCharacteristic data_base;
HAPBoolCharacteristic bool_base;
HAPUInt8Characteristic uint8_base;
// ...
};
void *context;
} MyHAPCharacteristic;
So, in your own code you can work with all characteristic types the same way. Assuming you're doing C++ wrappers anyways.
from homekitadk.
👍
I'm all supportive for having a contexts on a fine grained level, e.g. characteristic. Not sure why you need a server-wide context that is explicitly passed to every characteristic callback. It's not like you gonna have multiple instances of HAPAccessoryServer anyways, if I wanted to have a global context, I would just create a global variable and reference it directly.
Now, I think you can do it yourself: just create your own structures for HAPAccessory, HAPService and HAP*Characteristic and extend them with additional fields:
typedef struct {
HAPAccessory base;
// here go extra fields
void *context;
} MyHAPAccessory;
Then in your callbacks you can cast structures passed to you in request to your structures and pull whatever extra information you planted there.
from homekitadk.
good idea! this will work for accessory and service but will be extremely ugly for characteristics because HAPCharacteristic is cast to a specific characteristic types (poor-man's OOP in C). we'll need to wrap all of those.
from homekitadk.
It's not that bad, there's just 10 of them.
from homekitadk.
Related Issues (20)
- BLE and IP transports at the same time HOT 2
- Apple Defined Characteristics documented but not address in HAPCharacteristicTypes.h
- make all Error (related to mbedtls) HOT 4
- Docker build for Raspberry ends with an error
- How to build this library as .so
- linux compile raspberry pi firmware error HOT 1
- mbedtls --HEAD CMake Error
- Make docs doesn't work on Ubuntu
- Thread Network Protocol Redux HOT 4
- Make docs doesn't work on Ubuntu HOT 2
- How to use this code
- Unable to trigger write name event in Home APP HOT 3
- The HomeApp auto disconnect HOT 1
- Can't build project on m1
- Make docs not working on M1 HOT 1
- libdns_sd.so.1
- [Mbedtls] Compiler build error ,some chachapoly API undefined
- Ss
- How to update openssl version to V3.X?
- bbj
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homekitadk.