MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / connectEvent

Function connectEvent

modules/network/ble/qca4020/modBLEClient.c:838–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

836}
837
838static 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));
860bail:
861 xsEndHost(gBLE->the);
862}
863
864static void disconnectEvent(void *the, void *refcon, uint8_t *message, uint16_t messageLength)
865{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected