apple / HomeKitADK

Apache License 2.0
2.55k stars 232 forks source link

Connect, Pair, but can not receive value #111

Open sss22213 opened 3 years ago

sss22213 commented 3 years ago

Hi there,

I build homekit ADK on my board and code examples to test it.

HAP_RESULT_USE_CHECK
HAPError HandleTemp(
        HAPAccessoryServerRef* server HAP_UNUSED,
        const HAPFloatCharacteristicReadRequest* request HAP_UNUSED,
        float* value,
        void* _Nullable context HAP_UNUSED){
   *value = 24.0;

    return kHAPError_None;
}

I set the value of the sensor as 24, but iPhone can not display the value.

The iPhone can pair the device, and print information of the device (manufacturer, ...).

2021-06-14'T'08:28:24'Z'    Info    [com.apple.mfi.HomeKit.Core:Characteristic] [0000000000000001 Temperature Sensor] [0000000000000035 temperature.target] Calling read handler.
2021-06-14'T'08:28:24'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4de068:<
    0000  48545450 2f312e31 20323030 204f4b0d 0a436f6e 74656e74 2d547970 653a2061    HTTP/1.1 200 OK..Content-Type: a
    0020  70706c69 63617469 6f6e2f68 61702b6a 736f6e0d 0a436f6e 74656e74 2d4c656e    pplication/hap+json..Content-Len
    0040  6774683a 2035310d 0a0d0a7b 22636861 72616374 65726973 74696373 223a5b7b    gth: 51....{"characteristics":[{
    0060  22616964 223a312c 22696964 223a3533 2c227661 6c756522 3a32347d 5d7d        "aid":1,"iid":53,"value":24}]}
2021-06-14'T'08:33:15'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4de068:>
    0000  50555420 2f636861 72616374 65726973 74696373 20485454 502f312e 310d0a48    PUT /characteristics HTTP/1.1..H
    0020  6f73743a 2054656d 70657261 74757265 5c303332 53656e73 6f722e5f 6861702e    ost: Temperature\032Sensor._hap.
    0040  5f746370 2e6c6f63 616c0d0a 436f6e74 656e742d 4c656e67 74683a20 35300d0a    _tcp.local..Content-Length: 50..
    0060  436f6e74 656e742d 54797065 3a206170 706c6963 6174696f 6e2f6861 702b6a73    Content-Type: application/hap+js
    0080  6f6e0d0a 0d0a7b22 63686172 61637465 72697374 69637322 3a5b7b22 61696422    on....{"characteristics":[{"aid"
    00a0  3a312c22 69696422 3a35332c 22657622 3a747275 657d5d7d                      :1,"iid":53,"ev":true}]}
2021-06-14'T'08:33:15'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4de068:<
    0000  48545450 2f312e31 20323034 204e6f20 436f6e74 656e740d 0a0d0a               HTTP/1.1 204 No Content....
2021-06-14'T'08:33:15'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x4de068:>
    0000  47455420 2f636861 72616374 65726973 74696373 3f69643d 312e3533 20485454    GET /characteristics?id=1.53 HTT
    0020  502f312e 310d0a48 6f73743a 2054656d 70657261 74757265 5c303332 53656e73    P/1.1..Host: Temperature\032Sens
    0040  6f722e5f 6861702e 5f746370 2e6c6f63 616c0d0a 0d0a                          or._hap._tcp.local....

startup log:

021-06-14'T'11:38:03'Z' Debug   [com.apple.mfi.HomeKit.Platform:KeyValueStore] Storage configuration: keyValueStore = 4
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:AccessorySetup] Storage configuration: accessorySetup = 4
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:TCPStreamManager] Storage configuration: tcpStreamManager = 60
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:TCPStreamManager] Storage configuration: maxTCPStreams = 17
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:TCPStreamManager] Storage configuration: tcpStreams = 408
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] Storage configuration: serviceDiscovery = 552
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:RunLoop] Storage configuration: runLoop = 320
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:RunLoop] Storage configuration: fileHandle = 28
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:RunLoop] Storage configuration: timer = 24
2021-06-14'T'11:38:03'Z'    Default [com.apple.mfi.HomeKit.Core:AccessoryServer] Version information:
libhap: Unknown
  - Version: Internal (Jun 14 2021 11:30:17) - compatibility version 7
Using platform: Linux
  - Version: 5.10.31-v7l (Jun 14 2021 11:30:20) - compatibility version 7
  - Available features:
    - Key-Value store
    - Accessory setup manager
    - Service discovery
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:AccessoryServer] Storage configuration: server = 1728
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: ipAccessoryServerStorage = 32
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: numSessions = 17
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: sessions = 14552
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: sessions[0...16].inboundBuffer.numBytes = 32768
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: sessions[0...16].outboundBuffer.numBytes = 32768
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: sessions[0...16].numEventNotifications = 21
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: sessions[0...16].eventNotifications = 504
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: numReadContexts = 21
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: readContexts = 1008
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: numWriteContexts = 21
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: writeContexts = 1344
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Storage configuration: scratchBuffer.numBytes = 32768
2021-06-14'T'11:38:03'Z'    Info    AppCreate
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:AccessoryServer] Checking accessory definition. If this crashes, verify that service and characteristic lists are properly NULL-terminated.
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:AccessoryServer] Accessory definition ok.
2021-06-14'T'11:38:03'Z'    Info    [com.apple.mfi.HomeKit.Core:AccessoryServer] Accessory server starting.
2021-06-14'T'11:38:03'Z'    Info    [com.apple.mfi.HomeKit.Core:AccessoryServer] Firmware version: 3.0.0
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:AccessoryServer] Registering accessories.
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:AccessoryServer] Loading accessory identity.
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:AccessoryServer] Checking if admin pairing exists.
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:AccessorySetupInfo] HAPAccessorySetupInfoHandleAccessoryServerStart
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Starting server engine.
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:TCPStreamManager] setsockopt(5, SOL_SOCKET, SO_REUSEADDR, <buffer>);
    0000  01000000                                                                   ....
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:TCPStreamManager] TCP stream listener interface index: 0
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:TCPStreamManager] bind(5, <buffer>);
    0000  0a000000 00000000 00000000 00000000 00000000 00000000 00000000             ............................
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:TCPStreamManager] TCP stream listener port: 44889.
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:TCPStreamManager] listen(5, 64);
2021-06-14'T'11:38:03'Z'    Info    [com.apple.mfi.HomeKit.Core:IPServiceDiscovery] Registering _hap._tcp service.
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] interfaceIndex: 0
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] name: "Acme Light Bulb"
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] protocol: "_hap._tcp"
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] port: 44889
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[0]: "c#"
    0000  32                                                                         2
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[1]: "ff"
    0000  30                                                                         0
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[2]: "id"
    0000  43433a46 353a3734 3a31383a 34323a42 41                                     CC:F5:74:18:42:BA
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[3]: "md"
    0000  4c696768 7442756c 62332c32                                                 LightBulb3,2
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[4]: "pv"
    0000  312e31                                                                     1.1
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[5]: "s#"
    0000  31                                                                         1
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[6]: "sf"
    0000  31                                                                         1
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[7]: "ci"
    0000  35                                                                         5
2021-06-14'T'11:38:03'Z'    Debug   [com.apple.mfi.HomeKit.Platform:ServiceDiscovery] txtRecord[8]: "sh"
    0000  6348594b 64413d3d                                                          cHYKdA==
2021-06-14'T'11:38:03'Z'    Info    [com.apple.mfi.HomeKit.Platform:RunLoop] Entering run loop.
2021-06-14'T'11:38:03'Z'    Default [com.apple.mfi.HomeKit.Platform:Clock] Using 'clock_gettime' with 'CLOCK_MONOTONIC_RAW'.
2021-06-14'T'11:38:03'Z'    Info    Accessory Server State did update: Running.

The example "Lightbulb" is normal.

Component: