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

Function connectEvent

modules/network/ble/nimble/modBLEClient.c:890–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

888}
889
890static void connectEvent(void *the, void *refcon, uint8_t *message, uint16_t messageLength)
891{
892 struct ble_gap_conn_desc *desc = (struct ble_gap_conn_desc *)message;
893
894 if (!gBLE || gBLE->the != the)
895 return;
896 modBLE ble = gBLE;
897 xsBeginHost(the);
898 modBLEConnection connection = modBLEConnectionFindByAddressAndType(desc->peer_id_addr.val, desc->peer_id_addr.type);
899 if (!connection) {
900 // @@ workaround for https://github.com/espressif/esp-idf/issues/5693
901 connection = modBLEConnectionGetFirst();
902 while (NULL != connection) {
903 if (kInvalidConnectionID == connection->id)
904 break;
905 connection = modBLEConnectionGetNext(connection);
906 }
907 if (!connection)
908 xsUnknownError("connection not found");
909 }
910
911 if (0xFFFF != desc->conn_handle) {
912 if (kInvalidConnectionID != connection->id) {
913 LOG_GAP_MSG("Ignoring duplicate connect event");
914 goto bail;
915 }
916 connection->id = desc->conn_handle;
917 onConnected(desc);
918 }
919 else {
920 LOG_GAP_MSG("BLE_GAP_EVENT_CONNECT failed");
921 xsForget(connection->objConnection);
922 modBLEConnectionRemove(connection);
923 }
924bail:
925 xsEndHost(ble->the);
926 downBLEClientUseCount(ble);
927}
928
929static void disconnectEvent(void *the, void *refcon, uint8_t *message, uint16_t messageLength)
930{

Callers

nothing calls this directly

Calls 6

modBLEConnectionGetFirstFunction · 0.85
modBLEConnectionGetNextFunction · 0.85
onConnectedFunction · 0.85
modBLEConnectionRemoveFunction · 0.85
downBLEClientUseCountFunction · 0.85

Tested by

no test coverage detected