| 836 | } |
| 837 | |
| 838 | static void connectEvent(void *the, void *refcon, uint8_t *message, uint16_t messageLength) |
| 839 | { |
| 840 | qapi_BLE_GATT_Device_Connection_Data_t *result = (qapi_BLE_GATT_Device_Connection_Data_t*)message; |
| 841 | xsBeginHost(gBLE->the); |
| 842 | modBLEConnection connection = modBLEConnectionFindByAddress((uint8_t*)&result->RemoteDevice); |
| 843 | if (!connection) |
| 844 | xsUnknownError("connection not found"); |
| 845 | |
| 846 | // Ignore duplicate connection events |
| 847 | if (kInvalidConnectionID != connection->id) |
| 848 | goto bail; |
| 849 | |
| 850 | connection->id = result->ConnectionID; |
| 851 | xsmcVars(2); |
| 852 | xsVar(0) = xsmcNewObject(); |
| 853 | xsmcSetInteger(xsVar(1), connection->id); |
| 854 | xsmcSet(xsVar(0), xsID_connection, xsVar(1)); |
| 855 | xsmcSetArrayBuffer(xsVar(1), &result->RemoteDevice, 6); |
| 856 | xsmcSet(xsVar(0), xsID_address, xsVar(1)); |
| 857 | xsmcSetInteger(xsVar(1), connection->addressType); |
| 858 | xsmcSet(xsVar(0), xsID_addressType, xsVar(1)); |
| 859 | xsCall2(gBLE->obj, xsID_callback, xsString("onConnected"), xsVar(0)); |
| 860 | bail: |
| 861 | xsEndHost(gBLE->the); |
| 862 | } |
| 863 | |
| 864 | static void disconnectEvent(void *the, void *refcon, uint8_t *message, uint16_t messageLength) |
| 865 | { |
nothing calls this directly
no test coverage detected