Fixed "Error: SVC is not permitted on this architecture" error on newer ARM compilers
[nrf5x-base-fork.git] / services / device_info_service.c
blob45c8614dda0e610cfada913573b44668536e2e15
1 /*
2 * Device Information Serivce
3 * https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.device_information.xml
4 */
6 // Standard Libraries
7 #include <stdint.h>
8 #include <stdbool.h>
9 #include <stdio.h>
10 #include <string.h>
12 // Nordic Libraries
13 #include "nordic_common.h"
14 #include "nrf.h"
15 #include "ble.h"
16 #include "app_error.h"
17 #include "ble_dis.h"
19 // Simple BLE Libraries
20 #include "simple_ble.h"
21 #include "device_info_service.h"
23 // for use by simple_ble
24 void simple_ble_device_info_service_automatic () {
25 // get hardware revision defined by makefile
26 char* hw_rev = NULL;
27 #if defined(HW_REVISION)
28 hw_rev = HW_REVISION;
29 #endif
31 // get firmware revision defined by makefile
32 char* fw_rev = NULL;
33 #if defined(FW_REVISION)
34 fw_rev = FW_REVISION;
35 #endif
37 // create device information service
38 simple_ble_device_info_service(hw_rev, fw_rev, NULL);
41 void simple_ble_device_info_service (char* hw_rev, char* fw_rev, char* sw_rev) {
42 uint32_t error_code;
43 ble_dis_init_t device_info = {0};
45 // It's not clear that we need to support:
46 // * Manufacturer Name
47 // * Model Number
48 // * Serial Number
50 // char* manuf_name, char* model_num, char* serial_num,
52 if (manuf_name != NULL) {
53 device_info.manufact_name_str.length = strlen(manuf_name);
54 device_info.manufact_name_str.p_str = (uint8_t*)manuf_name;
57 if (model_num != NULL) {
58 device_info.model_num_str.length = strlen(model_num);
59 device_info.model_num_str.p_str = (uint8_t*)model_num;
62 if (serial_num != NULL) {
63 device_info.serial_num_str.length = strlen(serial_num);
64 device_info.serial_num_str.p_str = (uint8_t*)serial_num;
68 // code and hardware revisions
69 if (hw_rev != NULL) {
70 device_info.hw_rev_str.length = strlen(hw_rev);
71 device_info.hw_rev_str.p_str = (uint8_t*)hw_rev;
73 if (fw_rev != NULL) {
74 device_info.fw_rev_str.length = strlen(fw_rev);
75 device_info.fw_rev_str.p_str = (uint8_t*)fw_rev;
77 if (sw_rev != NULL) {
78 device_info.sw_rev_str.length = strlen(sw_rev);
79 device_info.sw_rev_str.p_str = (uint8_t*)sw_rev;
82 // BLE address of the system
83 ble_dis_sys_id_t sys_id = {0};
84 sys_id.manufacturer_id = (0xFFFE << 24) | (0x30004f);
85 sys_id.organizationally_unique_id = 0xc098e5;
86 device_info.p_sys_id = &sys_id;
88 // read permission
89 device_info.dis_attr_md.read_perm.sm = 1;
90 device_info.dis_attr_md.read_perm.lv = 1;
92 // Create service
93 error_code = ble_dis_init(&device_info);
94 APP_ERROR_CHECK(error_code);