Exemple #1
0
					 void *buf, uint16_t len,
					 uint16_t offset)
{
	uint8_t value = ble_hrs_sensor_location;

	return bt_gatt_attr_read(conn, attr, buf, len, offset, &value,
				 sizeof(value));
}

/* HRS Service Declaration */
static const struct bt_gatt_attr hrs_attrs[] = {
	BT_GATT_PRIMARY_SERVICE(BT_UUID_HRS),
	/* Heart Rate Measurement */
	BT_GATT_CHARACTERISTIC(BT_UUID_HRS_MEASUREMENT, BT_GATT_CHRC_NOTIFY),
	BT_GATT_DESCRIPTOR(BT_UUID_HRS_MEASUREMENT, 0, NULL, NULL, NULL),
	BT_GATT_CCC(hrs_measurement_ccc_cfg, hrs_measurement_ccc_cfg_changed),

	/* Body Sensor Location */
	BT_GATT_CHARACTERISTIC(BT_UUID_HRS_BODY_SENSOR, BT_GATT_CHRC_READ),
	BT_GATT_DESCRIPTOR(BT_UUID_HRS_BODY_SENSOR, BT_GATT_PERM_READ,
			   read_body_sensor_location, NULL, NULL),
	BT_GATT_CCC(hrs_measurement_ccc_cfg, hrs_measurement_ccc_cfg_changed),
};

/* Pointer to the HRS value attribute in the above table */
static struct bt_gatt_attr const *const hrs_value = &hrs_attrs[2];

int ble_hrs_init(void)
{
	/* cast to discard the const qualifier */
	return bt_gatt_register((struct bt_gatt_attr *)hrs_attrs,
Exemple #2
0
		on_ble_rscs_enabled();
	} else {
		/* Stop running speed and cadence sensor */
		pr_debug(LOG_MODULE_BLE, "RSCS disabled");
		on_ble_rscs_disabled();
	}
}

/* RSC Service Declaration */
static const struct bt_gatt_attr rscs_attrs[] = {
	/* Running Speed and Cadence Service */
	BT_GATT_PRIMARY_SERVICE(BT_UUID_RSCS),
	/* RSC Measurement */
	BT_GATT_CHARACTERISTIC(BT_UUID_RSC_MEASUREMENT, BT_GATT_CHRC_NOTIFY),
	BT_GATT_DESCRIPTOR(BT_UUID_RSC_MEASUREMENT, 0, NULL, NULL, NULL),
	BT_GATT_CCC(rsc_measurement_ccc_cfg, rsc_measurement_ccc_cfg_changed),

	/* RSC Feature */
	BT_GATT_CHARACTERISTIC(BT_UUID_RSC_FEATURE, BT_GATT_CHRC_READ),
	BT_GATT_DESCRIPTOR(BT_UUID_RSC_FEATURE, BT_GATT_PERM_READ,
			   read_stepcadence_feature, NULL, NULL),

#ifdef CONFIG_BLE_RSCS_SENSOR_LOCATION_SUPPORT
	/* Sensor Location*/
	BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR_LOCATION, BT_GATT_CHRC_READ),
	BT_GATT_DESCRIPTOR(BT_UUID_SENSOR_LOCATION, BT_GATT_PERM_READ,
			   read_sensor_location, NULL, NULL),
#endif
};

static struct bt_gatt_attr const *const measurement_value = &rscs_attrs[2];
Exemple #3
0
			0xAA, 0x47, 0x02, 0x83, 0x18, 0xE9, 0xC9, 0x71);

/* Characteristic UUID of solar power 0609E802-AFD2-4D56-B61C-12BA1F80CCB6 */
static struct bt_uuid_128 solar_power_uuid = BT_UUID_INIT_128(
			0xB6, 0xCC, 0x80, 0x1F, 0xBA, 0x12, 0x1C, 0xB6,
			0x56, 0x4D, 0xD2, 0xAF, 0x02, 0xE8, 0x09, 0x06);

static struct bt_gatt_attr attrs[] = {
	BT_GATT_PRIMARY_SERVICE(&power_uuid),

	BT_GATT_CHARACTERISTIC(&consumption_power_uuid.uuid,
				BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY),
	BT_GATT_DESCRIPTOR(&consumption_power_uuid.uuid, BT_GATT_PERM_READ,
				read_u32, NULL, &consumption_value),
	BT_GATT_CUD(CONSUMPTION_CUD, BT_GATT_PERM_READ),
	BT_GATT_CCC(consumption_ccc_cfg, sensor_ccc_cfg_changed),

	BT_GATT_CHARACTERISTIC(&solar_power_uuid.uuid,
				BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY),
	BT_GATT_DESCRIPTOR(&solar_power_uuid.uuid, BT_GATT_PERM_READ,
				read_u32, NULL, &solar_value),
	BT_GATT_CUD(SOLAR_CUD, BT_GATT_PERM_READ),
	BT_GATT_CCC(solar_ccc_cfg, sensor_ccc_cfg_changed)
};

static void bt_ready(int err)
{
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return;
	}
Exemple #4
0
		return len;
	default:
		status = SC_CP_RSP_OP_NOT_SUPP;
	}

	ctrl_point_ind(conn, req->op, status, NULL, 0);

	return len;
}

static struct bt_gatt_attr csc_attrs[] = {
	BT_GATT_PRIMARY_SERVICE(BT_UUID_CSC),
	BT_GATT_CHARACTERISTIC(BT_UUID_CSC_MEASUREMENT, BT_GATT_CHRC_NOTIFY),
	BT_GATT_DESCRIPTOR(BT_UUID_CSC_MEASUREMENT, 0x00, NULL, NULL, NULL),
	BT_GATT_CCC(csc_meas_ccc_cfg, csc_meas_ccc_cfg_changed),
	BT_GATT_CHARACTERISTIC(BT_UUID_SENSOR_LOCATION, BT_GATT_CHRC_READ),
	BT_GATT_DESCRIPTOR(BT_UUID_SENSOR_LOCATION, BT_GATT_PERM_READ,
			   read_location, NULL, &sensor_location),
	BT_GATT_CHARACTERISTIC(BT_UUID_CSC_FEATURE, BT_GATT_CHRC_READ),
	BT_GATT_DESCRIPTOR(BT_UUID_CSC_FEATURE, BT_GATT_PERM_READ,
			   read_csc_feature, NULL, NULL),
	BT_GATT_CHARACTERISTIC(BT_UUID_SC_CONTROL_POINT,
			       BT_GATT_CHRC_WRITE | BT_GATT_CHRC_INDICATE),
	BT_GATT_DESCRIPTOR(BT_UUID_SC_CONTROL_POINT, BT_GATT_PERM_WRITE, NULL,
			   write_ctrl_point, &sensor_location),
	BT_GATT_CCC(ctrl_point_ccc_cfg, ctrl_point_ccc_cfg_changed),
};

struct sc_ctrl_point_ind {
	uint8_t op;
    pwm_write();

    return sizeof(rgb);
}

/* WebBT Service Declaration */
static struct bt_gatt_attr attrs[] = {
    BT_GATT_PRIMARY_SERVICE(BT_UUID_WEBBT),

    /* Temperature */
    BT_GATT_CHARACTERISTIC(BT_UUID_TEMP,
        BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY),
    BT_GATT_DESCRIPTOR(BT_UUID_TEMP, BT_GATT_PERM_READ,
        read_temperature, NULL, &temperature),
    BT_GATT_CUD(SENSOR_1_NAME, BT_GATT_PERM_READ),
    BT_GATT_CCC(blvl_ccc_cfg, blvl_ccc_cfg_changed),

    /* RGB Led */
    BT_GATT_CHARACTERISTIC(BT_UUID_RGB,
        BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE),
    BT_GATT_DESCRIPTOR(BT_UUID_RGB, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
        read_rgb, write_rgb, rgb),
    BT_GATT_CUD(SENSOR_2_NAME, BT_GATT_PERM_READ),
};

void temperature_ipm_callback(void *context, uint32_t id, volatile void *data)
{
    struct bt_conn *conn = (struct bt_conn *) context;

    switch(id) {
      case 1:
Exemple #6
0
static const struct bt_uuid_128 vnd_signed_uuid = BT_UUID_INIT_128(
	0xf3, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x13,
	0x78, 0x56, 0x34, 0x12, 0x78, 0x56, 0x34, 0x13);

/* Vendor Primary Service Declaration */
static struct bt_gatt_attr vnd_attrs[] = {
	/* Vendor Primary Service Declaration */
	BT_GATT_PRIMARY_SERVICE(&vnd_uuid),
	BT_GATT_CHARACTERISTIC(&vnd_enc_uuid.uuid,
			       BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE |
			       BT_GATT_CHRC_INDICATE),
	BT_GATT_DESCRIPTOR(&vnd_enc_uuid.uuid,
			   BT_GATT_PERM_READ_ENCRYPT |
			   BT_GATT_PERM_WRITE_ENCRYPT,
			   read_vnd, write_vnd, vnd_value),
	BT_GATT_CCC(vnd_ccc_cfg, vnd_ccc_cfg_changed),
	BT_GATT_CHARACTERISTIC(&vnd_auth_uuid.uuid,
			       BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE),
	BT_GATT_DESCRIPTOR(&vnd_auth_uuid.uuid,
			   BT_GATT_PERM_READ_AUTHEN |
			   BT_GATT_PERM_WRITE_AUTHEN,
			   read_vnd, write_vnd, vnd_value),
	BT_GATT_CHARACTERISTIC(&vnd_long_uuid.uuid, BT_GATT_CHRC_READ |
			       BT_GATT_CHRC_WRITE | BT_GATT_CHRC_EXT_PROP),
	BT_GATT_DESCRIPTOR(&vnd_long_uuid.uuid,
			   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
			   read_long_vnd, write_long_vnd, &vnd_long_value),
	BT_GATT_CEP(&vnd_long_cep),
	BT_GATT_CHARACTERISTIC(&vnd_signed_uuid.uuid, BT_GATT_CHRC_READ |
			       BT_GATT_CHRC_WRITE | BT_GATT_CHRC_AUTH),
	BT_GATT_DESCRIPTOR(&vnd_signed_uuid.uuid,
Exemple #7
0
	const uint32_t *u32 = attr->user_data;
	uint32_t value = sys_cpu_to_le32(*u32);

	return bt_gatt_attr_read(conn, attr, buf, len, offset, &value,
				 sizeof(value));
}

static struct bt_gatt_attr attrs[] = {
	BT_GATT_PRIMARY_SERVICE(BT_UUID_ESS),

	BT_GATT_CHARACTERISTIC(BT_UUID_TEMPERATURE,
				BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY),
	BT_GATT_DESCRIPTOR(BT_UUID_TEMPERATURE, BT_GATT_PERM_READ,
				read_u16, NULL, &temp_value),
	BT_GATT_CUD(TEMPERATURE_CUD, BT_GATT_PERM_READ),
	BT_GATT_CCC(temp_ccc_cfg, sensor_ccc_cfg_changed),

	BT_GATT_CHARACTERISTIC(BT_UUID_HUMIDITY,
				BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY),
	BT_GATT_DESCRIPTOR(BT_UUID_HUMIDITY, BT_GATT_PERM_READ,
				read_u16, NULL, &humidity_value),
	BT_GATT_CUD(HUMIDITY_CUD, BT_GATT_PERM_READ),
	BT_GATT_CCC(humidity_ccc_cfg, sensor_ccc_cfg_changed),

	BT_GATT_CHARACTERISTIC(BT_UUID_PRESSURE,
				BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY),
	BT_GATT_DESCRIPTOR(BT_UUID_PRESSURE, BT_GATT_PERM_READ,
				read_u32, NULL, &pressure_value),
	BT_GATT_CUD(PRESSURE_CUD, BT_GATT_PERM_READ),
	BT_GATT_CCC(pressure_ccc_cfg, sensor_ccc_cfg_changed),