[-]
[+]
|
Changed |
_service:tar_git:nfcd-binder-plugin.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:nfcd-binder-plugin.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -7,7 +7,7 @@
<service name="tar_git">
<param name="url">https://github.com/sailfishos-oneplus5/nfcd-binder-plugin.git</param>
<param name="branch">master</param>
- <param name="revision"/>
+ <param name="revision">6fc9ed84da679726cd47b11a326dbffe4edab843</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/Makefile
^
|
@@ -1,180 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-.PHONY: clean all debug release
-.PHONY: print_debug_lib print_release_lib
-.PHONY: print_debug_path print_release_path
-
-#
-# Required packages
-#
-
-PKGS = libglibutil glib-2.0 gobject-2.0
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Library name
-#
-
-NAME = nci
-LIB_NAME = lib$(NAME)
-LIB = $(LIB_NAME).a
-
-#
-# Sources
-#
-
-SRC = \
- nci_core.c \
- nci_param.c \
- nci_param_w4_all_discoveries.c \
- nci_param_w4_host_select.c \
- nci_sar.c \
- nci_sm.c \
- nci_state.c \
- nci_state_discovery.c \
- nci_state_poll_active.c \
- nci_state_w4_all_discoveries.c \
- nci_state_w4_host_select.c \
- nci_transition.c \
- nci_transition_deactivate_to_idle.c \
- nci_transition_idle_to_discovery.c \
- nci_transition_poll_active_to_discovery.c \
- nci_transition_poll_active_to_idle.c \
- nci_transition_reset.c \
- nci_util.c
-
-#
-# Directories
-#
-
-SRC_DIR = src
-INCLUDE_DIR = include
-BUILD_DIR = build
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-COVERAGE_BUILD_DIR = $(BUILD_DIR)/coverage
-
-#
-# Tools and flags
-#
-
-CC = $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS = -Wall -Wstrict-aliasing -Wunused-result
-INCLUDES = -I$(INCLUDE_DIR)
-BASE_FLAGS = -fPIC
-FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) \
- -MMD -MP $(shell pkg-config --cflags $(PKGS))
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-COVERAGE_FLAGS = -g
-
-ifndef KEEP_SYMBOLS
-KEEP_SYMBOLS = 0
-endif
-
-ifneq ($(KEEP_SYMBOLS),0)
-RELEASE_FLAGS += -g
-endif
-
-DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
-COVERAGE_CFLAGS = $(FULL_CFLAGS) $(COVERAGE_FLAGS) --coverage
-
-#
-# Files
-#
-
-DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-COVERAGE_OBJS = $(SRC:%.c=$(COVERAGE_BUILD_DIR)/%.o)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_OBJS) $(DEBUG_LIB): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS) $(RELEASE_LIB): | $(RELEASE_BUILD_DIR)
-$(COVERAGE_OBJS) $(COVERAGE_LIB): | $(COVERAGE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
-RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
-COVERAGE_LIB = $(COVERAGE_BUILD_DIR)/$(LIB)
-
-debug: $(DEBUG_LIB)
-
-release: $(RELEASE_LIB)
-
-debug_lib: $(DEBUG_LIB)
-
-release_lib: $(RELEASE_LIB)
-
-coverage_lib: $(COVERAGE_LIB)
-
-print_debug_lib:
- @echo $(DEBUG_LIB)
-
-print_release_lib:
- @echo $(RELEASE_LIB)
-
-print_coverage_lib:
- @echo $(COVERAGE_LIB)
-
-print_debug_path:
- @echo $(DEBUG_BUILD_DIR)
-
-print_release_path:
- @echo $(RELEASE_BUILD_DIR)
-
-clean:
- rm -f *~ $(SRC_DIR)/*~ $(INCLUDE_DIR)/*~ $(INCLUDE_DIR)/internal/*~
- rm -fr $(BUILD_DIR)
-
-$(BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(COVERAGE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(COVERAGE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_LIB): $(DEBUG_OBJS)
- $(AR) rc $@ $?
- ranlib $@
-
-$(RELEASE_LIB): $(RELEASE_OBJS)
- $(AR) rc $@ $?
- ranlib $@
-
-$(COVERAGE_LIB): $(COVERAGE_OBJS)
- $(AR) rc $@ $?
- ranlib $@
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/include/nci_core.h
^
|
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_CORE_H
-#define NCI_CORE_H
-
-#include <nci_types.h>
-
-G_BEGIN_DECLS
-
-/*
- * If current_state != next_state, the state machine is transitioning
- * from one state to another. That may take a while.
- */
-
-typedef struct nci_core {
- NCI_STATE current_state;
- NCI_STATE next_state;
- guint cmd_timeout;
-} NciCore;
-
-typedef
-void
-(*NciCoreFunc)(
- NciCore* nci,
- void* user_data);
-
-typedef
-void
-(*NciCoreSendFunc)(
- NciCore* nci,
- gboolean success,
- void* user_data);
-
-typedef
-void
-(*NciCoreDataPacketFunc)(
- NciCore* nci,
- guint8 cid,
- const void* payload,
- guint len,
- void* user_data);
-
-typedef
-void
-(*NciCoreIntfActivationFunc)(
- NciCore* nci,
- const NciIntfActivationNtf* ntf,
- void* user_data);
-
-NciCore*
-nci_core_new(
- NciHalIo* io);
-
-void
-nci_core_free(
- NciCore* nci);
-
-void
-nci_core_restart(
- NciCore* nci);
-
-void
-nci_core_set_state(
- NciCore* nci,
- NCI_STATE state);
-
-guint
-nci_core_send_data_msg(
- NciCore* nci,
- guint8 cid,
- GBytes* payload,
- NciCoreSendFunc complete,
- GDestroyNotify destroy,
- void* user_data);
-
-void
-nci_core_cancel(
- NciCore* nci,
- guint id);
-
-gulong
-nci_core_add_current_state_changed_handler(
- NciCore* nci,
- NciCoreFunc func,
- void* user_data);
-
-gulong
-nci_core_add_next_state_changed_handler(
- NciCore* nci,
- NciCoreFunc func,
- void* user_data);
-
-gulong
-nci_core_add_intf_activated_handler(
- NciCore* nci,
- NciCoreIntfActivationFunc func,
- void* user_data);
-
-gulong
-nci_core_add_data_packet_handler(
- NciCore* nci,
- NciCoreDataPacketFunc func,
- void* user_data);
-
-void
-nci_core_remove_handler(
- NciCore* nci,
- gulong id);
-
-void
-nci_core_remove_handlers(
- NciCore* nci,
- gulong* ids,
- guint count);
-
-#define nci_core_remove_all_handlers(core,ids) \
- nci_core_remove_handlers(core, ids, G_N_ELEMENTS(ids))
-
-G_END_DECLS
-
-#endif /* NCI_CORE_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/include/nci_hal.h
^
|
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_HAL_H
-#define NCI_HAL_H
-
-#include <nci_types.h>
-
-/* Hardware abstraction layer */
-
-/* Functions provided by HAL implementation */
-
-typedef
-void
-(*NciHalClientFunc)(
- NciHalClient* client,
- gboolean ok);
-
-typedef struct nci_hal_io_functions {
- gboolean (*start)(NciHalIo* io, NciHalClient* client);
- void (*stop)(NciHalIo* io); /* implicitely cancels write */
- gboolean (*write)(NciHalIo* io, const GUtilData* chunks, guint count,
- NciHalClientFunc complete);
- void (*cancel_write)(NciHalIo* io);
-} NciHalIoFunctions;
-
-struct nci_hal_io {
- const NciHalIoFunctions* fn;
-};
-
-/* Functions provided by NCI core */
-
-typedef struct nci_hal_client_functions {
- void (*error)(NciHalClient* client);
- void (*read)(NciHalClient* client, const void* data, guint len);
-} NciHalClientFunctions;
-
-struct nci_hal_client {
- const NciHalClientFunctions* fn;
-};
-
-#endif /* NFC_HAL_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/include/nci_state.h
^
|
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_STATE_H
-#define NCI_STATE_H
-
-#include "nci_types.h"
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef struct nci_state_priv NciStatePriv;
-
-struct nci_state {
- GObject object;
- NciStatePriv* priv;
- NCI_STATE state;
- const char* name;
- gboolean active;
-};
-
-GType nci_state_get_type(void);
-#define NCI_TYPE_STATE (nci_state_get_type())
-#define NCI_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- NCI_TYPE_STATE, NciState))
-
-NciState*
-nci_state_ref(
- NciState* state);
-
-void
-nci_state_unref(
- NciState* state);
-
-G_END_DECLS
-
-#endif /* NCI_STATE_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/include/nci_types.h
^
|
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_TYPES_H
-#define NCI_TYPES_H
-
-#include <gutil_types.h>
-
-G_BEGIN_DECLS
-
-/* Types */
-
-typedef struct nci_core NciCore;
-typedef struct nci_hal_client NciHalClient;
-typedef struct nci_hal_io NciHalIo;
-typedef struct nci_state NciState;
-
-/* Table 4: Conn ID
- * 0: Static RF Connection between the DH and a Remote NFC Endpoint */
-#define NCI_STATIC_RF_CONN_ID (0x00)
-
-/* Table 94: Status Codes */
-typedef enum nci_status {
- NCI_STATUS_OK = 0x00,
- NCI_STATUS_REJECTED = 0x01,
- NCI_STATUS_RF_FRAME_CORRUPTED = 0x02,
- NCI_STATUS_FAILED = 0x03,
- NCI_STATUS_NOT_INITIALIZED = 0x04,
- NCI_STATUS_SYNTAX_ERROR = 0x05,
- NCI_STATUS_SEMANTIC_ERROR = 0x06,
- NCI_STATUS_INVALID_PARAM = 0x09,
- NCI_STATUS_MESSAGE_SIZE_EXCEEDED = 0x0A,
- NCI_STATUS_DISCOVERY_ALREADY_STARTED = 0xA0,
- NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED = 0xA1,
- NCI_STATUS_DISCOVERY_TEAR_DOWN = 0xA2,
- NCI_STATUS_RF_TRANSMISSION_ERROR = 0xB0,
- NCI_STATUS_RF_PROTOCOL_ERROR = 0xB1,
- NCI_STATUS_RF_TIMEOUT_ERROR = 0xB2,
- NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED = 0xC0,
- NCI_STATUS_NFCEE_TRANSMISSION_ERROR = 0xC1,
- NCI_STATUS_NFCEE_PROTOCOL_ERROR = 0xC2,
- NCI_STATUS_NFCEE_TIMEOUT_ERROR = 0xC3
-} NCI_STATUS;
-
-/* Table 96: RF Technology and Mode */
-typedef enum nci_mode {
- NCI_MODE_PASSIVE_POLL_A = 0x00,
- NCI_MODE_PASSIVE_POLL_B = 0x01,
- NCI_MODE_PASSIVE_POLL_F = 0x02,
- NCI_MODE_ACTIVE_POLL_A = 0x03,
- NCI_MODE_ACTIVE_POLL_F = 0x05,
- NCI_MODE_PASSIVE_POLL_15693 = 0x06,
- NCI_MODE_PASSIVE_LISTEN_A = 0x80,
- NCI_MODE_PASSIVE_LISTEN_B = 0x81,
- NCI_MODE_PASSIVE_LISTEN_F = 0x82,
- NCI_MODE_ACTIVE_LISTEN_A = 0x83,
- NCI_MODE_ACTIVE_LISTEN_F = 0x85,
- NCI_MODE_PASSIVE_LISTEN_15693 = 0x86
-} NCI_MODE;
-
-/* Table 97: Bit Rates */
-typedef enum nci_bit_rate {
- NFC_BIT_RATE_106 = 0x00, /* 106 Kbit/s */
- NFC_BIT_RATE_212 = 0x01, /* 212 Kbit/s */
- NFC_BIT_RATE_424 = 0x02, /* 424 Kbit/s */
- NFC_BIT_RATE_848 = 0x03, /* 848 Kbit/s */
- NFC_BIT_RATE_1695 = 0x04, /* 1695 Kbit/s */
- NFC_BIT_RATE_3390 = 0x05, /* 3390 Kbit/s */
- NFC_BIT_RATE_6780 = 0x06 /* 6780 Kbit/s */
-} NFC_BIT_RATE;
-
-/* Table 98: RF Protocols */
-typedef enum nci_protocol {
- NCI_PROTOCOL_UNDETERMINED = 0x00,
- NCI_PROTOCOL_T1T = 0x01,
- NCI_PROTOCOL_T2T = 0x02,
- NCI_PROTOCOL_T3T = 0x03,
- NCI_PROTOCOL_ISO_DEP = 0x04,
- NCI_PROTOCOL_NFC_DEP = 0x05,
-} NCI_PROTOCOL;
-
-/* Table 99: RF Interfaces */
-typedef enum nci_rf_interface {
- NCI_RF_INTERFACE_NFCEE_DIRECT = 0x00,
- NCI_RF_INTERFACE_FRAME = 0x01,
- NCI_RF_INTERFACE_ISO_DEP = 0x02,
- NCI_RF_INTERFACE_NFC_DEP = 0x03
-} NCI_RF_INTERFACE;
-
-/* See Table 54: Specific Parameters for NFC-A Poll Mode */
-typedef struct nci_mode_param_poll_a {
- guint8 sens_res[2];
- guint8 nfcid1_len;
- guint8 nfcid1[10];
- guint8 sel_res_len;
- guint8 sel_res;
-} NciModeParamPollA;
-
-/* Table 56: Specific Parameters for NFC-B Poll Mode */
-typedef struct nci_mode_param_poll_b {
- guint8 nfcid0[4];
- guint fsc; /* FSCI converted to bytes */
-} NciModeParamPollB;
-
-typedef union nci_mode_param {
- NciModeParamPollA poll_a;
- NciModeParamPollB poll_b;
-} NciModeParam;
-
-/* Table 76: Activation Parameters for NFC-A/ISO-DEP Poll Mode */
-typedef struct nci_activation_param_iso_dep_poll_a {
- guint fsc; /* FSC (FSCI converted to bytes) */
- GUtilData t1; /* T1 to Tk (otherwise called historical bytes) */
-} NciActivationParamIsoDepPollA;
-
-typedef union nci_activation_param {
- NciActivationParamIsoDepPollA iso_dep_poll_a;
-} NciActivationParam;
-
-/* See Table 61: Notification for RF Interface activation */
-typedef struct nci_intf_activated_ntf {
- guint8 discovery_id;
- NCI_RF_INTERFACE rf_intf;
- NCI_PROTOCOL protocol;
- NCI_MODE mode;
- guint8 max_data_packet_size;
- guint8 num_credits;
- guint8 mode_param_len;
- const void* mode_param_bytes;
- const NciModeParam* mode_param;
- NCI_MODE data_exchange_mode;
- NFC_BIT_RATE transmit_rate;
- NFC_BIT_RATE receive_rate;
- guint8 activation_param_len;
- const void* activation_param_bytes;
- const NciActivationParam* activation_param;
-} NciIntfActivationNtf;
-
-/* Table 52: Control Messages to Start Discovery */
-typedef struct nci_discovery_ntf {
- guint8 discovery_id;
- NCI_PROTOCOL protocol;
- NCI_MODE mode;
- guint8 param_len;
- const void* param_bytes;
- const NciModeParam* param;
- gboolean last;
-} NciDiscoveryNtf;
-
-/* NCI states */
-
-typedef enum nci_state_id {
- NCI_STATE_INIT,
- NCI_STATE_ERROR,
- NCI_STATE_STOP,
- /* RFST states are taken from the NCI spec */
- NCI_RFST_IDLE,
- NCI_RFST_DISCOVERY,
- NCI_RFST_W4_ALL_DISCOVERIES,
- NCI_RFST_W4_HOST_SELECT,
- NCI_RFST_POLL_ACTIVE,
- NCI_RFST_LISTEN_ACTIVE,
- NCI_RFST_LISTEN_SLEEP,
- NCI_CORE_STATES
-} NCI_STATE;
-
-/* Logging */
-
-#define NCI_LOG_MODULE nci_log
-extern GLogModule NCI_LOG_MODULE;
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_core.c
^
|
@@ -1,739 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_core.h"
-#include "nci_sar.h"
-#include "nci_sm.h"
-#include "nci_state.h"
-#include "nci_log.h"
-
-#include <gutil_misc.h>
-#include <gutil_macros.h>
-
-#include <glib-object.h>
-
-GLOG_MODULE_DEFINE("nci");
-
-typedef struct nci_core_closure {
- GCClosure cclosure;
- NciCoreFunc func;
- gpointer* user_data;
-} NciCoreClosure;
-
-typedef struct nci_core_intf_activated_closure {
- GCClosure cclosure;
- NciCoreIntfActivationFunc func;
- gpointer* user_data;
-} NciCoreIntfActivationClosure;
-
-typedef struct nci_core_data_packet_closure {
- GCClosure cclosure;
- NciCoreDataPacketFunc func;
- gpointer* user_data;
-} NciCoreDataPacketClosure;
-
-typedef struct nci_core_send_data {
- NciCoreSendFunc complete;
- GDestroyNotify destroy;
- gpointer user_data;
-} NciCoreSendData;
-
-enum nci_core_events {
- EVENT_LAST_STATE,
- EVENT_NEXT_STATE,
- EVENT_INTF_ACTIVATED,
- EVENT_COUNT
-};
-
-typedef struct nci_core_object {
- GObject object;
- NciCore core;
- NciSarClient sar_client;
- NciSmIo io;
- NciSm* sm;
- guint cmd_id;
- guint cmd_timeout_id;
- guint8 rsp_gid;
- guint8 rsp_oid;
- NciSmResponseFunc rsp_handler;
- gpointer rsp_data;
- gulong event_ids[EVENT_COUNT];
-} NciCoreObject;
-
-typedef GObjectClass NciCoreObjectClass;
-G_DEFINE_TYPE(NciCoreObject, nci_core_object, G_TYPE_OBJECT)
-#define NCI_TYPE_CORE (nci_core_object_get_type())
-#define NCI_CORE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- NCI_TYPE_CORE, NciCoreObject))
-
-typedef enum nci_core_signal {
- SIGNAL_CURRENT_STATE,
- SIGNAL_NEXT_STATE,
- SIGNAL_INTF_ACTIVATED,
- SIGNAL_DATA_PACKET,
- SIGNAL_COUNT
-} NCI_CORE_SIGNAL;
-
-#define SIGNAL_CURRENT_STATE_NAME "nci-core-current-state"
-#define SIGNAL_NEXT_STATE_NAME "nci-core-next-state"
-#define SIGNAL_INTF_ACTIVATED_NAME "nci-core-intf-activated"
-#define SIGNAL_DATA_PACKET_NAME "nci-core-data-packet"
-
-static guint nci_core_signals[SIGNAL_COUNT] = { 0 };
-
-#define DEFAULT_TIMEOUT (2000) /* msec */
-
-static inline NciCoreObject* nci_core_object(NciCore* ptr)
-{ return G_LIKELY(ptr) ? /* This one should be NULL safe */
- NCI_CORE(G_CAST(ptr, NciCoreObject, core)) : NULL; }
-
-static inline NciCoreObject* nci_core_object_from_sar_client(NciSarClient* ptr)
- { return NCI_CORE(G_CAST(ptr, NciCoreObject, sar_client)); }
-
-static inline NciCoreObject* nci_core_object_from_sm_io(NciSmIo* ptr)
- { return NCI_CORE(G_CAST(ptr, NciCoreObject, io)); }
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_core_cancel_command(
- NciCoreObject* self)
-{
- if (self->cmd_id) {
- gpointer user_data = self->rsp_data;
-
- nci_sar_cancel(self->io.sar, self->cmd_id);
- self->cmd_id = 0;
- self->rsp_data = NULL;
- if (self->cmd_timeout_id) {
- g_source_remove(self->cmd_timeout_id);
- self->cmd_timeout_id = 0;
- }
- if (self->rsp_handler) {
- NciSmResponseFunc handler = self->rsp_handler;
- GUtilData payload;
-
- self->rsp_handler = NULL;
- memset(&payload, 0, sizeof(payload));
- handler(NCI_REQUEST_CANCELLED, &payload, user_data);
- }
- }
-}
-
-static
-void
-nci_core_command_completion(
- NciSarClient* sar_client,
- gboolean success,
- gpointer user_data)
-{
- if (!success) {
- NciCoreObject* self = NCI_CORE(user_data);
-
- GWARN("Failed to send command %02x/%02x", self->rsp_gid, self->rsp_oid);
- nci_sm_stall(self->sm, NCI_STALL_ERROR);
- }
-}
-
-static
-void
-nci_core_io_dummy_resp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- gpointer user_data)
-{
- if (status != NCI_REQUEST_SUCCESS) {
- GWARN("Command %02x/%02x failed", NCI_CORE(user_data)->rsp_gid,
- NCI_CORE(user_data)->rsp_oid);
- }
-}
-
-static
-gboolean
-nci_core_command_timeout(
- gpointer user_data)
-{
- NciCoreObject* self = NCI_CORE(user_data);
- gpointer rsp_data = self->rsp_data;
-
- GWARN("Command %02x/%02x timed out", self->rsp_gid, self->rsp_oid);
- self->cmd_timeout_id = 0;
- self->rsp_data = NULL;
- nci_sar_cancel(self->io.sar, self->cmd_id);
- self->cmd_id = 0;
- if (self->rsp_handler) {
- NciSmResponseFunc handler = self->rsp_handler;
- GUtilData payload;
-
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_log.h
^
|
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_LOG_H
-#define NCI_LOG_H
-
-#include <nci_types.h>
-
-#define GLOG_MODULE_NAME NCI_LOG_MODULE
-#include <gutil_log.h>
-
-#endif /* NCI_LOG_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_param.c
^
|
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_param_impl.h"
-
-G_DEFINE_ABSTRACT_TYPE(NciParam, nci_param, G_TYPE_OBJECT)
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciParam*
-nci_param_ref(
- NciParam* self)
-{
- if (G_LIKELY(self)) {
- g_object_ref(NCI_PARAM(self));
- }
- return self;
-}
-
-void
-nci_param_unref(
- NciParam* self)
-{
- if (G_LIKELY(self)) {
- g_object_unref(NCI_PARAM(self));
- }
-}
-
-/*==========================================================================*
- * Internals
- *==========================================================================*/
-
-static
-void
-nci_param_init(
- NciParam* self)
-{
-}
-
-static
-void
-nci_param_class_init(
- NciParamClass* klass)
-{
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_param.h
^
|
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_PARAM_H
-#define NCI_PARAM_H
-
-#include "nci_types_p.h"
-
-#include <glib-object.h>
-
-struct nci_param {
- GObject object;
-};
-
-GType nci_param_get_type(void);
-#define NCI_TYPE_PARAM nci_param_get_type()
-#define NCI_IS_PARAM(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), NCI_TYPE_PARAM)
-#define NCI_PARAM(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), NCI_TYPE_PARAM, \
- NciParam)
-
-NciParam*
-nci_param_ref(
- NciParam* param);
-
-void
-nci_param_unref(
- NciParam* param);
-
-#endif /* NCI_PARAM_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_param_impl.h
^
|
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_PARAM_IMPL_H
-#define NCI_PARAM_IMPL_H
-
-#include "nci_param.h"
-
-typedef struct nci_param_class {
- GObjectClass parent;
-} NciParamClass;
-
-#endif /* NCI_PARAM_IMPL_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_param_w4_all_discoveries.c
^
|
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_param_w4_all_discoveries.h"
-#include "nci_param_impl.h"
-#include "nci_util.h"
-
-typedef NciParamClass NciParamW4AllDiscoveriesClass;
-G_DEFINE_TYPE(NciParamW4AllDiscoveries, nci_param_w4_all_discoveries,
- NCI_TYPE_PARAM)
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciParamW4AllDiscoveries*
-nci_param_w4_all_discoveries_new(
- const NciDiscoveryNtf* ntf)
-{
- if (ntf) {
- NciParamW4AllDiscoveries* self =
- g_object_new(NCI_TYPE_PARAM_W4_ALL_DISCOVERIES, NULL);
-
- self->ntf = nci_discovery_ntf_copy(ntf);
- return self;
- }
- return NULL;
-}
-
-/*==========================================================================*
- * Internals
- *==========================================================================*/
-
-static
-void
-nci_param_w4_all_discoveries_init(
- NciParamW4AllDiscoveries* self)
-{
-}
-
-static
-void
-nci_param_w4_all_discoveries_finalize(
- GObject* obj)
-{
- NciParamW4AllDiscoveries* self = NCI_PARAM_W4_ALL_DISCOVERIES(obj);
-
- g_free(self->ntf);
- G_OBJECT_CLASS(nci_param_w4_all_discoveries_parent_class)->finalize(obj);
-}
-
-static
-void
-nci_param_w4_all_discoveries_class_init(
- NciParamClass* klass)
-{
- G_OBJECT_CLASS(klass)->finalize = nci_param_w4_all_discoveries_finalize;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_param_w4_all_discoveries.h
^
|
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_PARAM_W4_ALL_DISCOVERIES_H
-#define NCI_PARAM_W4_ALL_DISCOVERIES_H
-
-#include "nci_param.h"
-
-typedef struct nci_param_w4_all_discoveries {
- NciParam param;
- NciDiscoveryNtf* ntf;
-} NciParamW4AllDiscoveries;
-
-GType nci_param_w4_all_discoveries_get_type(void);
-#define NCI_TYPE_PARAM_W4_ALL_DISCOVERIES \
- nci_param_w4_all_discoveries_get_type()
-#define NCI_IS_PARAM_W4_ALL_DISCOVERIES(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj),\
- NCI_TYPE_PARAM_W4_ALL_DISCOVERIES)
-#define NCI_PARAM_W4_ALL_DISCOVERIES(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), \
- NCI_TYPE_PARAM_W4_ALL_DISCOVERIES, NciParamW4AllDiscoveries)
-
-NciParamW4AllDiscoveries*
-nci_param_w4_all_discoveries_new(
- const NciDiscoveryNtf* ntf);
-
-#endif /* NCI_PARAM_W4_ALL_DISCOVERIES_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_param_w4_host_select.c
^
|
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_param_w4_host_select.h"
-#include "nci_param_impl.h"
-#include "nci_util.h"
-
-typedef NciParamClass NciParamW4HostSelectClass;
-G_DEFINE_TYPE(NciParamW4HostSelect, nci_param_w4_host_select, NCI_TYPE_PARAM)
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciParamW4HostSelect*
-nci_param_w4_host_select_new(
- const NciDiscoveryNtf* const* ntf,
- guint count)
-{
- NciParamW4HostSelect* self =
- g_object_new(NCI_TYPE_PARAM_W4_HOST_SELECT, NULL);
-
- self->ntf = nci_discovery_ntf_copy_array(ntf, count);
- self->count = count;
- return self;
-}
-
-/*==========================================================================*
- * Internals
- *==========================================================================*/
-
-static
-void
-nci_param_w4_host_select_init(
- NciParamW4HostSelect* self)
-{
-}
-
-static
-void
-nci_param_w4_host_select_finalize(
- GObject* obj)
-{
- NciParamW4HostSelect* self = NCI_PARAM_W4_HOST_SELECT(obj);
-
- g_free(self->ntf);
- G_OBJECT_CLASS(nci_param_w4_host_select_parent_class)->finalize(obj);
-}
-
-static
-void
-nci_param_w4_host_select_class_init(
- NciParamClass* klass)
-{
- G_OBJECT_CLASS(klass)->finalize = nci_param_w4_host_select_finalize;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_param_w4_host_select.h
^
|
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_PARAM_W4_HOST_SELECT_H
-#define NCI_PARAM_W4_HOST_SELECT_H
-
-#include "nci_param.h"
-
-typedef struct nci_param_w4_host_select {
- NciParam param;
- NciDiscoveryNtf* ntf;
- guint count;
-} NciParamW4HostSelect;
-
-GType nci_param_w4_host_select_get_type(void);
-#define NCI_TYPE_PARAM_W4_HOST_SELECT \
- nci_param_w4_host_select_get_type()
-#define NCI_IS_PARAM_W4_HOST_SELECT(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj),\
- NCI_TYPE_PARAM_W4_HOST_SELECT)
-#define NCI_PARAM_W4_HOST_SELECT(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), \
- NCI_TYPE_PARAM_W4_HOST_SELECT, NciParamW4HostSelect)
-
-NciParamW4HostSelect*
-nci_param_w4_host_select_new(
- const NciDiscoveryNtf* const* ntfs,
- guint count);
-
-#endif /* NCI_PARAM_W4_HOST_SELECT_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_sar.c
^
|
@@ -1,905 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_sar.h"
-#include "nci_hal.h"
-#include "nci_log.h"
-
-#include <gutil_macros.h>
-
-/* SAR (Segmentation and Reassembly) */
-
-#define SAR_DEFAULT_MAX_LOGICAL_CONNECTIONS (1)
-#define SAR_DEFAULT_CONTROL_MTU (0x20)
-#define SAR_DEFAULT_DATA_MTU (0xff)
-#define SAR_MIN_MTU (0x04)
-#define SAR_UNLIMITED_CREDITS (0xff)
-
-#define NCI_HDR_SIZE (3)
-
-typedef struct nci_sar_packet_out NciSarPacketOut;
-
-struct nci_sar_packet_out {
- NciSarPacketOut* next;
- guint8 hdr[NCI_HDR_SIZE];
- GBytes* payload;
- guint payload_pos;
- NciSarCompletionFunc complete;
- GDestroyNotify destroy;
- gpointer user_data;
- guint id;
-};
-
-typedef struct nci_sar_packet_out_queue {
- NciSarPacketOut* first;
- NciSarPacketOut* last;
-} NciSarPacketOutQueue;
-
-typedef struct nci_sar_logical_connection {
- guint8 credits;
- GByteArray* in;
- NciSarPacketOutQueue out;
-} NciSarLogicalConnection;
-
-struct nci_sar {
- NciHalIo* io;
- NciSarClient* client;
- NciHalClient hal_client;
- gboolean started;
- guint8 max_logical_conns;
- guint8 control_mtu;
- guint8 data_mtu;
- guint last_packet_id;
- guint start_write_id;
- gboolean write_pending;
- NciSarPacketOut* writing;
- NciSarPacketOutQueue cmd;
- NciSarLogicalConnection* conn;
- GByteArray* control_in;
- GByteArray* read_buf;
-};
-
-/* Control packets */
-
-#define NCI_CONTROL_GID_MASK (0x0f) /* First octet */
-#define NCI_CONTROL_OID_MASK (0x3f) /* Second octet */
-
-/* Data packets */
-#define NCI_DATA_CID_MASK (0x0f)
-
-static
-void
-nci_sar_schedule_write(
- NciSar* self);
-
-static
-void
-nci_sar_attempt_write(
- NciSar* self);
-
-static
-NciSar*
-nci_sar_from_hal_client(
- NciHalClient* hal_client)
-{
- return G_CAST(hal_client, NciSar, hal_client);
-}
-
-static
-void
-nci_sar_packet_out_free(
- NciSarPacketOut* out)
-{
- /* Caller makes sure that argument is not NULL */
- if (out->payload) {
- g_bytes_unref(out->payload);
- }
- if (out->destroy) {
- out->destroy(out->user_data);
- }
- g_slice_free(NciSarPacketOut, out);
-}
-
-static
-void
-nci_sar_write_completed(
- NciHalClient* client,
- gboolean ok)
-{
- NciSar* self = nci_sar_from_hal_client(client);
- NciSarPacketOut* out = self->writing;
-
- GASSERT(out);
- GASSERT(self->write_pending);
- self->write_pending = FALSE;
- if (ok) {
- gsize payload_len = out->payload ? g_bytes_get_size(out->payload) : 0;
-
- GASSERT(payload_len >= out->payload_pos);
- if (payload_len == out->payload_pos) {
- /* Done with this packet */
- self->writing = NULL;
- if (out->complete) {
- out->complete(self->client, TRUE, out->user_data);
- }
- nci_sar_packet_out_free(out);
- }
-
- /* And try to write the next segment or packet */
- nci_sar_attempt_write(self);
- } else {
- NciSarClient* client = self->client;
-
- /* Drop this packet and indicate an error */
- self->writing = NULL;
- if (out->complete) {
- out->complete(self->client, FALSE, out->user_data);
- }
- nci_sar_packet_out_free(out);
- client->fn->error(client);
- }
-}
-
-static
-NciSarPacketOutQueue*
-nci_sar_write_queue(
- NciSar* self,
- gboolean eat_credit)
-{
- if (self->cmd.first) {
- return &self->cmd;
- } else {
- guint i;
-
- for (i = 0; i < self->max_logical_conns; i++) {
- NciSarLogicalConnection* conn = self->conn + i;
-
- if (conn->out.first && conn->credits) {
- if (eat_credit) {
- conn->credits--;
- }
- return &conn->out;
- }
- }
- }
- return NULL;
-}
-
-static
-gboolean
-nci_sar_can_write(
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_sar.h
^
|
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_SAR_H
-#define NCI_SAR_H
-
-#include "nci_types_p.h"
-
-/* SAR (Segmentation and Reassembly) */
-
-typedef struct nci_sar_client NciSarClient;
-
-typedef struct nci_sar_client_functions {
- void (*error)(NciSarClient* client);
- void (*handle_response)(NciSarClient* client, guint8 gid, guint8 oid,
- const void* payload, guint payload_len);
- void (*handle_notification)(NciSarClient* client, guint8 gid, guint8 oid,
- const void* payload, guint payload_len);
- void (*handle_data_packet)(NciSarClient* client, guint8 cid,
- const void* payload, guint payload_len);
-} NciSarClientFunctions;
-
-struct nci_sar_client {
- const NciSarClientFunctions* fn;
-};
-
-typedef
-void
-(*NciSarCompletionFunc)(
- NciSarClient* client,
- gboolean success,
- gpointer user_data);
-
-NciSar*
-nci_sar_new(
- NciHalIo* io,
- NciSarClient* client);
-
-void
-nci_sar_free(
- NciSar* sar);
-
-gboolean
-nci_sar_start(
- NciSar* sar);
-
-void
-nci_sar_reset(
- NciSar* sar);
-
-void
-nci_sar_set_max_logical_connections(
- NciSar* sar,
- guint8 max);
-
-void
-nci_sar_set_max_control_packet_size(
- NciSar* sar,
- guint8 max);
-
-void
-nci_sar_set_initial_credits(
- NciSar* sar,
- guint8 cid,
- guint8 credits);
-
-void
-nci_sar_add_credits(
- NciSar* sar,
- guint8 cid,
- guint8 credits);
-
-guint
-nci_sar_send_command(
- NciSar* sar,
- guint8 gid,
- guint8 oid,
- GBytes* payload,
- NciSarCompletionFunc complete,
- GDestroyNotify destroy,
- gpointer user_data);
-
-guint
-nci_sar_send_data_packet(
- NciSar* sar,
- guint8 cid,
- GBytes* payload,
- NciSarCompletionFunc complete,
- GDestroyNotify destroy,
- gpointer user_data);
-
-void
-nci_sar_cancel(
- NciSar* sar,
- guint id);
-
-#endif /* NFC_SAR_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_sm.c
^
|
@@ -1,985 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_sm.h"
-#include "nci_sar.h"
-#include "nci_param.h"
-#include "nci_state_p.h"
-#include "nci_transition.h"
-#include "nci_log.h"
-
-#include <gutil_idlepool.h>
-#include <gutil_macros.h>
-#include <gutil_misc.h>
-
-#include <glib-object.h>
-
-typedef GObjectClass NciSmObjectClass;
-
-typedef struct nci_sm_closure {
- GCClosure cclosure;
- NciSmFunc func;
- gpointer* user_data;
-} NciSmClosure;
-
-typedef struct nci_sm_intf_activated_closure {
- GCClosure cclosure;
- NciSmIntfActivationFunc func;
- gpointer* user_data;
-} NciSmIntfActivationClosure;
-
-typedef struct nci_sm_object {
- GObject object;
- NciSm sm;
- GUtilIdlePool* pool;
- GPtrArray* states;
- GPtrArray* transitions;
- NciTransition* reset_transition;
- NciTransition* next_transition;
- NciTransition* active_transition;
- NciState* active_state;
- guint32 pending_signals;
-} NciSmObject;
-
-G_DEFINE_TYPE(NciSmObject, nci_sm_object, G_TYPE_OBJECT)
-#define NCI_TYPE_SM (nci_sm_object_get_type())
-#define NCI_SM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- NCI_TYPE_SM, NciSmObject))
-#define NCI_SM_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
- NCI_TYPE_SM, NciSmObjectClass)
-
-typedef enum nci_sm_signal {
- SIGNAL_NEXT_STATE,
- SIGNAL_LAST_STATE,
- SIGNAL_INTF_ACTIVATED,
- SIGNAL_COUNT
-} NCI_SM_SIGNAL;
-
-#define SIGNAL_LAST_STATE_NAME "nci-sm-last-state"
-#define SIGNAL_NEXT_STATE_NAME "nci-sm-next-state"
-#define SIGNAL_INTF_ACTIVATED_NAME "nci-sm-intf-activated"
-
-static guint nci_sm_signals[SIGNAL_COUNT] = { 0 };
-
-#define NCI_IS_INTERNAL_STATE(state) ((state) < NCI_RFST_IDLE)
-
-static inline NciSmObject* nci_sm_object(NciSm* sm) /* NULL safe */
- { return G_LIKELY(sm) ? NCI_SM(G_CAST(sm, NciSmObject, sm)) : NULL; }
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-inline
-void
-nci_sm_queue_signal(
- NciSmObject* self,
- NCI_SM_SIGNAL sig)
-{
- self->pending_signals |= (1 << sig);
-}
-
-static
-void
-nci_sm_emit_pending_signals(
- NciSmObject* self)
-{
- if (self->pending_signals) {
- GObject* obj = &self->object;
- int sig;
-
- /* Handlers could drops their references to us */
- g_object_ref(obj);
- for (sig = 0; self->pending_signals && sig < SIGNAL_COUNT; sig++) {
- const guint32 signal_bit = (1 << sig);
- if (self->pending_signals & signal_bit) {
- self->pending_signals &= ~signal_bit;
- g_signal_emit(obj, nci_sm_signals[sig], 0);
- }
- }
- /* And release the temporary reference */
- g_object_unref(obj);
- }
-}
-
-static
-NciState*
-nci_sm_add_new_state(
- NciSm* sm,
- NciState* (*fn)(NciSm* sm))
-{
- NciState* state = fn(sm);
-
- nci_sm_add_state(sm, state);
- nci_state_unref(state);
- return state;
-}
-
-static
-void
-nci_sm_add_new_transition(
- NciSm* sm,
- NCI_STATE state,
- NciTransition* (*fn)(NciSm* sm))
-{
- NciTransition* transition = fn(sm);
-
- nci_sm_add_transition(sm, state, transition);
- nci_transition_unref(transition);
-}
-
-static
-void
-nci_sm_weak_pointer_notify(
- gpointer data,
- GObject* dead_object)
-{
- NciSm** ptr = data;
- NciSmObject* dead_self = G_CAST(dead_object, NciSmObject, object);
-
- if (*ptr == &dead_self->sm) {
- *ptr = NULL;
- }
-}
-
-static
-void
-nci_sm_finish_active_transition(
- NciSmObject* self)
-{
- if (self->active_transition) {
- NciTransition* finished = self->active_transition;
-
- self->active_transition = NULL;
- nci_transition_finished(finished);
- nci_transition_unref(finished);
- }
-}
-
-static
-gboolean
-nci_sm_start_transition(
- NciSmObject* self,
- NciTransition* transition)
-{
- /* Caller checks that transition is not NULL */
- if (self->active_transition != transition) {
- nci_sm_finish_active_transition(self);
- }
-
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_sm.h
^
|
@@ -1,423 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_STATE_MACHINE_H
-#define NCI_STATE_MACHINE_H
-
-#include "nci_types_p.h"
-
-/* RF Communication State Machine */
-
-typedef enum nci_interface_version {
- NCI_INTERFACE_VERSION_UNKNOWN,
- NCI_INTERFACE_VERSION_1,
- NCI_INTERFACE_VERSION_2
-} NCI_INTERFACE_VERSION;
-
-/* Table 9: NFCC Features */
-typedef enum nci_nfcc_discovery {
- NCI_NFCC_DISCOVERY_NONE = 0x00,
- NCI_NFCC_DISCOVERY_FREQUENCY_CONFIG = 0x01,
- NCI_NFCC_DISCOVERY_RF_CONFIG_MERGE = 0x02
-} NCI_NFCC_DISCOVERY;
-
-typedef enum nci_nfcc_routing {
- NCI_NFCC_ROUTING_NONE = 0x00,
- NCI_NFCC_ROUTING_TECHNOLOGY_BASED = 0x02,
- NCI_NFCC_ROUTING_PROTOCOL_BASED = 0x04,
- NCI_NFCC_ROUTING_AID_BASED = 0x08
-} NCI_NFCC_ROUTING;
-
-typedef enum nci_nfcc_power {
- NCI_NFCC_POWER_NONE = 0x00,
- NCI_NFCC_POWER_BATTERY_OFF = 0x01,
- NCI_NFCC_POWER_SWITCH_OFF = 0x02
-} NCI_NFCC_POWER;
-
-/* Table 43: Value Field for Mode */
-#define NCI_DISCOVER_MAP_MODE_POLL (0x01)
-#define NCI_DISCOVER_MAP_MODE_LISTEN (0x02)
-
-/* Table 46: TLV Coding for Listen Mode Routing */
-#define NCI_ROUTING_ENTRY_TYPE_TECHNOLOGY (0x00)
-#define NCI_ROUTING_ENTRY_TYPE_PROTOCOL (0x01)
-#define NCI_ROUTING_ENTRY_TYPE_AID (0x02)
-
-/* Table 50: Value Field for Power State */
-#define NCI_ROUTING_ENTRY_POWER_ON (0x01)
-#define NCI_ROUTING_ENTRY_POWER_OFF (0x02)
-#define NCI_ROUTING_ENTRY_POWER_BATTERY_OFF (0x04)
-#define NCI_ROUTING_ENTRY_POWER_ALL (0x07)
-
-/* Table 63: Deactivation Types */
-typedef enum nci_deactivation_type {
- NCI_DEACTIVATE_TYPE_IDLE = 0x00,
- NCI_DEACTIVATE_TYPE_SLEEP = 0x01,
- NCI_DEACTIVATE_TYPE_SLEEP_AF = 0x02,
- NCI_DEACTIVATE_TYPE_DISCOVERY = 0x03
-} NCI_DEACTIVATION_TYPE;
-
-/* Table 64: Deactivation Reasons */
-typedef enum nci_deactivation_reason {
- NCI_DEACTIVATION_REASON_DH_REQUEST = 0x00,
- NCI_DEACTIVATION_REASON_ENDPOINT_REQUEST = 0x01,
- NCI_DEACTIVATION_REASON_RF_LINK_LOSS = 0x02,
- NCI_DEACTIVATION_REASON_BAD_AFI = 0x03
-} NCI_DEACTIVATION_REASON;
-
-/* Table 84: NFCEE IDs */
-#define NCI_NFCEE_ID_DH (0x00)
-
-/* Table 94: Status Codes */
-#define NCI_STATUS_OK (0x00)
-#define NCI_STATUS_REJECTED (0x01)
-#define NCI_STATUS_RF_FRAME_CORRUPTED (0x02)
-#define NCI_STATUS_FAILED (0x03)
-#define NCI_STATUS_NOT_INITIALIZED (0x04)
-#define NCI_STATUS_SYNTAX_ERROR (0x05)
-#define NCI_STATUS_SEMANTIC_ERROR (0x06)
-#define NCI_STATUS_INVALID_PARAM (0x09)
-#define NCI_STATUS_MESSAGE_SIZE_EXCEEDED (0x0a)
-#define NCI_DISCOVERY_ALREADY_STARTED (0xa0)
-#define NCI_DISCOVERY_TARGET_ACTIVATION_FAILED (0xa1)
-#define NCI_DISCOVERY_TEAR_DOWN (0xa2)
-#define NCI_RF_TRANSMISSION_ERROR (0xb0)
-#define NCI_RF_PROTOCOL_ERROR (0xb1)
-#define NCI_RF_TIMEOUT_ERROR (0xb2)
-#define NCI_NFCEE_INTERFACE_ACTIVATION_FAILED (0xc0)
-#define NCI_NFCEE_TRANSMISSION_ERROR (0xc1)
-#define NCI_NFCEE_PROTOCOL_ERROR (0xc2)
-#define NCI_NFCEE_TIMEOUT_ERROR (0xc3)
-
-/* Table 95: RF Technologies */
-typedef enum nci_rf_technology {
- NCI_RF_TECHNOLOGY_A = 0x00,
- NCI_RF_TECHNOLOGY_B = 0x01,
- NCI_RF_TECHNOLOGY_F = 0x02,
- NCI_RF_TECHNOLOGY_15693 = 0x03
-} NCI_RF_TECHNOLOGY;
-
-/* Table 101: Configuration Parameter Tags */
-
-/* Common Discovery Parameters */
-#define NCI_CONFIG_TOTAL_DURATION (0x00)
-#define NCI_CONFIG_CON_DEVICES_LIMIT (0x01)
-
-/* Poll Mode: NFC-A Discovery Parameters */
-#define NCI_CONFIG_PA_BAIL_OUT (0x08)
-
-/* Poll Mode: NFC-B Discovery Parameters */
-#define NCI_CONFIG_PB_AFI (0x10)
-#define NCI_CONFIG_PB_BAIL_OUT (0x11)
-#define NCI_CONFIG_PB_ATTRIB_PARAM1 (0x12)
-#define NCI_CONFIG_PB_SENSB_REQ_PARAM (0x13)
-
-/* Poll Mode: NFC-F Discovery Parameters */
-#define NCI_CONFIG_PF_BIT_RATE (0x18)
-#define NCI_CONFIG_PF_RC_CODE (0x19)
-
-/* Poll Mode: ISO-DEP Discovery Parameters */
-#define NCI_CONFIG_PB_H_INFO (0x20)
-#define NCI_CONFIG_PI_BIT_RATE (0x21)
-#define NCI_CONFIG_PA_ADV_FEAT (0x22)
-
-/* Poll Mode: NFC-DEP Discovery Parameters */
-#define NCI_CONFIG_PN_NFC_DEP_SPEED (0x28)
-#define NCI_CONFIG_PN_ATR_REQ_GEN_BYTES (0x29)
-#define NCI_CONFIG_PN_ATR_REQ_CONFIG (0x2A)
-
-/* Listen Mode: NFC-A Discovery Parameters */
-#define NCI_CONFIG_LA_BIT_FRAME_SDD (0x30)
-#define NCI_CONFIG_LA_PLATFORM_CONFIG (0x31)
-#define NCI_CONFIG_LA_SEL_INFO (0x32)
-#define NCI_CONFIG_LA_NFCID1 (0x33)
-
-/* Listen Mode: NFC-B Discovery Parameters */
-#define NCI_CONFIG_LB_SENSB_INFO (0x38)
-#define NCI_CONFIG_LB_NFCID0 (0x39)
-#define NCI_CONFIG_LB_APPLICATION_DATA (0x3A)
-#define NCI_CONFIG_LB_SFGI (0x3B)
-#define NCI_CONFIG_LB_ADC_FO (0x3C)
-
-/* Listen Mode: NFC-F Discovery Parameters */
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_1 (0x40)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_2 (0x41)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_3 (0x42)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_4 (0x43)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_5 (0x44)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_6 (0x45)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_7 (0x46)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_8 (0x47)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_9 (0x48)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_10 (0x49)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_11 (0x4A)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_12 (0x4B)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_13 (0x4C)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_14 (0x4D)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_15 (0x4E)
-#define NCI_CONFIG_LF_T3T_IDENTIFIERS_16 (0x4F)
-#define NCI_CONFIG_LF_PROTOCOL_TYPE (0x50)
-#define NCI_CONFIG_LF_T3T_PMM (0x51)
-#define NCI_CONFIG_LF_T3T_MAX (0x52)
-#define NCI_CONFIG_LF_T3T_FLAGS (0x53)
-#define NCI_CONFIG_LF_CON_BITR_F (0x54)
-#define NCI_CONFIG_LF_ADV_FEAT (0x55)
-
-/* Listen Mode: ISO-DEP Discovery Parameters */
-#define NCI_CONFIG_LI_FWI (0x58)
-#define NCI_CONFIG_LA_HIST_BY (0x59)
-#define NCI_CONFIG_LB_H_INFO_RESP (0x5A)
-#define NCI_CONFIG_LI_BIT_RATE (0x5B)
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_state.c
^
|
@@ -1,379 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_state_p.h"
-#include "nci_state_impl.h"
-#include "nci_sm.h"
-#include "nci_transition.h"
-#include "nci_log.h"
-
-struct nci_state_priv {
- NciSm* sm; /* Weak reference */
- GHashTable* transitions;
-};
-
-G_DEFINE_TYPE(NciState, nci_state, G_TYPE_OBJECT)
-#define NCI_STATE_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
- NCI_TYPE_STATE, NciStateClass)
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_state_transition_gone(
- gpointer state,
- GObject* dead_transition)
-{
- NciState* self = NCI_STATE(state);
- NciStatePriv* priv = self->priv;
- GHashTableIter it;
- gpointer value;
-
- g_hash_table_iter_init(&it, priv->transitions);
- while (g_hash_table_iter_next(&it, NULL, &value)) {
- if (dead_transition == value) {
- g_hash_table_iter_remove(&it);
- return;
- }
- }
- GVERBOSE("Unexpected dead transition %p", dead_transition);
-}
-
-static
-void
-nci_state_generic_error_ntf(
- NciState* self,
- const GUtilData* payload)
-{
- if (payload->size == 1) {
- GWARN("Generic error 0x%02x", payload->bytes[0]);
- } else {
- GWARN("Failed to parse CORE_GENERIC_ERROR_NTF");
- }
-}
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciState*
-nci_state_ref(
- NciState* self)
-{
- if (G_LIKELY(self)) {
- g_object_ref(NCI_STATE(self));
- }
- return self;
-}
-
-void
-nci_state_unref(
- NciState* self)
-{
- if (G_LIKELY(self)) {
- g_object_unref(NCI_STATE(self));
- }
-}
-
-/*==========================================================================*
- * Internal states
- *==========================================================================*/
-
-static
-NciState*
-nci_state_new(
- NciSm* sm,
- NCI_STATE state,
- const char* name)
-{
- NciState* self = g_object_new(NCI_TYPE_STATE, NULL);
-
- nci_state_init_base(self, sm, state, name);
- return self;
-}
-
-NciState*
-nci_state_init_new(
- NciSm* sm)
-{
- return nci_state_new(sm, NCI_STATE_INIT, "INIT");
-}
-
-NciState*
-nci_state_error_new(
- NciSm* sm)
-{
- return nci_state_new(sm, NCI_STATE_ERROR, "ERROR");
-}
-
-NciState*
-nci_state_stop_new(
- NciSm* sm)
-{
- return nci_state_new(sm, NCI_STATE_STOP, "STOP");
-}
-
-/*==========================================================================*
- * Trivial states
- *==========================================================================*/
-
-NciState*
-nci_state_idle_new(
- NciSm* sm)
-{
- return nci_state_new(sm, NCI_RFST_IDLE, "RFST_IDLE");
-}
-
-/*==========================================================================*
- * Internal interface
- *==========================================================================*/
-
-void
-nci_state_init_base(
- NciState* self,
- NciSm* sm,
- NCI_STATE state,
- const char* name)
-{
- NciStatePriv* priv = self->priv;
-
- /* Assume that name points to static buffer */
- self->name = name;
- self->state = state;
- priv->sm = sm;
- nci_sm_add_weak_pointer(&priv->sm);
-}
-
-gboolean
-nci_state_send_command(
- NciState* self,
- guint8 gid,
- guint8 oid,
- GBytes* payload,
- NciSmResponseFunc resp,
- gpointer user_data)
-{
- return G_LIKELY(self) && nci_sm_send_command(self->priv->sm,
- gid, oid, payload, resp, user_data);
-}
-
-NciSm*
-nci_state_sm(
- NciState* self)
-{
- return G_LIKELY(self) ? self->priv->sm : NULL;
-}
-
-void
-nci_state_add_transition(
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_state_discovery.c
^
|
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_sm.h"
-#include "nci_sar.h"
-#include "nci_state_impl.h"
-#include "nci_param_w4_all_discoveries.h"
-#include "nci_util.h"
-#include "nci_log.h"
-
-typedef NciState NciStateDiscovery;
-typedef NciStateClass NciStateDiscoveryClass;
-
-G_DEFINE_TYPE(NciStateDiscovery, nci_state_discovery, NCI_TYPE_STATE)
-#define THIS_TYPE (nci_state_discovery_get_type())
-#define PARENT_CLASS (nci_state_discovery_parent_class)
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_state_discovery_intf_activated_ntf(
- NciState* self,
- const GUtilData* payload)
-{
- NciIntfActivationNtf ntf;
- NciModeParam mode_param;
- NciActivationParam activation_param;
- NciSm* sm = nci_state_sm(self);
-
- /*
- * 5.2.2 State RFST_DISCOVERY
- *
- * ...
- * While polling, if the NFCC discovers just one Remote NFC Endpoint
- * that supports just one Protocol, the NFCC SHALL try to automatically
- * activate it. The NFCC SHALL first establish any underlying protocol(s)
- * with the Remote NFC Endpoint that are needed by the configured RF
- * Interface. On completion, the NFCC SHALL activate the RF Interface
- * and send RF_INTF_ACTIVATED_NTF (Poll Mode) to the DH. At this point,
- * the state is changed to RFST_POLL_ACTIVE.
- */
- if (nci_parse_intf_activated_ntf(&ntf, &mode_param, &activation_param,
- payload->bytes, payload->size)) {
- nci_sm_intf_activated(sm, &ntf);
- nci_sm_enter_state(sm, NCI_RFST_POLL_ACTIVE, NULL);
- } else {
- /* Deactivate this target */
- nci_sm_enter_state(sm, NCI_RFST_POLL_ACTIVE, NULL);
- nci_sm_switch_to(sm, NCI_RFST_DISCOVERY);
- }
-}
-
-static
-void
-nci_state_discovery_discover_ntf(
- NciState* self,
- const GUtilData* payload)
-{
- NciDiscoveryNtf ntf;
- NciModeParam param;
-
- /*
- * 5.2.2 State RFST_DISCOVERY
- *
- * ...
- * While polling, if the NFCC discovers more than one Remote NFC Endpoint,
- * or a Remote NFC Endpoint that supports more than one RF Protocol, it
- * SHALL start sending RF_DISCOVER_NTF messages to the DH. At this point,
- * the state is changed to RFST_W4_ALL_DISCOVERIES.
- */
- if (nci_parse_discover_ntf(&ntf, ¶m, payload->bytes, payload->size)) {
- NciSm* sm = nci_state_sm(self);
- NciParam* param = NCI_PARAM(nci_param_w4_all_discoveries_new(&ntf));
-
- nci_sm_enter_state(sm, NCI_RFST_W4_ALL_DISCOVERIES, param);
- nci_param_unref(param);
- }
-}
-
-static
-gboolean
-nci_state_discovery_generic_error_ntf(
- NciState* self,
- const GUtilData* payload)
-{
- const guint8* pkt = payload->bytes;
- const guint len = payload->size;
-
- /*
- * Table 18: Control Messages for Generic Error
- *
- * CORE_GENERIC_ERROR_NTF
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Status |
- * +=========================================================+
- *
- * 5.2.2 State RFST_DISCOVERY
- *
- * ...
- * If the protocol activation is not successful, the NFCC SHALL
- * send CORE_GENERIC_ERROR_NTF to the DH with status
- * DISCOVERY_TARGET_ACTIVATION_FAILED and stay in RFST_DISCOVERY.
- *
- * In this state, the NFCC MAY detect a command during the RF
- * communication, which forces it to come back to the IDLE state,
- * as defined in the [NFC Forum Activity Technical Specification]
- * Listen Mode state machine. If the RF Protocol deactivation is
- * completed, the NFCC SHALL send CORE_GENERIC_ERROR_NTF
- * (DISCOVERY_TEAR_DOWN), and the state will remain RFST_DISCOVERY.
- */
- if (len == 1) {
- switch (pkt[0]) {
- case NCI_DISCOVERY_TARGET_ACTIVATION_FAILED:
- GDEBUG("CORE_GENERIC_ERROR_NTF (Activation Failed)");
- return TRUE;
- case NCI_DISCOVERY_TEAR_DOWN:
- GDEBUG("CORE_GENERIC_ERROR_NTF (Tear Down)");
- return TRUE;
- }
- }
- /* Unrecornized notification */
- return FALSE;
-}
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciState*
-nci_state_discovery_new(
- NciSm* sm)
-{
- NciState* self = g_object_new(THIS_TYPE, NULL);
-
- nci_state_init_base(self, sm, NCI_RFST_DISCOVERY, "RFST_DISCOVERY");
- return self;
-}
-
-/*==========================================================================*
- * Methods
- *==========================================================================*/
-
-static
-void
-nci_state_discovery_handle_ntf(
- NciState* self,
- guint8 gid,
- guint8 oid,
- const GUtilData* payload)
-{
- switch (gid) {
- case NCI_GID_CORE:
- switch (oid) {
- case NCI_OID_CORE_GENERIC_ERROR:
- if (nci_state_discovery_generic_error_ntf(self, payload)) {
- return;
- }
- }
- break;
- case NCI_GID_RF:
- switch (oid) {
- case NCI_OID_RF_DISCOVER:
- nci_state_discovery_discover_ntf(self, payload);
- return;
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_state_impl.h
^
|
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_STATE_IMPL_H
-#define NCI_STATE_IMPL_H
-
-#include "nci_state.h"
-#include "nci_types_p.h"
-
-/* Internal API for use by NciState implemenations */
-
-typedef struct nci_state_class {
- GObjectClass parent;
- void (*enter)(NciState* state, NciParam* param);
- void (*reenter)(NciState* state, NciParam* param);
- void (*leave)(NciState* state);
- void (*handle_ntf)(NciState* state, guint8 gid, guint8 oid,
- const GUtilData* payload);
-} NciStateClass;
-
-#define NCI_STATE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), \
- NCI_TYPE_STATE, NciStateClass)
-
-void
-nci_state_init_base(
- NciState* state,
- NciSm* sm,
- NCI_STATE id,
- const char* name);
-
-gboolean
-nci_state_send_command(
- NciState* state,
- guint8 gid,
- guint8 oid,
- GBytes* payload,
- NciSmResponseFunc resp,
- gpointer user_data);
-
-void
-nci_state_error(
- NciState* state);
-
-NciSm*
-nci_state_sm(
- NciState* state);
-
-#endif /* NCI_STATE_IMPL_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_state_p.h
^
|
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_STATE_PRIVATE_H
-#define NCI_STATE_PRIVATE_H
-
-#include "nci_types_p.h"
-
-#include "nci_state.h"
-
-NciTransition*
-nci_state_get_transition(
- NciState* state,
- NCI_STATE dest);
-
-void
-nci_state_add_transition(
- NciState* state,
- NciTransition* transition);
-
-void
-nci_state_enter(
- NciState* state,
- void* param);
-
-void
-nci_state_reenter(
- NciState* state,
- void* param);
-
-void
-nci_state_leave(
- NciState* state);
-
-void
-nci_state_handle_ntf(
- NciState* state,
- guint8 gid,
- guint8 oid,
- const GUtilData* payload);
-
-/* Specific states */
-
-NciState* /* NCI_STATE_INIT */
-nci_state_init_new(
- NciSm* sm);
-
-NciState* /* NCI_STATE_ERROR */
-nci_state_error_new(
- NciSm* sm);
-
-NciState* /* NCI_STATE_STOP */
-nci_state_stop_new(
- NciSm* sm);
-
-NciState* /* NCI_RFST_IDLE */
-nci_state_idle_new(
- NciSm* sm);
-
-NciState* /* NCI_RFST_DISCOVERY */
-nci_state_discovery_new(
- NciSm* sm);
-
-NciState* /* NCI_RFST_POLL_ACTIVE */
-nci_state_poll_active_new(
- NciSm* sm);
-
-NciState* /* NCI_RFST_W4_ALL_DISCOVERIES */
-nci_state_w4_all_discoveries_new(
- NciSm* sm);
-
-NciState* /* NCI_RFST_W4_HOST_SELECT */
-nci_state_w4_host_select_new(
- NciSm* sm);
-
-#endif /* NCI_STATE_PRIVATE_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_state_poll_active.c
^
|
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_sm.h"
-#include "nci_state_impl.h"
-#include "nci_log.h"
-
-typedef NciState NciStatePollActive;
-typedef NciStateClass NciStatePollActiveClass;
-
-G_DEFINE_TYPE(NciStatePollActive, nci_state_poll_active, NCI_TYPE_STATE)
-#define THIS_TYPE (nci_state_poll_active_get_type())
-#define PARENT_CLASS (nci_state_poll_active_parent_class)
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-gboolean
-nci_state_poll_active_interface_error_ntf(
- NciState* self,
- const GUtilData* payload)
-{
- const guint8* pkt = payload->bytes;
- const guint len = payload->size;
-
- /*
- * Table 19: Control Messages for Interface Error
- *
- * CORE_INTERFACE_ERROR_NTF
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Status |
- * | 1 | 1 | Conn ID |
- * +=========================================================+
- *
- * 5.2.5 State RFST_POLL_ACTIVE
- *
- * ...
- * When using the ISO-DEP or NFC-DEP RF interface, and the NFCC
- * detects an error during the RF communication, it SHALL notify
- * the DH sending CORE_INTERFACE_ERROR_NTF, using the appropriate
- * status out of RF_TRANSMISSION_ERROR, RF_PROTOCOL_ERROR and
- * RF_TIMEOUT_ERROR. The state will then remain RFST_POLL_ACTIVE.
- */
- if (len == 2) {
- switch (pkt[0]) {
- case NCI_RF_TRANSMISSION_ERROR:
- GDEBUG("CORE_INTERFACE_ERROR_NTF (Transmission Error)");
- return TRUE;
- case NCI_RF_PROTOCOL_ERROR:
- GDEBUG("CORE_INTERFACE_ERROR_NTF (Protocol Error)");
- return TRUE;
- case NCI_RF_TIMEOUT_ERROR:
- GDEBUG("CORE_INTERFACE_ERROR_NTF (Timeout)");
- return TRUE;
- }
- }
- /* Unrecornized notification */
- return FALSE;
-}
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciState*
-nci_state_poll_active_new(
- NciSm* sm)
-{
- NciState* self = g_object_new(THIS_TYPE, NULL);
-
- nci_state_init_base(self, sm, NCI_RFST_POLL_ACTIVE, "RFST_POLL_ACTIVE");
- return self;
-}
-
-/*==========================================================================*
- * Methods
- *==========================================================================*/
-
-static
-void
-nci_state_poll_active_handle_ntf(
- NciState* state,
- guint8 gid,
- guint8 oid,
- const GUtilData* payload)
-{
- switch (gid) {
- case NCI_GID_CORE:
- switch (oid) {
- case NCI_OID_CORE_INTERFACE_ERROR:
- if (nci_state_poll_active_interface_error_ntf(state, payload)) {
- return;
- }
- break;
- }
- break;
- case NCI_GID_RF:
- switch (oid) {
- case NCI_OID_RF_DEACTIVATE:
- nci_sm_handle_rf_deactivate_ntf(nci_state_sm(state), payload);
- return;
- }
- break;
- }
- NCI_STATE_CLASS(PARENT_CLASS)->handle_ntf(state, gid, oid, payload);
-}
-
-/*==========================================================================*
- * Internals
- *==========================================================================*/
-
-static
-void
-nci_state_poll_active_init(
- NciStatePollActive* self)
-{
-}
-
-static
-void
-nci_state_poll_active_class_init(
- NciStatePollActiveClass* klass)
-{
- NCI_STATE_CLASS(klass)->handle_ntf = nci_state_poll_active_handle_ntf;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_state_w4_all_discoveries.c
^
|
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_sm.h"
-#include "nci_state_impl.h"
-#include "nci_param_w4_all_discoveries.h"
-#include "nci_param_w4_host_select.h"
-#include "nci_util.h"
-
-typedef NciStateClass NciStateW4AllDiscoveriesClass;
-typedef struct nci_state_w4_all_discoveries {
- NciState state;
- GPtrArray* discoveries;
-} NciStateW4AllDiscoveries;
-
-G_DEFINE_TYPE(NciStateW4AllDiscoveries, nci_state_w4_all_discoveries,
- NCI_TYPE_STATE)
-#define THIS_TYPE (nci_state_w4_all_discoveries_get_type())
-#define PARENT_CLASS (nci_state_w4_all_discoveries_parent_class)
-#define NCI_STATE_W4_ALL_DISCOVERIES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- THIS_TYPE, NciStateW4AllDiscoveries))
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_state_w4_all_discoveries_handle_discovery(
- NciStateW4AllDiscoveries* self,
- const NciDiscoveryNtf* ntf)
-{
- /* Store discovery info in self->discoveries */
- g_ptr_array_add(self->discoveries, nci_discovery_ntf_copy(ntf));
-
- /*
- * 5.2.3 State RFST_W4_ALL_DISCOVERIES
- *
- * ...
- * Discover notifications with Notification type set to 2 SHALL NOT
- * change the state. When the NFCC sends the last RF_DISCOVER_NTF
- * (Notification Type not equal to 2) to the DH, the state is
- * changed to RFST_W4_HOST_SELECT.
- */
- if (ntf->last) {
- NciSm* sm = nci_state_sm(&self->state);
- NciParam* param = NCI_PARAM(nci_param_w4_host_select_new(
- (const NciDiscoveryNtf**)self->discoveries->pdata,
- self->discoveries->len));
-
- nci_sm_enter_state(sm, NCI_RFST_W4_HOST_SELECT, param);
- nci_param_unref(param);
- }
-}
-
-static
-void
-nci_state_w4_all_discoveries_start(
- NciStateW4AllDiscoveries* self,
- NciParam* param)
-{
- g_ptr_array_set_size(self->discoveries, 0);
- if (NCI_IS_PARAM_W4_ALL_DISCOVERIES(param)) {
- nci_param_ref(param);
- nci_state_w4_all_discoveries_handle_discovery(self,
- NCI_PARAM_W4_ALL_DISCOVERIES(param)->ntf);
- nci_param_unref(param);
- }
-}
-
-static
-void
-nci_state_w4_all_discoveries_discover_ntf(
- NciStateW4AllDiscoveries* self,
- const GUtilData* payload)
-{
- NciDiscoveryNtf ntf;
- NciModeParam param;
-
- if (nci_parse_discover_ntf(&ntf, ¶m, payload->bytes, payload->size)) {
- nci_state_w4_all_discoveries_handle_discovery(self, &ntf);
- }
-}
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciState*
-nci_state_w4_all_discoveries_new(
- NciSm* sm)
-{
- NciState* self = g_object_new(THIS_TYPE, NULL);
-
- nci_state_init_base(self, sm, NCI_RFST_W4_ALL_DISCOVERIES,
- "RFST_W4_ALL_DISCOVERIES");
- return self;
-}
-
-/*==========================================================================*
- * Methods
- *==========================================================================*/
-
-static
-void
-nci_state_w4_all_discoveries_enter(
- NciState* state,
- NciParam* param)
-{
- NciStateW4AllDiscoveries* self = NCI_STATE_W4_ALL_DISCOVERIES(state);
-
- nci_state_w4_all_discoveries_start(self, param);
- NCI_STATE_CLASS(PARENT_CLASS)->enter(state, param);
-}
-
-static
-void
-nci_state_w4_all_discoveries_reenter(
- NciState* state,
- NciParam* param)
-{
- NciStateW4AllDiscoveries* self = NCI_STATE_W4_ALL_DISCOVERIES(state);
-
- nci_state_w4_all_discoveries_start(self, param);
- NCI_STATE_CLASS(PARENT_CLASS)->reenter(state, param);
-}
-
-static
-void
-nci_state_w4_all_discoveries_leave(
- NciState* state)
-{
- NciStateW4AllDiscoveries* self = NCI_STATE_W4_ALL_DISCOVERIES(state);
-
- /* Release the memory */
- g_ptr_array_set_size(self->discoveries, 0);
- NCI_STATE_CLASS(PARENT_CLASS)->leave(state);
-}
-
-static
-void
-nci_state_w4_all_discoveries_handle_ntf(
- NciState* state,
- guint8 gid,
- guint8 oid,
- const GUtilData* payload)
-{
- switch (gid) {
- case NCI_GID_RF:
- switch (oid) {
- case NCI_OID_RF_DISCOVER:
- nci_state_w4_all_discoveries_discover_ntf
- (NCI_STATE_W4_ALL_DISCOVERIES(state), payload);
- return;
- }
- break;
- }
- NCI_STATE_CLASS(PARENT_CLASS)->handle_ntf(state, gid, oid, payload);
-}
-
-/*==========================================================================*
- * Internals
- *==========================================================================*/
-
-static
-void
-nci_state_w4_all_discoveries_init(
- NciStateW4AllDiscoveries* self)
-{
- self->discoveries = g_ptr_array_new_with_free_func(g_free);
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_state_w4_host_select.c
^
|
@@ -1,351 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_sm.h"
-#include "nci_state_impl.h"
-#include "nci_param_w4_host_select.h"
-#include "nci_util.h"
-#include "nci_log.h"
-
-typedef NciStateClass NciStateW4HostSelectClass;
-typedef NciState NciStateW4HostSelect;
-
-G_DEFINE_TYPE(NciStateW4HostSelect, nci_state_w4_host_select, NCI_TYPE_STATE)
-#define THIS_TYPE (nci_state_w4_host_select_get_type())
-#define PARENT_CLASS (nci_state_w4_host_select_parent_class)
-#define NCI_STATE_W4_HOST_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- THIS_TYPE, NciStateW4HostSelect))
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-gint
-nci_state_w4_host_select_sort(
- gconstpointer a,
- gconstpointer b)
-{
- const NciDiscoveryNtf* ntf_a = a;
- const NciDiscoveryNtf* ntf_b = b;
-
- /*
- * Return 0 if elements are equal, a negative value if the
- * first element comes before the second, or a positive value if
- * the first element comes after the second.
- */
- if (ntf_a->protocol != ntf_b->protocol) {
- static const NCI_PROTOCOL protocol_order[] = {
- NCI_PROTOCOL_T2T,
- NCI_PROTOCOL_ISO_DEP
- };
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS(protocol_order); i++) {
- if (ntf_a->protocol == protocol_order[i]) {
- return -1;
- } else if (ntf_b->protocol == protocol_order[i]) {
- return 1;
- }
- }
- }
-
- /* Otherwise sort by discovery ID */
- return (gint)(ntf_a->discovery_id) - (gint)(ntf_b->discovery_id);
-}
-
-static
-void
-nci_state_w4_host_select_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- gpointer user_data)
-{
- if (status == NCI_REQUEST_SUCCESS) {
- const guint8* pkt = payload->bytes;
- const guint len = payload->size;
-
- /*
- * Table 60: Control Messages to select a Discovered Target
- *
- * RF_DISCOVER_SELECT_RSP
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Status |
- * +=========================================================+
- */
- if (len > 0 && pkt[0] == NCI_STATUS_OK) {
- GDEBUG("%c RF_DISCOVER_SELECT_RSP ok", DIR_IN);
- } else {
- if (len > 0) {
- GWARN("%c RF_DISCOVER_SELECT_RSP error %u", DIR_IN, pkt[0]);
- } else {
- GWARN("%c Broken RF_DISCOVER_SELECT_RSP", DIR_IN);
- }
- }
- } else {
- GWARN("RF_DISCOVER_SELECT failed");
- }
-}
-
-static
-void
-nci_state_w4_host_select_entered(
- NciStateW4HostSelect* self,
- NciParam* param)
-{
- if (NCI_IS_PARAM_W4_HOST_SELECT(param)) {
- NciSm* sm = nci_state_sm(self);
- NciParamW4HostSelect* select = NCI_PARAM_W4_HOST_SELECT(param);
- GSList* selected = NULL;
- guint i;
-
- /* Select a supported protocol */
- for (i = 0; i < select->count; i++) {
- NciDiscoveryNtf* ntf = select->ntf + i;
-
- if (nci_sm_supports_protocol(sm, ntf->protocol)) {
- selected = g_slist_insert_sorted(selected, ntf,
- nci_state_w4_host_select_sort);
- }
- }
-
- /*
- * We may want to store the list and selected the next protocol
- * if the best one gets rejected.
- */
- if (selected) {
- const NciDiscoveryNtf* ntf = selected->data;
- GBytes* payload;
-
- /*
- * Table 60: Control Messages to select a Discovered Target
- *
- * RF_DISCOVER_SELECT_CMD
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | RF Discovery ID |
- * | 1 | 1 | RF Protocol |
- * | 2 | 1 | RF Interface |
- * +=========================================================+
- */
- guint8 cmd[3];
- cmd[0] = ntf->discovery_id;
- cmd[1] = ntf->protocol;
- cmd[2] = (ntf->protocol == NCI_PROTOCOL_ISO_DEP) ?
- NCI_RF_INTERFACE_ISO_DEP :
- NCI_RF_INTERFACE_FRAME;
-
- GDEBUG("%c RF_DISCOVER_SELECT_CMD (0x%02x)", DIR_OUT,
- ntf->discovery_id);
- payload = g_bytes_new(cmd, sizeof(cmd));
- nci_sm_send_command(sm, NCI_GID_RF, NCI_OID_RF_DISCOVER_SELECT,
- payload, nci_state_w4_host_select_rsp, self);
- g_bytes_unref(payload);
- g_slist_free(selected);
- }
- }
-}
-
-static
-void
-nci_state_w4_host_select_handle_intf_activated_ntf(
- NciState* self,
- const GUtilData* payload)
-{
- NciIntfActivationNtf ntf;
- NciModeParam mode_param;
- NciActivationParam activation_param;
- NciSm* sm = nci_state_sm(self);
-
- /*
- * 5.2.4 State RFST_W4_HOST_SELECT
- *
- * ...
- * When the DH sends RF_DISCOVER_SELECT_CMD with a valid RF Discovery
- * ID, RF Protocol and RF Interface, the NFCC SHALL try to activate
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_transition.c
^
|
@@ -1,285 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_transition.h"
-#include "nci_transition_impl.h"
-#include "nci_state.h"
-#include "nci_sm.h"
-#include "nci_log.h"
-
-struct nci_transition_priv {
- NciSm* sm; /* Weak reference */
-};
-
-G_DEFINE_ABSTRACT_TYPE(NciTransition, nci_transition, G_TYPE_OBJECT)
-#define NCI_TRANSITION_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
- NCI_TYPE_TRANSITION, NciTransitionClass)
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciTransition*
-nci_transition_ref(
- NciTransition* self)
-{
- if (G_LIKELY(self)) {
- g_object_ref(NCI_TRANSITION(self));
- }
- return self;
-}
-
-void
-nci_transition_unref(
- NciTransition* self)
-{
- if (G_LIKELY(self)) {
- g_object_unref(NCI_TRANSITION(self));
- }
-}
-
-void
-nci_transition_init_base(
- NciTransition* self,
- NciSm* sm,
- NciState* dest)
-{
- NciTransitionPriv* priv = self->priv;
-
- self->dest = nci_state_ref(dest);
- priv->sm = sm;
- nci_sm_add_weak_pointer(&priv->sm);
-}
-
-NciSm*
-nci_transition_sm(
- NciTransition* self)
-{
- return G_LIKELY(self) ? self->priv->sm : NULL;
-}
-
-void
-nci_transition_stall(
- NciTransition* self,
- NCI_STALL stall)
-{
- nci_sm_stall(nci_transition_sm(self), stall);
-}
-
-gboolean
-nci_transition_active(
- NciTransition* self)
-{
- return nci_sm_active_transition(nci_transition_sm(self), self);
-}
-
-void
-nci_transition_finish(
- NciTransition* self,
- void* param)
-{
- if (G_LIKELY(self)) {
- nci_sm_enter_state(self->priv->sm, self->dest->state, param);
- }
-}
-
-gboolean
-nci_transition_start(
- NciTransition* self)
-{
- if (G_LIKELY(self)) {
- if (NCI_TRANSITION_GET_CLASS(self)->start(self)) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void
-nci_transition_finished(
- NciTransition* self)
-{
- if (G_LIKELY(self)) {
- NCI_TRANSITION_GET_CLASS(self)->finished(self);
- }
-}
-
-void
-nci_transition_handle_ntf(
- NciTransition* self,
- guint8 gid,
- guint8 oid,
- const GUtilData* payload)
-{
- if (G_LIKELY(self)) {
- NCI_TRANSITION_GET_CLASS(self)->handle_ntf(self, gid, oid, payload);
- }
-}
-
-gboolean
-nci_transition_send_command(
- NciTransition* self,
- guint8 gid,
- guint8 oid,
- GBytes* payload,
- NciTransitionResponseFunc resp)
-{
- return G_LIKELY(self) && nci_sm_send_command(self->priv->sm,
- gid, oid, payload, (NciSmResponseFunc)resp, self);
-}
-
-gboolean
-nci_transition_send_command_static(
- NciTransition* self,
- guint8 gid,
- guint8 oid,
- const void* payload,
- gsize payload_len,
- NciTransitionResponseFunc resp)
-{
- return G_LIKELY(self) && nci_sm_send_command_static(self->priv->sm,
- gid, oid, payload, payload_len, (NciSmResponseFunc)resp, self);
-}
-
-/*
- * Table 62: Control Messages for RF Interface Deactivation
- *
- * RF_DEACTIVATE_CMD
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Deactivation Type |
- * +=========================================================+
- */
-gboolean
-nci_transition_deactivate_to_idle(
- NciTransition* self,
- NciTransitionResponseFunc resp)
-{
- static const guint8 cmd[] = { NCI_DEACTIVATE_TYPE_IDLE };
-
- GDEBUG("%c RF_DEACTIVATE_CMD (Idle)", DIR_OUT);
- return nci_transition_send_command_static(self, NCI_GID_RF,
- NCI_OID_RF_DEACTIVATE, cmd, sizeof(cmd), resp);
-}
-
-gboolean
-nci_transition_deactivate_to_discovery(
- NciTransition* self,
- NciTransitionResponseFunc resp)
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_transition.h
^
|
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_TRANSITION_H
-#define NCI_TRANSITION_H
-
-#include "nci_types_p.h"
-
-#include <glib-object.h>
-
-/* State transition */
-
-typedef struct nci_transition_priv NciTransitionPriv;
-
-struct nci_transition {
- GObject object;
- NciTransitionPriv* priv;
- NciState* dest;
-};
-
-GType nci_transition_get_type(void);
-#define NCI_TYPE_TRANSITION (nci_transition_get_type())
-#define NCI_TRANSITION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- NCI_TYPE_TRANSITION, NciTransition))
-
-typedef
-void
-(*NciTransitionFunc)(
- NciTransition* transition,
- void* user_data);
-
-NciTransition*
-nci_transition_ref(
- NciTransition* transition);
-
-void
-nci_transition_unref(
- NciTransition* transition);
-
-gboolean
-nci_transition_start(
- NciTransition* self);
-
-void
-nci_transition_finished(
- NciTransition* self);
-
-void
-nci_transition_handle_ntf(
- NciTransition* transition,
- guint8 gid,
- guint8 oid,
- const GUtilData* payload);
-
-/* Specific transitions */
-
-NciTransition*
-nci_transition_reset_new(
- NciSm* sm);
-
-NciTransition*
-nci_transition_idle_to_discovery_new(
- NciSm* sm);
-
-NciTransition*
-nci_transition_deactivate_to_idle_new(
- NciSm* sm);
-
-NciTransition*
-nci_transition_poll_active_to_discovery_new(
- NciSm* sm);
-
-NciTransition*
-nci_transition_poll_active_to_idle_new(
- NciSm* sm);
-
-#endif /* NCI_TRANSITION_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_transition_deactivate_to_idle.c
^
|
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_transition.h"
-#include "nci_transition_impl.h"
-#include "nci_sm.h"
-#include "nci_log.h"
-
-/*==========================================================================*
- *
- * 5.2.2 State RFST_DISCOVERY
- * 5.2.3 State RFST_W4_ALL_DISCOVERIES
- * 5.2.4 State RFST_W4_HOST_SELECT
- *
- * ...
- *
- * If the DH sends RF_DEACTIVATE_CMD, the NFCC SHALL ignore the Deactivation
- * Type parameter, stop the RF Discovery Process, and send RF_DEACTIVATE_RSP.
- * The state will then change to RFST_IDLE.
- *
- *==========================================================================*/
-
-typedef NciTransition NciTransitionDeactivateToIdle;
-typedef NciTransitionClass NciTransitionDeactivateToIdleClass;
-
-G_DEFINE_TYPE(NciTransitionDeactivateToIdle, nci_transition_deactivate_to_idle,
- NCI_TYPE_TRANSITION)
-#define THIS_TYPE (nci_transition_deactivate_to_idle_get_type())
-#define PARENT_CLASS (nci_transition_deactivate_to_idle_parent_class)
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_transition_deactivate_to_idle_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* self)
-{
- if (status == NCI_REQUEST_CANCELLED || !nci_transition_active(self)) {
- GDEBUG("RF_DEACTIVATE cancelled");
- } else if (status == NCI_REQUEST_TIMEOUT) {
- GDEBUG("RF_DEACTIVATE timed out");
- nci_transition_stall(self, NCI_STALL_ERROR);
- } else {
- const guint8* pkt = payload->bytes;
- const guint len = payload->size;
-
- /*
- * Table 62: Control Messages for RF Interface Deactivation
- *
- * RF_DEACTIVATE_RSP
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Status |
- * +=========================================================+
- */
- if (len > 0 && pkt[0] == NCI_STATUS_OK) {
- GDEBUG("%c RF_DEACTIVATE_RSP ok", DIR_IN);
- nci_transition_finish(self, NULL);
- } else {
- if (len > 0) {
- GWARN("%c RF_DEACTIVATE_RSP error %u", DIR_IN, pkt[0]);
- } else {
- GWARN("%c Broken RF_DEACTIVATE_RSP", DIR_IN);
- }
- nci_transition_stall(self, NCI_STALL_ERROR);
- }
- }
-}
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciTransition*
-nci_transition_deactivate_to_idle_new(
- NciSm* sm)
-{
- NciState* dest = nci_sm_get_state(sm, NCI_RFST_IDLE);
-
- if (dest) {
- NciTransition* self = g_object_new(THIS_TYPE, NULL);
-
- nci_transition_init_base(self, sm, dest);
- return self;
- }
- return NULL;
-}
-
-/*==========================================================================*
- * Methods
- *==========================================================================*/
-
-static
-gboolean
-nci_transition_deactivate_to_idle_start(
- NciTransition* self)
-{
- return nci_transition_deactivate_to_idle(self,
- nci_transition_deactivate_to_idle_rsp);
-}
-
-/*==========================================================================*
- * Internals
- *==========================================================================*/
-
-static
-void
-nci_transition_deactivate_to_idle_init(
- NciTransitionDeactivateToIdle* self)
-{
-}
-
-static
-void
-nci_transition_deactivate_to_idle_class_init(
- NciTransitionDeactivateToIdleClass* klass)
-{
- klass->start = nci_transition_deactivate_to_idle_start;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_transition_idle_to_discovery.c
^
|
@@ -1,476 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_transition.h"
-#include "nci_transition_impl.h"
-#include "nci_sm.h"
-#include "nci_log.h"
-
-/*==========================================================================*
- * NCI_RFST_IDLE -> NCI_RFST_DISCOVERY transition
- *==========================================================================*/
-
-typedef NciTransition NciTransitionIdleToDiscovery;
-typedef NciTransitionClass NciTransitionIdleToDiscoveryClass;
-
-G_DEFINE_TYPE(NciTransitionIdleToDiscovery, nci_transition_idle_to_discovery,
- NCI_TYPE_TRANSITION)
-#define THIS_TYPE (nci_transition_idle_to_discovery_get_type())
-#define PARENT_CLASS (nci_transition_idle_to_discovery_parent_class)
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_transition_idle_to_discovery_discover_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* self)
-{
- if (status == NCI_REQUEST_CANCELLED || !nci_transition_active(self)) {
- GDEBUG("RF_DISCOVER_MAP cancelled");
- } else if (status == NCI_REQUEST_TIMEOUT) {
- GDEBUG("RF_DISCOVER_MAP timed out");
- nci_transition_stall(self, NCI_STALL_ERROR);
- } else {
- const guint8* pkt = payload->bytes;
- const guint len = payload->size;
-
- /*
- * Table 52: Control Messages to Start Discovery
- *
- * RF_DISCOVER_RSP
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Status |
- * +=========================================================+
- */
- if (len > 0 && pkt[0] == NCI_STATUS_OK) {
- GDEBUG("%c RF_DISCOVER_RSP ok", DIR_IN);
- nci_transition_finish(self, NULL);
- } else {
- if (len > 0) {
- GWARN("%c RF_DISCOVER_RSP error %u", DIR_IN, pkt[0]);
- } else {
- GWARN("%c Broken RF_DISCOVER_RSP", DIR_IN);
- }
- nci_transition_stall(self, NCI_STALL_ERROR);
- }
- }
-}
-
-static
-void
-nci_transition_idle_to_discovery_discover(
- NciTransition* self)
-{
- /*
- * Table 52: Control Messages to Start Discovery
- *
- * RF_DISCOVER_CMD
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Number of Configurations |
- * | 1 | 2*n | Configurations: |
- * | | +-----------------------------------------+
- * | | | 0 | RF Technology and Mode |
- * | | | 1 | Frequency (1 = every period) |
- * +=========================================================+
- */
- static const guint8 cmd[] = {
- 0x04,
- NCI_MODE_PASSIVE_POLL_A, 1,
- NCI_MODE_PASSIVE_POLL_B, 1,
- NCI_MODE_PASSIVE_POLL_F, 1,
- NCI_MODE_PASSIVE_POLL_15693, 1
- };
-
- GDEBUG("%c RF_DISCOVER_CMD", DIR_OUT);
- nci_transition_send_command_static(self, NCI_GID_RF, NCI_OID_RF_DISCOVER,
- cmd, sizeof(cmd), nci_transition_idle_to_discovery_discover_rsp);
-}
-
-static
-void
-nci_transition_idle_to_discover_map_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* self)
-{
- if (status == NCI_REQUEST_CANCELLED || !nci_transition_active(self)) {
- GDEBUG("RF_DISCOVER_MAP cancelled");
- } else if (status == NCI_REQUEST_TIMEOUT) {
- GDEBUG("RF_DISCOVER_MAP timed out");
- nci_transition_stall(self, NCI_STALL_ERROR);
- } else {
- const guint8* pkt = payload->bytes;
- const guint len = payload->size;
-
- /*
- * Table 42: Control Messages for RF Interface Mapping Configuration
- *
- * RF_DISCOVER_MAP_RSP
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Status |
- * +=========================================================+
- */
- if (len > 0 && pkt[0] == NCI_STATUS_OK) {
- GDEBUG("%c RF_DISCOVER_MAP_RSP ok", DIR_IN);
- nci_transition_idle_to_discovery_discover(self);
- } else {
- if (len > 0) {
- GWARN("%c RF_DISCOVER_MAP_RSP error %u", DIR_IN, pkt[0]);
- } else {
- GWARN("%c Broken RF_DISCOVER_MAP_RSP", DIR_IN);
- }
- nci_transition_stall(self, NCI_STALL_ERROR);
- }
- }
-}
-
-static
-gboolean
-nci_transition_idle_to_discover_map(
- NciTransition* self)
-{
- /*
- * Table 42: Control Messages for RF Interface Mapping Configuration
- *
- * RF_DISCOVER_MAP_CMD
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Number of Mapping Configurations (n) |
- * | 1 | 3*n | Mapping Configurations: |
- * | | +-----------------------------------------+
- * | | | 0 | RF Protocol |
- * | | | 1 | Mode |
- * | | | 2 | RF Interface |
- * +=========================================================+
- */
- static const guint8 cmd[] = {
- 0x05,
-
- NCI_PROTOCOL_T1T,
- NCI_DISCOVER_MAP_MODE_POLL,
- NCI_RF_INTERFACE_FRAME,
-
- NCI_PROTOCOL_T2T,
- NCI_DISCOVER_MAP_MODE_POLL,
- NCI_RF_INTERFACE_FRAME,
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_transition_impl.h
^
|
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_TRANSITION_IMPL_H
-#define NCI_TRANSITION_IMPL_H
-
-#include "nci_transition.h"
-
-/* Internal API for use by NciTransition implemenations */
-
-typedef struct nci_transition_class {
- GObjectClass parent;
- gboolean (*start)(NciTransition* self);
- void (*finished)(NciTransition* self);
- void (*handle_ntf)(NciTransition* self, guint8 gid, guint8 oid,
- const GUtilData* payload);
-} NciTransitionClass;
-
-#define NCI_TRANSITION_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), \
- NCI_TYPE_TRANSITION, NciTransitionClass)
-
-typedef
-void
-(*NciTransitionResponseFunc)(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* transition);
-
-void
-nci_transition_init_base(
- NciTransition* self,
- NciSm* sm,
- NciState* dest);
-
-NciSm*
-nci_transition_sm(
- NciTransition* self);
-
-void
-nci_transition_finish(
- NciTransition* self,
- void* param);
-
-void
-nci_transition_stall(
- NciTransition* self,
- NCI_STALL stall);
-
-gboolean
-nci_transition_active(
- NciTransition* self);
-
-gboolean
-nci_transition_send_command(
- NciTransition* self,
- guint8 gid,
- guint8 oid,
- GBytes* payload,
- NciTransitionResponseFunc resp);
-
-gboolean
-nci_transition_send_command_static(
- NciTransition* self,
- guint8 gid,
- guint8 oid,
- const void* payload,
- gsize payload_len,
- NciTransitionResponseFunc resp);
-
-gboolean
-nci_transition_deactivate_to_idle(
- NciTransition* self,
- NciTransitionResponseFunc resp);
-
-gboolean
-nci_transition_deactivate_to_discovery(
- NciTransition* self,
- NciTransitionResponseFunc resp);
-
-#endif /* NCI_TRANSITION_IMPL_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_transition_poll_active_to_discovery.c
^
|
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_transition.h"
-#include "nci_transition_impl.h"
-#include "nci_sm.h"
-#include "nci_log.h"
-
-/*==========================================================================*
- *
- * 5.2.5 State RFST_POLL_ACTIVE
- *
- * ...
- * If the DH sends RF_DEACTIVATE_CMD (Discovery), the NFCC SHALL send
- * RF_DEACTIVATE_RSP followed by RF_DEACTIVATE_NTF (Discovery, DH Request)
- * upon successful deactivation. The state will then change to RFST_DISCOVERY
- * where the NFCC SHALL either restart or continue the Polling discovery
- * activity.
- *
- *==========================================================================*/
-
-typedef NciTransition NciTransitionPollActiveToDiscovery;
-typedef NciTransitionClass NciTransitionPollActiveToDiscoveryClass;
-
-G_DEFINE_TYPE(NciTransitionPollActiveToDiscovery,
- nci_transition_poll_active_to_discovery, NCI_TYPE_TRANSITION)
-#define THIS_TYPE (nci_transition_poll_active_to_discovery_get_type())
-#define PARENT_CLASS (nci_transition_poll_active_to_discovery_parent_class)
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_transition_poll_active_to_discovery_idle_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* self)
-{
- if (status == NCI_REQUEST_CANCELLED || !nci_transition_active(self)) {
- GDEBUG("RF_DEACTIVATE (Idle) cancelled");
- return;
- } else if (status == NCI_REQUEST_TIMEOUT) {
- GDEBUG("RF_DEACTIVATE (Idle) timed out");
- } else if (status == NCI_REQUEST_SUCCESS) {
- const guint8* rsp = payload->bytes;
- const guint len = payload->size;
-
- if (len == 1 && rsp[0] == NCI_STATUS_OK) {
- GDEBUG("%c RF_DEACTIVATE_RSP (Idle) ok", DIR_IN);
- nci_sm_enter_state(nci_transition_sm(self), NCI_RFST_IDLE, NULL);
- return;
- } else if (len > 0) {
- GWARN("%c RF_DEACTIVATE_RSP (Idle) error %u", DIR_IN, rsp[0]);
- } else {
- GWARN("%c Broken RF_DEACTIVATE_RSP (Idle)", DIR_IN);
- }
- }
- nci_transition_stall(self, NCI_STALL_ERROR);
-}
-
-static
-void
-nci_transition_poll_active_to_discovery_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* self)
-{
- if (status == NCI_REQUEST_CANCELLED || !nci_transition_active(self)) {
- GDEBUG("RF_DEACTIVATE (Discovery) cancelled");
- } else if (status == NCI_REQUEST_TIMEOUT) {
- GDEBUG("RF_DEACTIVATE (Discovery) timed out");
- nci_transition_stall(self, NCI_STALL_ERROR);
- } else if (status == NCI_REQUEST_SUCCESS) {
- const guint8* rsp = payload->bytes;
- const guint len = payload->size;
-
- if (len == 1 && rsp[0] == NCI_STATUS_OK) {
- GDEBUG("%c RF_DEACTIVATE_RSP (Discovery) ok", DIR_IN);
- /* Wait for RF_DEACTIVATE_NTF */
- } else {
- /* Try to deactivate to IDLE */
- GWARN("RF_DEACTIVATE_CMD (Discovery) failed");
- nci_transition_deactivate_to_idle(self,
- nci_transition_poll_active_to_discovery_idle_rsp);
- }
- } else {
- nci_transition_stall(self, NCI_STALL_ERROR);
- }
-}
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciTransition*
-nci_transition_poll_active_to_discovery_new(
- NciSm* sm)
-{
- NciState* dest = nci_sm_get_state(sm, NCI_RFST_DISCOVERY);
-
- if (dest) {
- NciTransition* self = g_object_new(THIS_TYPE, NULL);
-
- nci_transition_init_base(self, sm, dest);
- return self;
- }
- return NULL;
-}
-
-/*==========================================================================*
- * Methods
- *==========================================================================*/
-
-static
-gboolean
-nci_transition_poll_active_to_discovery_start(
- NciTransition* self)
-{
- return nci_transition_deactivate_to_discovery(self,
- nci_transition_poll_active_to_discovery_rsp);
-}
-
-static
-void
-nci_transition_poll_active_to_discovery_handle_ntf(
- NciTransition* self,
- guint8 gid,
- guint8 oid,
- const GUtilData* payload)
-{
- switch (gid) {
- case NCI_GID_RF:
- switch (oid) {
- case NCI_OID_RF_DEACTIVATE:
- nci_sm_handle_rf_deactivate_ntf(nci_transition_sm(self), payload);
- return;
- }
- break;
- }
- NCI_TRANSITION_CLASS(PARENT_CLASS)->handle_ntf(self, gid, oid, payload);
-}
-
-/*==========================================================================*
- * Internals
- *==========================================================================*/
-
-static
-void
-nci_transition_poll_active_to_discovery_init(
- NciTransitionPollActiveToDiscovery* self)
-{
-}
-
-static
-void
-nci_transition_poll_active_to_discovery_class_init(
- NciTransitionPollActiveToDiscoveryClass* klass)
-{
- klass->start = nci_transition_poll_active_to_discovery_start;
- klass->handle_ntf = nci_transition_poll_active_to_discovery_handle_ntf;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_transition_poll_active_to_idle.c
^
|
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_transition.h"
-#include "nci_transition_impl.h"
-#include "nci_sm.h"
-#include "nci_log.h"
-
-/*==========================================================================*
- *
- * 5.2.5 State RFST_POLL_ACTIVE
- *
- * ...
- * If the DH sends RF_DEACTIVATE_CMD (Idle Mode), the NFCC SHALL send
- * RF_DEACTIVATE_RSP followed by RF_DEACTIVATE_NTF (Idle Mode, DH Request)
- * upon successful deactivation. The state will then change to RFST_IDLE.
- *
- *==========================================================================*/
-
-typedef NciTransition NciTransitionPollActiveToIdle;
-typedef NciTransitionClass NciTransitionPollActiveToIdleClass;
-
-G_DEFINE_TYPE(NciTransitionPollActiveToIdle,
- nci_transition_poll_active_to_idle, NCI_TYPE_TRANSITION)
-#define THIS_TYPE (nci_transition_poll_active_to_idle_get_type())
-#define PARENT_CLASS (nci_transition_poll_active_to_idle_parent_class)
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_transition_poll_active_to_idle_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* self)
-{
- if (status == NCI_REQUEST_CANCELLED || !nci_transition_active(self)) {
- GDEBUG("RF_DEACTIVATE (Idle) cancelled");
- } else if (status == NCI_REQUEST_TIMEOUT) {
- GDEBUG("RF_DEACTIVATE (Idle) timed out");
- nci_transition_stall(self, NCI_STALL_ERROR);
- } else if (status == NCI_REQUEST_SUCCESS) {
- const guint8* rsp = payload->bytes;
- const guint len = payload->size;
-
- if (len == 1 && rsp[0] == NCI_STATUS_OK) {
- GDEBUG("%c RF_DEACTIVATE_RSP (Idle) ok", DIR_IN);
- /* Wait for RF_DEACTIVATE_NTF */
- } else {
- if (len > 0) {
- GWARN("%c RF_DEACTIVATE_RSP (Idle) error %u", DIR_IN, rsp[0]);
- } else {
- GWARN("%c Broken RF_DEACTIVATE_RSP (Idle)", DIR_IN);
- }
- nci_transition_stall(self, NCI_STALL_ERROR);
- }
- }
-}
-
-/*==========================================================================*
- * Interface
- *==========================================================================*/
-
-NciTransition*
-nci_transition_poll_active_to_idle_new(
- NciSm* sm)
-{
- NciState* dest = nci_sm_get_state(sm, NCI_RFST_IDLE);
-
- if (dest) {
- NciTransition* self = g_object_new(THIS_TYPE, NULL);
-
- nci_transition_init_base(self, sm, dest);
- return self;
- }
- return NULL;
-}
-
-/*==========================================================================*
- * Methods
- *==========================================================================*/
-
-static
-void
-nci_transition_poll_active_to_idle_handle_ntf(
- NciTransition* self,
- guint8 gid,
- guint8 oid,
- const GUtilData* payload)
-{
- switch (gid) {
- case NCI_GID_RF:
- switch (oid) {
- case NCI_OID_RF_DEACTIVATE:
- nci_sm_handle_rf_deactivate_ntf(nci_transition_sm(self), payload);
- return;
- }
- break;
- }
- NCI_TRANSITION_CLASS(PARENT_CLASS)->handle_ntf(self, gid, oid, payload);
-}
-
-static
-gboolean
-nci_transition_poll_active_to_idle_start(
- NciTransition* self)
-{
- return nci_transition_deactivate_to_idle(self,
- nci_transition_poll_active_to_idle_rsp);
-}
-
-/*==========================================================================*
- * Internals
- *==========================================================================*/
-
-static
-void
-nci_transition_poll_active_to_idle_init(
- NciTransitionPollActiveToIdle* self)
-{
-}
-
-static
-void
-nci_transition_poll_active_to_idle_class_init(
- NciTransitionPollActiveToIdleClass* klass)
-{
- klass->start = nci_transition_poll_active_to_idle_start;
- klass->handle_ntf = nci_transition_poll_active_to_idle_handle_ntf;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_transition_reset.c
^
|
@@ -1,591 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_transition.h"
-#include "nci_transition_impl.h"
-#include "nci_sar.h"
-#include "nci_sm.h"
-#include "nci_log.h"
-
-typedef NciTransition NciTransitionReset;
-typedef NciTransitionClass NciTransitionResetClass;
-
-G_DEFINE_TYPE(NciTransitionReset, nci_transition_reset, NCI_TYPE_TRANSITION)
-#define THIS_TYPE (nci_transition_reset_get_type())
-#define PARENT_CLASS (nci_transition_reset_parent_class)
-
-/*==========================================================================*
- * Implementation
- *==========================================================================*/
-
-static
-void
-nci_transition_reset_set_config_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* self)
-{
- NciSm* sm = nci_transition_sm(self);
-
- if (status == NCI_REQUEST_CANCELLED || !nci_transition_active(self)) {
- GDEBUG("CORE_SET_CONFIG cancelled");
- return;
- } else if (status == NCI_REQUEST_TIMEOUT) {
- GDEBUG("CORE_SET_CONFIG timed out");
- } else if (sm) {
- /*
- * Table 10: Control Messages for Setting Configuration Parameters
- *
- * CORE_SET_CONFIG_RSP
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Status |
- * | 1 | 1 | The number of invalid Parameters (n) |
- * | 2 | n | Invalid parameters |
- * +=========================================================+
- */
- if (status == NCI_REQUEST_SUCCESS &&
- payload->size >= 2 &&
- payload->bytes[0] == NCI_STATUS_OK) {
- GDEBUG("%c CORE_SET_CONFIG_RSP ok", DIR_IN);
- } else {
- GWARN("CORE_SET_CONFIG_CMD failed (continuing anyway)");
- }
- nci_transition_finish(self, NULL);
- return;
- }
- nci_sm_stall(sm, NCI_STALL_ERROR);
-}
-
-static
-void
-nci_transition_reset_set_config(
- NciTransition* self)
-{
- /*
- * Table 10: Control Messages for Setting Configuration Parameters
- *
- * CORE_SET_CONFIG_CMD
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | The number of Parameter fields (n) |
- * | 1 | ... | Parameters * n |
- * | | +-----------------------------------------+
- * | | | ID | 1 | The identifier |
- * | | | Len | 1 | The length of Val (m) |
- * | | | Val | m | The value of the parameter |
- * +=========================================================+
- */
- static const guint8 cmd[] = {
- 2,
- NCI_CONFIG_PA_BAIL_OUT, 0x01, 0x00,
- NCI_CONFIG_PB_BAIL_OUT, 0x01, 0x00
- };
-
- GDEBUG("%c CORE_SET_CONFIG_CMD", DIR_OUT);
- nci_transition_send_command_static(self,
- NCI_GID_CORE, NCI_OID_CORE_SET_CONFIG, cmd, sizeof(cmd),
- nci_transition_reset_set_config_rsp);
-}
-
-static
-void
-nci_transition_reset_get_config_rsp(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- NciTransition* self)
-{
- NciSm* sm = nci_transition_sm(self);
-
- if (status == NCI_REQUEST_CANCELLED || !nci_transition_active(self)) {
- GDEBUG("CORE_GET_CONFIG cancelled");
- return;
- } else if (status == NCI_REQUEST_TIMEOUT) {
- GDEBUG("CORE_GET_CONFIG timed out");
- } else if (sm) {
- /*
- * Table 11: Control Messages for Reading Current Configuration
- *
- * CORE_GET_CONFIG_RSP
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | Status |
- * | 1 | 1 | The number of Parameters (n) |
- * | 2 | ... | Parameters |
- * | | +-----------------------------------------+
- * | | | ID | 1 | The identifier |
- * | | | Len | 1 | The length of Val (m) |
- * | | | Val | m | The value of the parameter |
- * +=========================================================+
- */
- if (status == NCI_REQUEST_SUCCESS && payload->size >= 2) {
- const guint8* pkt = payload->bytes;
- const guint len = payload->size;
- const guint n = pkt[1];
-
- if (pkt[0] == NCI_STATUS_OK) {
- GDEBUG("%c CORE_GET_CONFIG_RSP ok", DIR_IN);
- } else if (pkt[0] == NCI_STATUS_INVALID_PARAM && len >= 2 + n*2) {
-#if GUTIL_LOG_DEBUG
- /*
- * [NFCForum-TS-NCI-1.0]
- * 4.3.2 Retrieve the Configuration
- *
- * If the DH tries to retrieve any parameter(s) that
- * are not available in the NFCC, the NFCC SHALL respond
- * with a CORE_GET_CONFIG_RSP with a Status field of
- * STATUS_INVALID_PARAM, containing each unavailable
- * Parameter ID with a Parameter Len field of value zero.
- * In this case, the CORE_GET_CONFIG_RSP SHALL NOT include
- * any parameter(s) that are available on the NFCC.
- */
- if (GLOG_ENABLED(GLOG_LEVEL_DEBUG)) {
- GString* buf = g_string_new(NULL);
- guint i;
-
- for (i = 0; i < n; i++) {
- g_string_append_printf(buf, " %02x", pkt[2 + i*2]);
- }
- GDEBUG("%c CORE_GET_CONFIG_RSP invalid parameter(s):%s",
- DIR_IN, buf->str);
- g_string_free(buf, TRUE);
- }
-#endif
- } else {
- GWARN("CORE_GET_CONFIG_CMD error 0x%02x (continuing anyway)",
- payload->bytes[0]);
- }
- nci_transition_reset_set_config(self);
- return;
- } else {
- GWARN("CORE_GET_CONFIG_CMD failed (continuing anyway)");
- }
- }
- nci_sm_stall(sm, NCI_STALL_ERROR);
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_types_p.h
^
|
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_TYPES_PRIVATE_H
-#define NCI_TYPES_PRIVATE_H
-
-#include <nci_types.h>
-
-typedef struct nci_param NciParam;
-typedef struct nci_sar NciSar;
-typedef struct nci_sm NciSm;
-typedef struct nci_transition NciTransition;
-
-typedef enum nci_request_status {
- NCI_REQUEST_SUCCESS,
- NCI_REQUEST_TIMEOUT,
- NCI_REQUEST_CANCELLED
-} NCI_REQUEST_STATUS;
-
-typedef
-void
-(*NciSmResponseFunc)(
- NCI_REQUEST_STATUS status,
- const GUtilData* payload,
- gpointer user_data);
-
-/* Stall modes */
-typedef enum nci_stall {
- NCI_STALL_STOP,
- NCI_STALL_ERROR
-} NCI_STALL;
-
-/* Debug log */
-#define DIR_IN '>'
-#define DIR_OUT '<'
-
-/* Message Type (MT) */
-#define NCI_MT_MASK (0xe0)
-#define NCI_MT_DATA_PKT (0x00)
-#define NCI_MT_CMD_PKT (0x20)
-#define NCI_MT_RSP_PKT (0x40)
-#define NCI_MT_NTF_PKT (0x60)
-
-/* Packet Boundary Flag (PBF) */
-#define NCI_PBF (0x10)
-
-#endif /* NCI_TYPES_PRIVATE_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_util.c
^
|
@@ -1,540 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "nci_util.h"
-#include "nci_log.h"
-
-#include <gutil_macros.h>
-
-const NciModeParam*
-nci_parse_mode_param(
- NciModeParam* param,
- NCI_MODE mode,
- const guint8* bytes,
- guint len)
-{
- switch (mode) {
- case NCI_MODE_ACTIVE_POLL_A:
- case NCI_MODE_PASSIVE_POLL_A:
- /*
- * NFCForum-TS-NCI-1.0
- * Table 54: Specific Parameters for NFC-A Poll Mode
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 2 | SENS_RES Response |
- * | 2 | 1 | Length of NFCID1 Parameter (n) |
- * | 3 | n | NFCID1 (0, 4, 7, or 10 Octets) |
- * | 3 + n | 1 | SEL_RES Response Length (m) |
- * | 4 + n | m | SEL_RES Response (0 or 1 Octet) |
- * +=========================================================+
- */
- if (len >= 4) {
- NciModeParamPollA* ppa = ¶m->poll_a;
-
- memset(ppa, 0, sizeof(*ppa));
- ppa->sens_res[0] = bytes[0];
- ppa->sens_res[1] = bytes[1];
- ppa->nfcid1_len = bytes[2];
- if (ppa->nfcid1_len <= sizeof(ppa->nfcid1) &&
- len >= ppa->nfcid1_len + 4 &&
- len >= ppa->nfcid1_len + 4 +
- bytes[ppa->nfcid1_len + 3]) {
- memcpy(ppa->nfcid1, bytes + 3, ppa->nfcid1_len);
- ppa->sel_res_len = bytes[ppa->nfcid1_len + 3];
- if (ppa->sel_res_len) {
- ppa->sel_res = bytes[ppa->nfcid1_len + 4];
- }
-#if GUTIL_LOG_DEBUG
- if (GLOG_ENABLED(GLOG_LEVEL_DEBUG)) {
- GString* buf = g_string_new(NULL);
- guint i;
-
- for (i = 0; i < ppa->nfcid1_len; i++) {
- g_string_append_printf(buf, " %02x", ppa->nfcid1[i]);
- }
- GDEBUG("NFC-A");
- GDEBUG(" PollA.sel_res = 0x%02x", ppa->sel_res);
- GDEBUG(" PollA.nfcid1 =%s", buf->str);
- g_string_free(buf, TRUE);
- }
-#endif
- return param;
- }
- }
- GDEBUG("Failed to parse parameters for NFC-A poll mode");
- return NULL;
- case NCI_MODE_PASSIVE_POLL_B:
- /*
- * NFCForum-TS-NCI-1.0
- * Table 56: Specific Parameters for NFC-B Poll Mode
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | SENSB_RES Response Length n (11 or 12) |
- * | 1 | n | Bytes 2-12 or 13 or SENSB_RES Response |
- * +=========================================================+
- *
- * NFCForum-TS-DigitalProtocol-1.0
- * Table 25: SENSB_RES Format
- *
- * +=========================================================+
- * | Byte 1 | Byte 2-5 | Byte 6-9 | Byte 10-12 or 13 |
- * +=========================================================+
- * | 50h | NFCID0 | Application Data | Protocol Info |
- * +=========================================================+
- *
- * Table 27: Protocol Info Format
- *
- * +=========================================================+
- * | Byte 1 | 8 bits | Bit Rate Capability |
- * +--------+--------+---------------------------------------+
- * | Byte 2 | 4 bits | FSCI |
- * | | 4 bits | Protocol_Type |
- * +--------+--------+---------------------------------------+
- * | Byte 3 | 4 bits | FWI |
- * | | 2 bits | ADC |
- * | | 2 bits | FO |
- * +-------------------optional -----------------------------+
- * | Byte 4 | 4 bits | SFGI |
- * | | 4 bits | RFU |
- * +=========================================================+
- *
- * Table 29: FSCI to FSC Conversion
- * +=========================================================+
- * | FSCI | 0h 1h 2h 3h 4h 5h 6h 7h 8h 9h-Fh |
- * |-------------+-------------------------------------------+
- * | FSC (bytes) | 16 24 32 40 48 64 96 128 256 RFU |
- * +=========================================================+
- */
- if (len >= 1 && bytes[0] >= 11) {
- NciModeParamPollB* ppb = ¶m->poll_b;
- const guint fsci = (bytes[10] >> 4);
- static const guint fsc_table[] = {
- 16, 24, 32, 40, 48, 64, 96, 128, 256
- };
-
- memset(ppb, 0, sizeof(*ppb));
- memcpy(ppb->nfcid0, bytes + 1, 4);
- ppb->fsc = (fsci < G_N_ELEMENTS(fsc_table)) ?
- fsc_table[fsci] :
- fsc_table[G_N_ELEMENTS(fsc_table) - 1];
-
- GDEBUG("NFC-B");
- GDEBUG(" PollB.fsc = %u", ppb->fsc);
- GDEBUG(" PollB.nfcid0 = %02x %02x %02x %02x", ppb->nfcid0[0],
- ppb->nfcid0[1], ppb->nfcid0[2], ppb->nfcid0[3]);
- return param;
- }
- GDEBUG("Failed to parse parameters for NFC-B poll mode");
- return NULL;
- default:
- GDEBUG("Unhandled activation mode %d", mode);
- return NULL;
- }
-}
-
-gboolean
-nci_parse_discover_ntf(
- NciDiscoveryNtf* ntf,
- NciModeParam* param,
- const guint8* pkt,
- guint len)
-{
- /*
- * NFCForum-TS-NCI-1.0
- * Table 52: Control Messages to Start Discovery
- *
- * RF_DISCOVER_NTF
- *
- * +=========================================================+
- * | Offset | Size | Description |
- * +=========================================================+
- * | 0 | 1 | RF Discovery ID |
- * | 1 | 1 | RF Protocol |
- * | 2 | 1 | Activation RF Technology and Mode |
- * | 3 | 1 | Length of RF Technology Parameters (n) |
- * | 4 | n | RF Technology Specific Parameters |
- * | 4 + n | 1 | Notification Type |
- * | | |-----------------------------------------|
- * | | | 0 | Last Notification |
- * | | | 1 | Last Notification (limit reached) |
- * | | | 2 | More Notification to follow |
- * +=========================================================+
- */
- if (len >= 5) {
- const guint n = pkt[3];
-
- if (len >= 5 + n) {
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/nci/src/nci_util.h
^
|
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NCI_UTIL_H
-#define NCI_UTIL_H
-
-#include "nci_types_p.h"
-
-const NciModeParam*
-nci_parse_mode_param(
- NciModeParam* param,
- NCI_MODE mode,
- const guint8* bytes,
- guint len);
-
-gboolean
-nci_parse_discover_ntf(
- NciDiscoveryNtf* ntf,
- NciModeParam* param,
- const guint8* bytes,
- guint len);
-
-gboolean
-nci_parse_intf_activated_ntf(
- NciIntfActivationNtf* ntf,
- NciModeParam* mode_param,
- NciActivationParam* activation_param,
- const guint8* pkt,
- guint len);
-
-NciDiscoveryNtf*
-nci_discovery_ntf_copy_array(
- const NciDiscoveryNtf* const* ntfs,
- guint count);
-
-NciDiscoveryNtf*
-nci_discovery_ntf_copy(
- const NciDiscoveryNtf* ntf);
-
-#endif /* NCI_UTIL_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/src/binder_nfc_target.c
^
|
@@ -1,454 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "binder_nfc.h"
-
-#include <nci_core.h>
-
-#include <nfc_tag.h>
-#include <nfc_target_impl.h>
-
-#include <gbinder.h>
-
-#define T2T_CMD_READ (0x30)
-
-enum {
- EVENT_DATA_PACKET,
- EVENT_COUNT
-};
-
-typedef struct binder_nfc_target_presence_check {
- BinderNfcTargetPresenseCheckFunc done;
- void* user_data;
-} BinderNfcTargetPresenceCheck;
-
-typedef
-guint
-(*BinderNfcTargetPresenceCheckFunc)(
- BinderNfcTarget* self,
- BinderNfcTargetPresenceCheck* check);
-
-typedef NfcTargetClass BinderNfcTargetClass;
-struct binder_nfc_target {
- NfcTarget target;
- GBinderRemoteObject* remote;
- NciCore* nci;
- NCI_RF_INTERFACE rf_intf;
- gulong event_id[EVENT_COUNT];
- guint send_in_progress;
- gboolean transmit_in_progress;
- GBytes* pending_reply; /* Reply arrived before send has completed */
- BinderNfcTargetPresenceCheckFunc presence_check_fn;
-};
-
-G_DEFINE_TYPE(BinderNfcTarget, binder_nfc_target, NFC_TYPE_TARGET)
-
-static
-BinderNfcTargetPresenceCheck*
-binder_nfc_target_presence_check_new(
- BinderNfcTargetPresenseCheckFunc fn,
- void* user_data)
-{
- BinderNfcTargetPresenceCheck* check =
- g_slice_new(BinderNfcTargetPresenceCheck);
-
- check->done = fn;
- check->user_data = user_data;
- return check;
-}
-
-static
-void
-binder_nfc_target_presence_check_free(
- BinderNfcTargetPresenceCheck* check)
-{
- g_slice_free(BinderNfcTargetPresenceCheck, check);
-}
-
-static
-void
-binder_nfc_target_presence_check_free1(
- gpointer data)
-{
- binder_nfc_target_presence_check_free(data);
-}
-
-static
-void
-binder_nfc_target_cancel_send(
- BinderNfcTarget* self)
-{
- if (self->send_in_progress) {
- nci_core_cancel(self->nci, self->send_in_progress);
- self->send_in_progress = 0;
- if (self->pending_reply) {
- g_bytes_unref(self->pending_reply);
- self->pending_reply = NULL;
- }
- }
-}
-
-static
-void
-binder_nfc_target_drop_nci(
- BinderNfcTarget* self)
-{
- binder_nfc_target_cancel_send(self);
- nci_core_remove_all_handlers(self->nci, self->event_id);
- self->nci = NULL;
-}
-
-static
-void
-binder_nfc_target_finish_transmit(
- BinderNfcTarget* self,
- const guint8* payload,
- guint len)
-{
- NfcTarget* target = &self->target;
-
- self->transmit_in_progress = FALSE;
- if (len > 0) {
- if (self->rf_intf == NCI_RF_INTERFACE_FRAME) {
- const guint8 status = payload[len - 1];
-
- /*
- * 8.2 Frame RF Interface
- * 8.2.1.2 Data from RF to the DH
- */
- if (status == NCI_STATUS_OK) {
- nfc_target_transmit_done(target, NFC_TRANSMIT_STATUS_OK,
- payload, len - 1);
- return;
- }
- GDEBUG("Transmission status 0x%02x", status);
- } else if (self->rf_intf == NCI_RF_INTERFACE_ISO_DEP) {
- /*
- * 8.3 ISO-DEP RF Interface
- * 8.3.1.2 Data from RF to the DH
- */
- nfc_target_transmit_done(target, NFC_TRANSMIT_STATUS_OK,
- payload, len);
- return;
- }
- }
- nfc_target_transmit_done(target, NFC_TRANSMIT_STATUS_ERROR, NULL, 0);
-}
-
-static
-void
-binder_nfc_target_data_sent(
- NciCore* nci,
- gboolean success,
- void* user_data)
-{
- BinderNfcTarget* self = BINDER_NFC_TARGET(user_data);
-
- GASSERT(self->send_in_progress);
- self->send_in_progress = 0;
-
- if (self->pending_reply) {
- gsize len;
- GBytes* reply = self->pending_reply;
- const guint8* payload = g_bytes_get_data(reply, &len);
-
- /* We have been waiting for this send to complete */
- GDEBUG("Send completed");
- self->pending_reply = NULL;
- binder_nfc_target_finish_transmit(self, payload, len);
- g_bytes_unref(reply);
- }
-}
-
-static
-void
-binder_nfc_target_data_packet_handler(
- NciCore* nci,
- guint8 cid,
- const void* data,
- guint len,
- void* user_data)
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/Makefile
^
|
@@ -1,15 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-all:
-%:
- @$(MAKE) -C nci_core $*
- @$(MAKE) -C nci_sar $*
- @$(MAKE) -C nci_sm $*
- @$(MAKE) -C nci_util $*
-
-clean: unitclean
- rm -f *~
- rm -f common/*~
- rm -f coverage/*~
- rm -f coverage/*.gcov
- rm -fr coverage/report
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/common/Makefile
^
|
@@ -1,189 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-.PHONY: clean all debug release coverage
-.PHONY: debug_lib release_lib coverage_lib
-
-#
-# Real test makefile defines EXE (and possibly SRC) and includes this one.
-#
-
-ifndef EXE
-${error EXE not defined}
-endif
-
-SRC ?= $(EXE).c
-COMMON_SRC ?= test_main.c
-
-#
-# Required packages
-#
-
-PKGS += libglibutil glib-2.0 gobject-2.0
-
-#
-# Default target
-#
-
-all: debug release
-
-#
-# Directories
-#
-
-SRC_DIR = .
-LIB_DIR = ../../nci
-COMMON_DIR = ../common
-BUILD_DIR = build
-DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
-RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-COVERAGE_BUILD_DIR = $(BUILD_DIR)/coverage
-
-#
-# Tools and flags
-#
-
-CC = $(CROSS_COMPILE)gcc
-LD = $(CC)
-WARNINGS += -Wall
-INCLUDES += -I$(COMMON_DIR) -I$(LIB_DIR)/src -I$(LIB_DIR)/include
-BASE_FLAGS = -fPIC
-BASE_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS)
-BASE_CFLAGS = $(BASE_FLAGS) $(CFLAGS)
-FULL_CFLAGS = $(BASE_CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) -MMD -MP \
- $(shell pkg-config --cflags $(PKGS))
-FULL_LDFLAGS = $(BASE_LDFLAGS)
-LIBS = $(shell pkg-config --libs $(PKGS)) -ldl
-QUIET_MAKE = make --no-print-directory
-DEBUG_FLAGS = -g
-RELEASE_FLAGS =
-COVERAGE_FLAGS = -g
-
-DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
-COVERAGE_LDFLAGS = $(FULL_LDFLAGS) $(COVERAGE_FLAGS) --coverage
-
-DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
-RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
-COVERAGE_CFLAGS = $(FULL_CFLAGS) $(COVERAGE_FLAGS) --coverage
-
-DEBUG_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_debug_lib)
-RELEASE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_release_lib)
-COVERAGE_LIB_FILE := $(shell $(QUIET_MAKE) -C $(LIB_DIR) print_coverage_lib)
-
-DEBUG_LIB = $(LIB_DIR)/$(DEBUG_LIB_FILE)
-RELEASE_LIB = $(LIB_DIR)/$(RELEASE_LIB_FILE)
-COVERAGE_LIB = $(LIB_DIR)/$(COVERAGE_LIB_FILE)
-
-DEBUG_LIBS = $(DEBUG_LIB) $(LIBS)
-RELEASE_LIBS = $(RELEASE_LIB) $(LIBS)
-COVERAGE_LIBS = $(COVERAGE_LIB) $(LIBS)
-
-#
-# Files
-#
-
-DEBUG_OBJS = \
- $(COMMON_SRC:%.c=$(DEBUG_BUILD_DIR)/common_%.o) \
- $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = \
- $(COMMON_SRC:%.c=$(RELEASE_BUILD_DIR)/common_%.o) \
- $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
-COVERAGE_OBJS = \
- $(COMMON_SRC:%.c=$(COVERAGE_BUILD_DIR)/common_%.o) \
- $(SRC:%.c=$(COVERAGE_BUILD_DIR)/%.o)
-
-#
-# Dependencies
-#
-
-DEPS = $(DEBUG_OBJS:%.o=%.d) $(RELEASE_OBJS:%.o=%.d)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(DEPS)),)
--include $(DEPS)
-endif
-endif
-
-$(DEBUG_LIB): | debug_lib
-$(RELEASE_LIB): | release_lib
-$(COVERAGE_LIB): | coverage_lib
-
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
-
-#
-# Rules
-#
-
-DEBUG_EXE = $(DEBUG_BUILD_DIR)/$(EXE)
-RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
-COVERAGE_EXE = $(COVERAGE_BUILD_DIR)/$(EXE)
-
-debug: debug_lib $(DEBUG_EXE)
-
-release: release_lib $(RELEASE_EXE)
-
-coverage: coverage_lib $(COVERAGE_EXE)
-
-unitclean:
- rm -f *~
- rm -fr $(BUILD_DIR)
-
-clean: unitclean
-
-cleaner: unitclean
- @make -C $(LIB_DIR) clean
-
-test_banner:
- @echo "===========" $(EXE) "=========== "
-
-test: test_banner debug
- @LD_LIBRARY_PATH="$(LIB_DIR)/$(DEBUG_LIB_PATH)" $(DEBUG_EXE)
-
-valgrind: test_banner debug
- @LD_LIBRARY_PATH="$(LIB_DIR)/$(DEBUG_LIB_PATH)" G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no $(DEBUG_EXE)
-
-$(DEBUG_BUILD_DIR):
- mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- mkdir -p $@
-
-$(COVERAGE_BUILD_DIR):
- mkdir -p $@
-
-$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(COVERAGE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
- $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_BUILD_DIR)/common_%.o : $(COMMON_DIR)/%.c
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/common_%.o : $(COMMON_DIR)/%.c
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(COVERAGE_BUILD_DIR)/common_%.o : $(COMMON_DIR)/%.c
- $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_EXE): $(DEBUG_LIB) $(DEBUG_OBJS)
- $(LD) $(DEBUG_LDFLAGS) $(DEBUG_OBJS) $(DEBUG_LIBS) -o $@
-
-$(RELEASE_EXE): $(RELEASE_LIB) $(RELEASE_OBJS)
- $(LD) $(RELEASE_LDFLAGS) $(RELEASE_OBJS) $(RELEASE_LIBS) -o $@
-
-$(COVERAGE_EXE): $(COVERAG_LIB) $(COVERAGE_OBJS)
- $(LD) $(COVERAGE_LDFLAGS) $(COVERAGE_OBJS) $(COVERAGE_LIBS) -o $@
-
-debug_lib:
- $(MAKE) -C $(LIB_DIR) $@
-
-release_lib:
- $(MAKE) -C $(LIB_DIR) $@
-
-coverage_lib:
- $(MAKE) -C $(LIB_DIR) $@
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/common/test_common.h
^
|
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TEST_COMMON_H
-#define TEST_COMMON_H
-
-#include <gutil_types.h>
-
-#define TEST_FLAG_DEBUG (0x01)
-typedef struct test_opt {
- int flags;
-} TestOpt;
-
-/* Should be invoked after g_test_init */
-void
-test_init(
- TestOpt* opt,
- int argc,
- char* argv[]);
-
-/* Run loop with a timeout */
-void
-test_run(
- const TestOpt* opt,
- GMainLoop* loop);
-
-/* Quits the event loop on the next iteration (or after n iterations) */
-void
-test_quit_later(
- GMainLoop* loop);
-
-void
-test_quit_later_n(
- GMainLoop* loop,
- guint n);
-
-#define TEST_TIMEOUT_SEC (20)
-
-/* Helper macros */
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-# define TEST_INT16_BYTES(v) \
- (guint8)(v), (guint8)((v) >> 8)
-# define TEST_INT32_BYTES(v) \
- (guint8)(v), (guint8)((v) >> 8), \
- (guint8)((v) >> 16), (guint8)((v) >> 24)
-# define TEST_INT64_BYTES(v) \
- (guint8)(v), (guint8)((v) >> 8), \
- (guint8)((v) >> 16), (guint8)((v) >> 24), \
- (guint8)(((guint64)(v)) >> 32), (guint8)(((guint64)(v)) >> 40), \
- (guint8)(((guint64)(v)) >> 48), (guint8)(((guint64)(v)) >> 56)
-#elif G_BYTE_ORDER == G_BIG_ENDIAN
-# define TEST_INT16_BYTES(v) \
- (guint8)((v) >> 8), (guint8)(v)
-# define TEST_INT32_BYTES(v) \
- (guint8)((v) >> 24), (guint8)((v) >> 16), \
- (guint8)((v) >> 8), (guint8)(v)
-# define TEST_INT64_BYTES(v) \
- (guint8)(((guint64)(v)) >> 56), (guint8)(((guint64)(v)) >> 48), \
- (guint8)(((guint64)(v)) >> 40), (guint8)(((guint64)(v)) >> 32), \
- (guint8)((v) >> 24), (guint8)((v) >> 16), \
- (guint8)((v) >> 8), (guint8)(v)
-#else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
-#error unknown ENDIAN type
-#endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
-
-#define TEST_ARRAY_AND_COUNT(a) a, G_N_ELEMENTS(a)
-#define TEST_ARRAY_AND_SIZE(a) a, sizeof(a)
-#define TEST_BYTES_SET(b,d) ((b).bytes = (void*)(d), (b).size = sizeof(d))
-
-#endif /* TEST_COMMON_H */
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/common/test_main.c
^
|
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include <gutil_log.h>
-
-static
-gboolean
-test_timeout_expired(
- gpointer data)
-{
- g_assert(!"TIMEOUT");
- return G_SOURCE_REMOVE;
-}
-
-typedef struct test_quit_later_data{
- GMainLoop* loop;
- guint n;
-} TestQuitLaterData;
-
-static
-void
-test_quit_later_n_free(
- gpointer user_data)
-{
- TestQuitLaterData* data = user_data;
-
- g_main_loop_unref(data->loop);
- g_free(data);
-}
-
-static
-gboolean
-test_quit_later_n_func(
- gpointer user_data)
-{
- TestQuitLaterData* data = user_data;
-
- if (data->n > 0) {
- data->n--;
- return G_SOURCE_CONTINUE;
- } else {
- g_main_loop_quit(data->loop);
- return G_SOURCE_REMOVE;
- }
-}
-
-void
-test_quit_later_n(
- GMainLoop* loop,
- guint n)
-{
- TestQuitLaterData* data = g_new0(TestQuitLaterData, 1);
-
- data->loop = g_main_loop_ref(loop);
- data->n = n;
- g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, test_quit_later_n_func, data,
- test_quit_later_n_free);
-}
-
-void
-test_quit_later(
- GMainLoop* loop)
-{
- test_quit_later_n(loop, 0);
-}
-
-void
-test_run(
- const TestOpt* opt,
- GMainLoop* loop)
-{
- if (opt->flags & TEST_FLAG_DEBUG) {
- g_main_loop_run(loop);
- } else {
- const guint timeout_id = g_timeout_add_seconds(TEST_TIMEOUT_SEC,
- test_timeout_expired, NULL);
- g_main_loop_run(loop);
- g_source_remove(timeout_id);
- }
-}
-
-void
-test_init(
- TestOpt* opt,
- int argc,
- char* argv[])
-{
- const char* sep1;
- const char* sep2;
- int i;
-
- memset(opt, 0, sizeof(*opt));
- for (i=1; i<argc; i++) {
- const char* arg = argv[i];
- if (!strcmp(arg, "-d") || !strcmp(arg, "--debug")) {
- opt->flags |= TEST_FLAG_DEBUG;
- } else if (!strcmp(arg, "-v")) {
- GTestConfig* config = (GTestConfig*)g_test_config_vars;
- config->test_verbose = TRUE;
- } else {
- GWARN("Unsupported command line option %s", arg);
- }
- }
-
- /* Setup logging */
- sep1 = strrchr(argv[0], '/');
- sep2 = strrchr(argv[0], '\\');
- gutil_log_default.name = (sep1 && sep2) ? (MAX(sep1, sep2) + 1) :
- sep1 ? (sep1 + 1) : sep2 ? (sep2 + 1) : argv[0];
- gutil_log_default.level = g_test_verbose() ?
- GLOG_LEVEL_VERBOSE : GLOG_LEVEL_NONE;
- gutil_log_timestamp = FALSE;
-}
-
-/*
- * Local Variables:
- * mode: C
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/coverage/.gitignore
^
|
@@ -1,2 +0,0 @@
-report
-*.gcov
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/coverage/run
^
|
@@ -1,52 +0,0 @@
-#!/bin/bash
-#
-# This script requires lcov, dirname
-#
-
-TESTS="\
-nci_core \
-nci_sar \
-nci_sm \
-nci_util"
-
-function err() {
- echo "*** ERROR!" $1
- exit 1
-}
-
-# Check the required tools
-which lcov >> /dev/null || err "Please install lcov"
-which dirname >> /dev/null || err "Please install dirname"
-
-# LCOV 1.10 has branch coverage disabled per default
-# Previous versions didn't have the --rc option
-if [ ! -z "$(lcov --help | grep ' --rc ')" ] ; then
- LCOV_OPT="--rc lcov_branch_coverage=1"
- GENHTML_OPT="--branch-coverage"
-fi
-
-pushd `dirname $0` > /dev/null
-COV_DIR="$PWD"
-pushd .. > /dev/null
-TEST_DIR="$PWD"
-pushd .. > /dev/null
-TOP_DIR="$PWD"
-LIB_DIR="$TOP_DIR/nci"
-popd > /dev/null
-popd > /dev/null
-popd > /dev/null
-
-make -C "$TOP_DIR" clean
-for t in $TESTS ; do
- pushd "$TEST_DIR/$t"
- make -C "$TEST_DIR/$t" clean coverage || exit 1
- build/coverage/test_$t || exit 1
- popd
-done
-
-FULL_COV="$COV_DIR/full.gcov"
-LIB_COV="$COV_DIR/lib.gcov"
-rm -f "$FULL_COV" "$LIB_COV"
-lcov $LCOV_OPT -c -d "$LIB_DIR/build/coverage" -b "$LIB_DIR/src" -o "$FULL_COV" || exit 1
-lcov $LCOV_OPT -e "$FULL_COV" "$LIB_DIR/src/*" -o "$LIB_COV" || exit 1
-genhtml $GENHTML_OPT "$LIB_COV" -t "NCI core" --output-directory "$COV_DIR/report" || exit 1
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/nci_core/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_nci_core
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/nci_core/test_nci_core.c
^
|
@@ -1,2216 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "nci_core.h"
-#include "nci_hal.h"
-#include "nci_sm.h"
-
-#include <gutil_macros.h>
-#include <gutil_log.h>
-
-static TestOpt test_opt;
-
-#define TEST_TIMEOUT (20) /* seconds */
-#define TEST_DEFAULT_CMD_TIMEOUT (10000) /* milliseconds */
-
-static const guint8 CORE_RESET_RSP[] = {
- 0x40, 0x00, 0x03, 0x00, 0x10, 0x00
-};
-static const guint8 CORE_RESET_RSP_ERROR[] = {
- 0x40, 0x00, 0x03, 0x03, 0x10, 0x00
-};
-static const guint8 CORE_RESET_V2_RSP[] = {
- 0x40, 0x00, 0x01, 0x00
-};
-static const guint8 CORE_RESET_V2_NTF[] = {
- 0x60, 0x00, 0x1f, 0x02, 0x01, 0x20, 0x02, 0x1a,
- 0x04, 0x04, 0x01, 0x03, 0x63, 0x94, 0x02, 0x02,
- 0x00, 0x59, 0xc0, 0xc0, 0x1b, 0x59, 0xc0, 0x89,
- 0x7f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x42,
- 0x22, 0x01
-};
-static const guint8 CORE_RESET_RSP_BROKEN[] = {
- 0x40, 0x00, 0x02, 0x00, 0x00
-};
-static const guint8 CORE_INIT_RSP[] = {
- 0x40, 0x01, 0x19, 0x00, 0x03, 0x0e, 0x02, 0x00,
- 0x08, 0x00, 0x01, 0x02, 0x03, 0x80, 0x82, 0x83,
- 0x84, 0x02, 0x5c, 0x03, 0xff, 0x02, 0x00, 0x04,
- 0x41, 0x11, 0x01, 0x18
-};
-static const guint8 CORE_INIT_RSP_1[] = {
- 0x40, 0x01, 0x19, 0x00, 0x03, 0x0e, 0x02, 0x00,
- 0x08, 0x00, 0x01, 0x02, 0x03, 0x80, 0x82, 0x83,
- 0x84, 0x02, 0x5c, 0x03, 0xff, 0x02, 0x00, 0x04,
- 0x41, 0x11, 0x01, 0x1a
-};
-static const guint8 CORE_INIT_V2_RSP[] = {
- 0x40, 0x01, 0x18, 0x00, 0x1a, 0x7e, 0x06, 0x00,
- 0x02, 0x00, 0x02, 0xff, 0xff, 0x00, 0x0c, 0x01,
- 0x05, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x90, 0x00
-};
-static const guint8 CORE_INIT_V2_RSP_NO_PROTOCOL_ROUTING[] = {
- 0x40, 0x01, 0x18, 0x00, 0x1a, 0x7a, 0x06, 0x00,
- 0x02, 0x00, 0x02, 0xff, 0xff, 0x00, 0x0c, 0x01,
- 0x05, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x90, 0x00
-};
-static const guint8 CORE_INIT_V2_RSP_NO_TECHNOLOGY_ROUTING[] = {
- 0x40, 0x01, 0x18, 0x00, 0x1a, 0x7c, 0x06, 0x00,
- 0x02, 0x00, 0x02, 0xff, 0xff, 0x00, 0x0c, 0x01,
- 0x05, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x90, 0x00
-};
-static const guint8 CORE_INIT_V2_RSP_NO_ROUTING[] = {
- 0x40, 0x01, 0x18, 0x00, 0x1a, 0x70, 0x06, 0x00,
- 0x02, 0x00, 0x02, 0xff, 0xff, 0x00, 0x0c, 0x01,
- 0x05, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x90, 0x00
-};
-static const guint8 CORE_INIT_V2_RSP_ERROR[] = {
- 0x40, 0x01, 0x0e, 0x03, 0x1a, 0x7e, 0x06, 0x00,
- 0x02, 0x00, 0x02, 0xff, 0xff, 0x00, 0x0c, 0x01,
- 0x00
-};
-static const guint8 CORE_INIT_V2_RSP_BROKEN1[] = {
- 0x40, 0x01, 0x10, 0x00, 0x1a, 0x7e, 0x06, 0x00,
- 0x02, 0x00, 0x02, 0xff, 0xff, 0x00, 0x0c, 0x01,
- 0x05, 0x01, 0x00
-};
-static const guint8 CORE_INIT_V2_RSP_BROKEN2[] = {
- 0x40, 0x01, 0x01, 0x03
-};
-static const guint8 CORE_INIT_RSP_BROKEN[] = {
- 0x40, 0x01, 0x00
-};
-static const guint8 CORE_GET_CONFIG_RSP[] = {
- 0x40, 0x03, 0x0b, 0x00, 0x03, 0x08, 0x01, 0x00,
- 0x11, 0x01, 0x00, 0x22, 0x01, 0x00
-};
-static const guint8 CORE_GET_CONFIG_RSP_ERROR[] = {
- 0x40, 0x03, 0x02, 0x03, 0x00
-};
-static const guint8 CORE_GET_CONFIG_RSP_INVALID_PARAM[] = {
- 0x40, 0x03, 0x04, NCI_STATUS_INVALID_PARAM, 0x01, 0x11, 0x00
-};
-static const guint8 CORE_GET_CONFIG_BROKEN[] = {
- 0x40, 0x03, 0x00
-};
-static const guint8 CORE_SET_CONFIG_RSP[] = {
- 0x40, 0x02, 0x02, 0x00, 0x00
-};
-static const guint8 CORE_SET_CONFIG_RSP_ERROR[] = {
- 0x40, 0x02, 0x02, NCI_STATUS_REJECTED, 0x00
-};
-static const guint8 CORE_SET_CONFIG_RSP_INVALID_PARAM[] = {
- 0x40, 0x02, 0x03, NCI_STATUS_INVALID_PARAM, 0x01, 0x11
-};
-static const guint8 RF_SET_LISTEN_MODE_ROUTING_RSP[] = {
- 0x41, 0x01, 0x01, 0x00
-};
-static const guint8 RF_SET_LISTEN_MODE_ROUTING_RSP_ERROR[] = {
- 0x41, 0x01, 0x01, 0x01
-};
-static const guint8 RF_SET_LISTEN_MODE_ROUTING_RSP_BROKEN[] = {
- 0x41, 0x01, 0x00
-};
-static const guint8 RF_DISCOVER_MAP_RSP[] = {
- 0x41, 0x00, 0x01, 0x00
-};
-static const guint8 RF_DISCOVER_MAP_ERROR[] = {
- 0x41, 0x00, 0x01, 0x03
-};
-static const guint8 RF_DISCOVER_MAP_BROKEN[] = {
- 0x41, 0x00, 0x00
-};
-static const guint8 RF_DISCOVER_RSP[] = {
- 0x41, 0x03, 0x01, 0x00
-};
-static const guint8 RF_DISCOVER_RSP_ERROR[] = {
- 0x41, 0x03, 0x01, 0x03
-};
-static const guint8 RF_DISCOVER_RSP_BROKEN[] = {
- 0x41, 0x03, 0x00
-};
-static const guint8 RF_INTF_ACTIVATED_NTF_T2[] = {
- 0x61, 0x05, 0x17, 0x01, 0x01, 0x02, 0x00, 0xff,
- 0x01, 0x0c, 0x44, 0x00, 0x07, 0x04, 0x9b, 0xfb,
- 0x4a, 0xeb, 0x2b, 0x80, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00
-};
-static const guint8 RF_INTF_ACTIVATED_NTF_ISO_DEP[] = {
- 0x61, 0x05, 0x1f, 0x01, 0x02, 0x04, 0x00, 0xff,
- 0x01, 0x09, 0x04, 0x00, 0x04, 0x4f, 0x01, 0x74,
- 0x01, 0x01, 0x20, 0x00, 0x00, 0x00, 0x0b, 0x0a,
- 0x78, 0x80, 0x81, 0x02, 0x4b, 0x4f, 0x4e, 0x41,
- 0x14, 0x11
-};
-static const guint8 RF_INTF_ACTIVATED_NTF_T2_BROKEN1[] = {
- 0x61, 0x05, 0x05 /* Too short */, 0x01, 0x01, 0x02, 0x00, 0xff
-};
-static const guint8 RF_INTF_ACTIVATED_NTF_T2_BROKEN2[] = {
- 0x61, 0x05, 0x14 /* Still too short */, 0x01, 0x01, 0x02, 0x00, 0xff,
- 0x01, 0x0c, 0x44, 0x00, 0x07, 0x04, 0x9b, 0xfb,
- 0x4a, 0xeb, 0x2b, 0x80, 0x01, 0x00, 0x00
-};
-static const guint8 RF_INTF_ACTIVATED_NTF_T2_BROKEN3[] = {
- 0x61, 0x05, 0x0b, 0x01, 0x01, 0x02, 0x00, 0xff,
- 0x01, 0x00 /* Missing RF Tech Parameters */, 0x00, 0x00, 0x00, 0x00
-};
-static const guint8 RF_INTF_ACTIVATED_NTF_T4A[] = {
- 0x61, 0x05, 0x27, 0x01, 0x02, 0x04, 0x00, 0xff,
- 0x01, 0x09, 0x04, 0x00, 0x04, 0x37, 0xf4, 0x95,
- 0x95, 0x01, 0x20, 0x00, 0x00, 0x00, 0x13, 0x12,
- 0x78, 0x80, 0x72, 0x02, 0x80, 0x31, 0x80, 0x66,
- 0xb1, 0x84, 0x0c, 0x01, 0x6e, 0x01, 0x83, 0x00,
- 0x90, 0x00
-};
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/nci_sar/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_nci_sar
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/nci_sar/test_nci_sar.c
^
|
@@ -1,1485 +0,0 @@
-/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "nci_types_p.h"
-#include "nci_hal.h"
-#include "nci_sar.h"
-
-#include <gutil_macros.h>
-#include <gutil_log.h>
-
-static TestOpt test_opt;
-
-#define TEST_TIMEOUT (10) /* seconds */
-
-#define TEST_GID (0x01)
-#define TEST_OID (0x02)
-
-static
-gboolean
-test_timeout(
- gpointer loop)
-{
- g_assert(!"TIMEOUT");
- return G_SOURCE_REMOVE;
-}
-
-static
-guint
-test_setup_timeout(
- GMainLoop* loop)
-{
- if (!(test_opt.flags & TEST_FLAG_DEBUG)) {
- return g_timeout_add_seconds(TEST_TIMEOUT, test_timeout, loop);
- } else {
- return 0;
- }
-}
-
-static
-void
-test_bytes_unref(
- gpointer bytes)
-{
- g_bytes_unref(bytes);
-}
-
-static
-void
-test_client_unexpected_completion(
- NciSarClient* client,
- gboolean success,
- gpointer user_data)
-{
- g_assert(FALSE);
-}
-
-static
-void
-test_client_expect_success(
- NciSarClient* client,
- gboolean success,
- gpointer user_data)
-{
- g_assert(success);
-}
-
-static
-void
-test_client_expect_error(
- NciSarClient* client,
- gboolean success,
- gpointer user_data)
-{
- g_assert(!success);
-}
-
-static
-void
-test_sar_client_unexpected(
- NciSarClient* client)
-{
- g_assert(FALSE);
-}
-
-static
-void
-test_sar_client_unexpected_resp(
- NciSarClient* client,
- guint8 gid,
- guint8 oid,
- const void* payload,
- guint payload_len)
-{
- g_assert(FALSE);
-}
-
-static
-void
-test_sar_client_unexpected_data_packet(
- NciSarClient* client,
- guint8 cid,
- const void* payload,
- guint payload_len)
-{
- g_assert(FALSE);
-}
-
-/*==========================================================================*
- * Test HAL
- *==========================================================================*/
-
-static
-gboolean
-test_dummy_hal_io_start(
- NciHalIo* io,
- NciHalClient* client)
-{
- return FALSE;
-}
-
-static
-void
-test_dummy_hal_io_stop(
- NciHalIo* io)
-{
-}
-
-static
-gboolean
-test_dummy_hal_io_write(
- NciHalIo* io,
- const GUtilData* chunks,
- guint count,
- NciHalClientFunc complete)
-{
- return FALSE;
-}
-
-static
-void
-test_dummy_hal_io_cancel_write(
- NciHalIo* io)
-{
-}
-
-static const NciHalIoFunctions test_dummy_hal_io_fn = {
- .start = test_dummy_hal_io_start,
- .stop = test_dummy_hal_io_stop,
- .write = test_dummy_hal_io_write,
- .cancel_write = test_dummy_hal_io_cancel_write
-};
-
-static NciHalIo test_dummy_hal_io = {
- .fn = &test_dummy_hal_io_fn
-};
-
-/*==========================================================================*
- * Test HAL
- *==========================================================================*/
-
-typedef struct test_hal_io {
- NciHalIo io;
- GPtrArray* written;
- guint write_id;
- NciHalClient* sar;
- void* test_data;
-} TestHalIo;
-
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/nci_sm/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_nci_sm
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/nci_sm/test_nci_sm.c
^
|
@@ -1,578 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "nci_types_p.h"
-#include "nci_sm.h"
-#include "nci_state.h"
-#include "nci_state_p.h"
-#include "nci_state_impl.h"
-#include "nci_transition_impl.h"
-#include "nci_param_w4_all_discoveries.h"
-
-static TestOpt test_opt;
-
-static
-void
-test_count_cb(
- NciSm* sm,
- void* user_data)
-{
- (*((int*)user_data))++;
-}
-
-static
-void
-test_unreached_cb(
- NciSm* sm,
- void* user_data)
-{
- g_assert(FALSE);
-}
-
-/*==========================================================================*
- * Test state
- *==========================================================================*/
-
-typedef NciStateClass TestStateClass;
-typedef struct test_state {
- NciState state;
- int entered;
- int reentered;
- int left;
-} TestState;
-
-G_DEFINE_TYPE(TestState, test_state, NCI_TYPE_STATE)
-#define TEST_STATE_OBJ(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- TEST_TYPE_STATE, TestState))
-#define TEST_TYPE_STATE (test_state_get_type())
-#define TEST_STATE_PARENT (test_state_parent_class)
-#define TEST_STATE NCI_CORE_STATES
-#define INVALID_STATE (TEST_STATE + 1)
-
-static
-void
-test_state_enter(
- NciState* state,
- NciParam* param)
-{
- TEST_STATE_OBJ(state)->entered++;
- NCI_STATE_CLASS(test_state_parent_class)->enter(state, param);
-}
-
-static
-void
-test_state_reenter(
- NciState* state,
- NciParam* param)
-{
- TEST_STATE_OBJ(state)->reentered++;
- NCI_STATE_CLASS(test_state_parent_class)->reenter(state, param);
-}
-
-static
-void
-test_state_leave(
- NciState* state)
-{
- TEST_STATE_OBJ(state)->left++;
- NCI_STATE_CLASS(test_state_parent_class)->leave(state);
-}
-
-static
-void
-test_state_init(
- TestState* self)
-{
-}
-
-static
-void
-test_state_class_init(
- TestStateClass* klass)
-{
- klass->enter = test_state_enter;
- klass->reenter = test_state_reenter;
- klass->leave = test_state_leave;
-}
-
-TestState*
-test_state_new(
- NciSm* sm,
- NCI_STATE state,
- const char* name)
-{
- TestState* test = g_object_new(TEST_TYPE_STATE, NULL);
-
- nci_state_init_base(NCI_STATE(test), sm, state, name);
- return test;
-}
-
-/*==========================================================================*
- * Test transition
- *==========================================================================*/
-
-typedef NciTransitionClass TestTransitionClass;
-typedef struct test_transition {
- NciTransition transition;
- gboolean fail_start;
- int started;
- int finished;
-} TestTransition;
-
-G_DEFINE_TYPE(TestTransition, test_transition, NCI_TYPE_TRANSITION)
-#define TEST_TYPE_TRANSITION (test_transition_get_type())
-#define TEST_TRANSITION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- TEST_TYPE_TRANSITION, TestTransition))
-
-static
-gboolean
-test_transition_start(
- NciTransition* transition)
-{
- TestTransition* self = TEST_TRANSITION(transition);
-
- if (self->fail_start) {
- return NCI_TRANSITION_CLASS(test_transition_parent_class)->
- start(transition);
- } else {
- self->started++;
- nci_transition_finish(transition, NULL);
- return TRUE;
- }
-}
-
-static
-void
-test_transition_finished(
- NciTransition* transition)
-{
- TestTransition* self = TEST_TRANSITION(transition);
-
- self->finished++;
- NCI_TRANSITION_CLASS(test_transition_parent_class)->finished(transition);
-}
-
-static
-void
-test_transition_init(
- TestTransition* self)
-{
-}
-
-static
-void
-test_transition_class_init(
- TestTransitionClass* klass)
-{
- klass->start = test_transition_start;
- klass->finished = test_transition_finished;
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/nci_util/Makefile
^
|
@@ -1,5 +0,0 @@
-# -*- Mode: makefile-gmake -*-
-
-EXE = test_nci_util
-
-include ../common/Makefile
|
[-]
[+]
|
Deleted |
_service:tar_git:nfcd-binder-plugin-1.0.5.tar.bz2/unit/nci_util/test_nci_util.c
^
|
@@ -1,423 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
- *
- * You may use this file under the terms of BSD license as follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test_common.h"
-
-#include "nci_util.h"
-
-static TestOpt test_opt;
-
-/*==========================================================================*
- * null
- *==========================================================================*/
-
-static
-void
-test_null(
- void)
-{
- g_assert(!nci_discovery_ntf_copy_array(NULL, 0));
- g_assert(!nci_discovery_ntf_copy(NULL));
-}
-
-/*==========================================================================*
- * mode_param_ok
- *==========================================================================*/
-
-typedef struct test_mode_param_success_data {
- const char* name;
- NCI_MODE mode;
- GUtilData data;
- NciModeParam expected;
-} TestModeParamSuccessData;
-
-static
-void
-test_mode_param_success(
- gconstpointer user_data)
-{
- const TestModeParamSuccessData* test = user_data;
- NciModeParam param;
-
- memset(¶m, 0, sizeof(param));
- g_assert(nci_parse_mode_param(¶m, test->mode,
- test->data.bytes, test->data.size));
- g_assert(!memcmp(¶m, &test->expected, sizeof(param)));
-}
-
-
-static const guint8 mode_param_success_data_minimal[] =
- { 0x04, 0x00, 0x00, 0x00 };
-static const guint8 mode_param_success_data_full[] =
- { 0x04, 0x00, 0x04, 0x37, 0xf4, 0x95, 0x95, 0x01, 0x20 };
-static const guint8 mode_param_success_data_no_nfcid1[] =
- { 0x04, 0x00, 0x00, 0x01, 0x20 };
-static const guint8 mode_param_success_data_poll_b[] =
- { 0x0b, 0x65, 0xe6, 0x70, 0x15, 0xe1, 0xf3, 0x5e, 0x11, 0x77, 0x87, 0x95 };
-static const guint8 mode_param_success_data_poll_b_rfu[] =
- { 0x0b, 0x65, 0xe6, 0x70, 0x15, 0xe1, 0xf3, 0x5e, 0x11, 0x77, 0x97, 0x95 };
-static const TestModeParamSuccessData mode_param_success_tests[] = {
- {
- .name = "minimal",
- .mode = NCI_MODE_ACTIVE_POLL_A,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_success_data_minimal) },
- .expected = { .poll_a = { { 0x04, 0x00 } } }
- },{
- .name = "no_nfcid1",
- .mode = NCI_MODE_ACTIVE_POLL_A,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_success_data_no_nfcid1) },
- .expected = { .poll_a = { { 0x04, 0x00 }, 0, { 0 }, 1, 0x20 } }
- },{
- .name = "full",
- .mode = NCI_MODE_PASSIVE_POLL_A,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_success_data_full) },
- .expected = {
- .poll_a = { {0x04, 0x00}, 4, {0x37, 0xf4, 0x95, 0x95}, 1, 0x20 }
- }
- },{
- .name = "poll_b",
- .mode = NCI_MODE_PASSIVE_POLL_B,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_success_data_poll_b) },
- .expected = { .poll_b = { {0x65, 0xe6, 0x70, 0x15}, 256 } }
- },{
- .name = "poll_b_rfu", /* RFU part of FSCI to FSC conversion table */
- .mode = NCI_MODE_PASSIVE_POLL_B,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_success_data_poll_b_rfu) },
- .expected = { .poll_b = { {0x65, 0xe6, 0x70, 0x15}, 256 } }
- }
-};
-
-/*==========================================================================*
- * mode_param_fail
- *==========================================================================*/
-
-typedef struct test_mode_param_fail_data {
- const char* name;
- NCI_MODE mode;
- GUtilData data;
-} TestModeParamFailData;
-
-static
-void
-test_mode_param_fail(
- gconstpointer user_data)
-{
- const TestModeParamFailData* test = user_data;
- NciModeParam param;
-
- g_assert(!nci_parse_mode_param(¶m, test->mode,
- test->data.bytes, test->data.size));
-}
-
-static const guint8 mode_param_fail_data_too_short_1[] =
- { 0x00 };
-static const guint8 mode_param_fail_data_too_short_2[] =
- { 0x04, 0x00, 0x04, 0x37, 0xf4 };
-static const guint8 mode_param_fail_data_too_short_3[] =
- { 0x04, 0x00, 0x04, 0x37, 0xf4, 0x95, 0x95, 0x01 };
-static const guint8 mode_param_fail_data_too_long[] =
- { 0x04, 0x00, 0x0b /* exceeds max 10 */, 0x01, 0x02, 0x03,
- 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x01, 0x20 };
-static const guint8 mode_param_fail_pollb_data_too_short_1[] =
- { 0x0a, 0x65, 0xe6, 0x70, 0x15, 0xe1, 0xf3, 0x5e, 0x11, 0x77, 0x87 };
-static const TestModeParamFailData mode_param_fail_tests[] = {
- {
- .name = "unhandled_mode",
- .mode = NCI_MODE_PASSIVE_LISTEN_15693
- },{
- .name = "passive_poll_a_empty",
- .mode = NCI_MODE_PASSIVE_POLL_A,
- .data = { NULL, 0 }
- },{
- .name = "active_poll_a_empty",
- .mode = NCI_MODE_ACTIVE_POLL_A,
- .data = { NULL, 0 }
- },{
- .name = "too_short/poll_a",
- .mode = NCI_MODE_ACTIVE_POLL_A,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_fail_data_too_short_1) }
- },{
- .name = "too_short/poll_b",
- .mode = NCI_MODE_ACTIVE_POLL_A,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_fail_data_too_short_1) }
- },{
- .name = "too_short/2",
- .mode = NCI_MODE_ACTIVE_POLL_A,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_fail_data_too_short_2) }
- },{
- .name = "too_short/3",
- .mode = NCI_MODE_ACTIVE_POLL_A,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_fail_data_too_short_3) }
- },{
- .name = "too_long",
- .mode = NCI_MODE_ACTIVE_POLL_A,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_fail_data_too_long) }
- },{
- .name = "poll_b_empty",
- .mode = NCI_MODE_PASSIVE_POLL_B,
- .data = { NULL, 0 }
- },{
- .name = "poll_b_too_short",
- .mode = NCI_MODE_PASSIVE_POLL_B,
- .data = { TEST_ARRAY_AND_SIZE(mode_param_fail_pollb_data_too_short_1) }
- }
-};
-
-/*==========================================================================*
- * discover_success
- *==========================================================================*/
-
-typedef struct test_discover_success_data {
|
[-]
[+]
|
Changed |
_service:tar_git:nfcd-binder-plugin-1.1.1.tar.bz2/Makefile
^
|
@@ -1,13 +1,12 @@
# -*- Mode: makefile-gmake -*-
-.PHONY: clean all release
-.PHONY: nci_debug_lib nci_release_lib
+.PHONY: clean all debug release install
#
# Required packages
#
-LDPKGS = libgbinder libglibutil gobject-2.0 glib-2.0
+LDPKGS = libncicore libnciplugin libgbinder libglibutil gobject-2.0 glib-2.0
PKGS = $(LDPKGS) nfcd-plugin
#
@@ -26,23 +25,12 @@
LIB = $(LIB_SONAME)
#
-# libnfc-nci
-#
-
-NCI_LIB = libnci.a
-NCI_DIR = nci
-NCI_BUILD_DIR = $(NCI_DIR)/build
-NCI_DEBUG_LIB = $(NCI_BUILD_DIR)/debug/$(NCI_LIB)
-NCI_RELEASE_LIB = $(NCI_BUILD_DIR)/release/$(NCI_LIB)
-
-#
# Sources
#
SRC = \
binder_nfc_adapter.c \
- binder_nfc_plugin.c \
- binder_nfc_target.c
+ binder_nfc_plugin.c
#
# Directories
@@ -53,10 +41,6 @@
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release
-NCI_DIR = nci
-NCI_SRC_DIR = $(NCI_DIR)/src
-NCI_CFLAGS = -I$(NCI_SRC_DIR)
-
#
# Tools and flags
#
@@ -67,7 +51,7 @@
BASE_FLAGS = -fPIC -fvisibility=hidden
DEFINES = -DNFC_PLUGIN_EXTERNAL
FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) -MMD -MP \
- -I$(NCI_DIR)/include $(shell pkg-config --cflags $(PKGS))
+ $(shell pkg-config --cflags $(PKGS))
FULL_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS) -shared
DEBUG_FLAGS = -g
RELEASE_FLAGS =
@@ -86,19 +70,15 @@
RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
LIBS = $(shell pkg-config --libs $(LDPKGS))
-DEBUG_LIBS = $(NCI_DEBUG_LIB) $(LIBS)
-RELEASE_LIBS = $(NCI_RELEASE_LIB) $(LIBS)
+DEBUG_LIBS = $(LIBS)
+RELEASE_LIBS = $(LIBS)
#
# Files
#
-DEBUG_OBJS = \
- $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o) \
- $(NCI_SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
-RELEASE_OBJS = \
- $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o) \
- $(NCI_SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
+DEBUG_OBJS = $(SRC:%.c=$(DEBUG_BUILD_DIR)/%.o)
+RELEASE_OBJS = $(SRC:%.c=$(RELEASE_BUILD_DIR)/%.o)
#
# Dependencies
@@ -113,11 +93,9 @@
endif
endif
-DEBUG_DEPS = $(NCI_DEBUG_LIB)
-RELEASE_DEPS = $(NCI_RELEASE_LIB)
+DEBUG_DEPS =
+RELEASE_DEPS =
-$(NCI_DEBUG_LIB): | nci_debug_lib
-$(NCI_RELEASE_LIB): | nci_release_lib
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
@@ -128,21 +106,14 @@
DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
-debug: nci_debug_lib $(DEBUG_LIB)
+debug: $(DEBUG_LIB)
-release: nci_release_lib $(RELEASE_LIB)
+release: $(RELEASE_LIB)
clean:
- make -C $(NCI_DIR) clean
rm -f *~ rpm/*~ $(SRC_DIR)/*~
rm -fr $(BUILD_DIR)
-nci_debug_lib:
- make -C $(NCI_DIR) debug
-
-nci_release_lib:
- make -C $(NCI_DIR) release
-
$(DEBUG_BUILD_DIR):
mkdir -p $@
@@ -155,12 +126,6 @@
$(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(DEBUG_BUILD_DIR)/%.o : $(NCI_SRC_DIR)/%.c
- $(CC) -c $(NCI_CFLAGS) $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/%.o : $(NCI_SRC_DIR)/%.c
- $(CC) -c $(NCI_CFLAGS) $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
$(DEBUG_LIB): $(DEBUG_OBJS) $(DEBUG_DEPS)
$(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) $(DEBUG_LIBS) -o $@
|
[-]
[+]
|
Changed |
_service:tar_git:nfcd-binder-plugin-1.1.1.tar.bz2/src/binder_nfc.h
^
|
@@ -75,18 +75,6 @@
NfcAdapterFunc func,
void* user_data);
-NfcTarget*
-binder_nfc_target_new(
- GBinderRemoteObject* remote,
- const NciIntfActivationNtf* ntf,
- NciCore* nci);
-
-guint
-binder_nfc_target_presence_check(
- BinderNfcTarget* target,
- BinderNfcTargetPresenseCheckFunc fn,
- void* user_data);
-
#endif /* BINDER_NFC_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:nfcd-binder-plugin-1.1.1.tar.bz2/src/binder_nfc_adapter.c
^
|
@@ -32,18 +32,13 @@
#include "binder_nfc.h"
-#include <nfc_adapter_impl.h>
-#include <nfc_target_impl.h>
-#include <nfc_tag_t2.h>
-#include <nfc_tag_t4.h>
+#include <nci_adapter_impl.h>
#include <nci_core.h>
#include <nci_hal.h>
#include <gbinder.h>
-#include <gutil_idlequeue.h>
-#include <gutil_idlepool.h>
#include <gutil_misc.h>
#include <gutil_macros.h>
@@ -56,23 +51,8 @@
.flags = GLOG_FLAG_HIDE_NAME
};
-/* Idle queue tags */
-enum {
- IDLE_MODE_CHECK
-};
-
-/* NCI core events */
-enum {
- CORE_EVENT_CURRENT_STATE,
- CORE_EVENT_NEXT_STATE,
- CORE_EVENT_INTF_ACTIVATED,
- CORE_EVENT_COUNT
-};
-
-#define PRESENCE_CHECK_PERIOD_MS (250)
-
typedef struct binder_nfc_adapter BinderNfcAdapter;
-typedef NfcAdapterClass BinderNfcAdapterClass;
+typedef NciAdapterClass BinderNfcAdapterClass;
typedef
void
@@ -80,19 +60,14 @@
BinderNfcAdapter* self);
struct binder_nfc_adapter {
- NfcAdapter adapter;
+ NciAdapter adapter;
GBinderRemoteObject* remote;
GBinderClient* client;
GBinderLocalObject* callback;
- NciCore* nci;
- gulong nci_event_id[CORE_EVENT_COUNT];
NciHalIo hal_io;
NciHalClient* hal_client;
gulong nci_write_id;
- NfcTarget* target;
char* fqname;
- GUtilIdleQueue* idle;
- GUtilIdlePool* pool;
gboolean core_initialized;
gulong death_id;
@@ -102,19 +77,13 @@
gulong pending_tx;
BinderNfcAdapterFunc open_cplt;
BinderNfcAdapterFunc close_cplt;
-
- NFC_MODE desired_mode;
- NFC_MODE current_mode;
- gboolean mode_change_pending;
-
- guint presence_check_id;
- guint presence_check_timer;
};
-G_DEFINE_TYPE(BinderNfcAdapter, binder_nfc_adapter, NFC_TYPE_ADAPTER)
+G_DEFINE_TYPE(BinderNfcAdapter, binder_nfc_adapter, NCI_TYPE_ADAPTER)
#define BINDER_NFC_TYPE_ADAPTER (binder_nfc_adapter_get_type())
#define BINDER_NFC_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
BINDER_NFC_TYPE_ADAPTER, BinderNfcAdapter))
+#define SUPER_CLASS binder_nfc_adapter_parent_class
enum binder_nfc_adapter_signal {
SIGNAL_DEATH,
@@ -213,69 +182,6 @@
}
}
-static
-void
-binder_nfc_adapter_drop_target(
- BinderNfcAdapter* self)
-{
- NfcTarget* target = self->target;
-
- if (target) {
- self->target = NULL;
- if (self->presence_check_timer) {
- g_source_remove(self->presence_check_timer);
- self->presence_check_timer = 0;
- }
- if (self->presence_check_id) {
- nci_core_cancel(self->nci, self->presence_check_id);
- self->presence_check_id = 0;
- }
- GINFO("Target is gone");
- nfc_target_gone(target);
- nfc_target_unref(target);
- }
-}
-
-static
-void
-binder_nfc_adapter_presence_check_done(
- NfcTarget* target,
- gboolean ok,
- void* user_data)
-{
- BinderNfcAdapter* self = BINDER_NFC_ADAPTER(user_data);
-
- GDEBUG("Presence check %s", ok ? "ok" : "failed");
- self->presence_check_id = 0;
- if (!ok) {
- nci_core_set_state(self->nci, NCI_RFST_DISCOVERY);
- }
-}
-
-static
-gboolean
-binder_nfc_adapter_presence_check_timer(
- gpointer user_data)
-{
- BinderNfcAdapter* self = BINDER_NFC_ADAPTER(user_data);
-
- if (!self->presence_check_id && !self->target->sequence) {
- BinderNfcTarget* target = BINDER_NFC_TARGET(self->target);
-
- self->presence_check_id = binder_nfc_target_presence_check(target,
- binder_nfc_adapter_presence_check_done, self);
- if (!self->presence_check_id) {
- GDEBUG("Failed to start presence check");
- self->presence_check_timer = 0;
- nci_core_set_state(self->nci, NCI_RFST_DISCOVERY);
- return G_SOURCE_REMOVE;
- }
- } else {
- GDEBUG("Skipped presence check");
- }
- return G_SOURCE_CONTINUE;
-}
-
/*==========================================================================*
* INfcClientCallback
*==========================================================================*/
@@ -471,19 +377,21 @@
BinderNfcAdapter* self,
gboolean on)
{
+ NciCore* nci = self->adapter.nci;
+
if (self->power_switch_pending) {
self->power_switch_pending = FALSE;
self->power_on = on;
if (on) {
- nci_core_restart(self->nci);
+ nci_core_restart(nci);
}
- nfc_adapter_power_notify(&self->adapter, on, TRUE);
+ nfc_adapter_power_notify(NFC_ADAPTER(self), on, TRUE);
} else if (self->power_on != on) {
self->power_on = on;
if (on) {
- nci_core_restart(self->nci);
+ nci_core_restart(nci);
}
- nfc_adapter_power_notify(&self->adapter, on, FALSE);
+ nfc_adapter_power_notify(NFC_ADAPTER(self), on, FALSE);
}
}
@@ -492,7 +400,9 @@
binder_nfc_adapter_can_close(
BinderNfcAdapter* self)
{
- return (self->nci->current_state <= NCI_RFST_IDLE);
+ NciCore* nci = self->adapter.nci;
+
+ return (nci->current_state <= NCI_RFST_IDLE);
}
static
@@ -689,35 +599,6 @@
static
void
-binder_nfc_adapter_mode_check(
|