iot 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/iot +81 -0
- data/iot.gemspec +23 -0
- data/lib/iot.rb +34 -0
- data/lib/iot/bleyamlparser.rb +43 -0
- data/lib/iot/characteristic.rb +27 -0
- data/lib/iot/destroy.rb +69 -0
- data/lib/iot/devicename.rb +46 -0
- data/lib/iot/generate.rb +137 -0
- data/lib/iot/help.rb +26 -0
- data/lib/iot/install.rb +93 -0
- data/lib/iot/mkhex.rb +14 -0
- data/lib/iot/new.rb +62 -0
- data/lib/iot/new/bleyaml.rb +11 -0
- data/lib/iot/new/main.rb +54 -0
- data/lib/iot/new/makefile.rb +159 -0
- data/lib/iot/new/stbledevice.rb +83 -0
- data/lib/iot/new/stdeviceinfo.rb +6 -0
- data/lib/iot/new/stservice.rb +118 -0
- data/lib/iot/run.rb +158 -0
- data/lib/iot/service.rb +20 -0
- data/lib/iot/stats.rb +10 -0
- data/lib/iot/version.rb +3 -0
- metadata +101 -0
data/lib/iot/help.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
IOT_HELP = <<-EOS
|
2
|
+
Example usage:
|
3
|
+
iot install
|
4
|
+
iot uninstall
|
5
|
+
iot new app_path
|
6
|
+
iot generate
|
7
|
+
|
8
|
+
Troubleshooting:
|
9
|
+
iot doctor
|
10
|
+
iot version
|
11
|
+
EOS
|
12
|
+
|
13
|
+
module Iot
|
14
|
+
module Help
|
15
|
+
def help
|
16
|
+
puts IOT_HELP
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# NOTE Keep the lenth of vanilla --help less than 25 lines!
|
22
|
+
# This is because the default Terminal height is 25 lines. Scrolling sucks
|
23
|
+
# and concision is important. If more help is needed we should start
|
24
|
+
# specialising help like the gem command does.
|
25
|
+
# NOTE Keep lines less than 80 characters! Wrapping is just not cricket.
|
26
|
+
# NOTE The reason the string is at the top is so 25 lines is easy to measure!
|
data/lib/iot/install.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require "FileUtils"
|
2
|
+
require "open3"
|
3
|
+
|
4
|
+
StroboPath = File.expand_path "/usr/local/strobo"
|
5
|
+
|
6
|
+
ArmGccLink = "https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-mac.tar.bz2"
|
7
|
+
ArmGccTarPath = File.expand_path "#{StroboPath}/#{ File.basename ArmGccLink }"
|
8
|
+
ArmGccPath = "#{StroboPath}/gcc-arm-none-eabi-4_9-2014q4"
|
9
|
+
|
10
|
+
Mbed_Dev_Url = "http://developer.mbed.org/"
|
11
|
+
Mbed_Ble_Api_Link = "#{Mbed_Dev_Url}teams/Bluetooth-Low-Energy/code/BLE_API/archive/fb2a891a0d98.zip"
|
12
|
+
Mbed_Nrf51822_Link = "#{Mbed_Dev_Url}teams/Nordic-Semiconductor/code/nRF51822/archive/17fe69405098.zip"
|
13
|
+
Mbed_Mbed_Link = "#{Mbed_Dev_Url}users/mbed_official/code/mbed/archive/4fc01daae5a5.zip"
|
14
|
+
|
15
|
+
|
16
|
+
# Install packages for offline compile
|
17
|
+
module Iot
|
18
|
+
module Install
|
19
|
+
|
20
|
+
def uninstall
|
21
|
+
executeOut, _, _ = *Open3.capture3("rm -rf #{StroboPath}")
|
22
|
+
puts "rm -rf #{StroboPath}/*"
|
23
|
+
end
|
24
|
+
|
25
|
+
def installComponents
|
26
|
+
make_strobo_dir
|
27
|
+
|
28
|
+
# Install mbed Libraries:
|
29
|
+
# mbed, BLE_API, nrf51822
|
30
|
+
zip_links = [
|
31
|
+
Mbed_Ble_Api_Link,
|
32
|
+
Mbed_Nrf51822_Link,
|
33
|
+
Mbed_Mbed_Link
|
34
|
+
]
|
35
|
+
zip_links.each do |zip_link|
|
36
|
+
get_lib_zip zip_link
|
37
|
+
end
|
38
|
+
|
39
|
+
get_gcc_arm
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# Create strobo directory.
|
45
|
+
# Check existing of /usr/local/strobo before creating
|
46
|
+
def make_strobo_dir
|
47
|
+
if File.exist? StroboPath
|
48
|
+
puts "already exist #{StroboPath}"
|
49
|
+
else
|
50
|
+
puts "create #{StroboPath}"
|
51
|
+
Dir.mkdir StroboPath
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Install Arm-GCC
|
56
|
+
# see here: https://launchpad.net/gcc-arm-embedded
|
57
|
+
def get_gcc_arm
|
58
|
+
if File.exist? ArmGccPath
|
59
|
+
puts "already exist #{ArmGccPath}"
|
60
|
+
return
|
61
|
+
elsif File.exist? ArmGccTarPath
|
62
|
+
`rm #{ArmGccTarPath}`
|
63
|
+
end
|
64
|
+
|
65
|
+
cmd = "wget #{ArmGccLink} -P #{StroboPath}"
|
66
|
+
puts cmd
|
67
|
+
`#{cmd}`
|
68
|
+
|
69
|
+
cmd = "tar zxvf #{ ArmGccTarPath } -C #{StroboPath}"
|
70
|
+
puts cmd
|
71
|
+
executeOut, _, _ = *Open3.capture3(cmd)
|
72
|
+
|
73
|
+
`rm #{ArmGccTarPath}`
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_lib_zip lib_path
|
77
|
+
cmd = "wget #{lib_path} -P #{StroboPath}"
|
78
|
+
puts cmd
|
79
|
+
`#{cmd}`
|
80
|
+
|
81
|
+
cmd = []
|
82
|
+
cmd << "unzip #{StroboPath}/*.zip -d #{StroboPath}"
|
83
|
+
cmd << "rm #{StroboPath}/*.zip"
|
84
|
+
cmd << "mv #{StroboPath}/nRF51822* #{StroboPath}/nRF51822"
|
85
|
+
cmd << "mv #{StroboPath}/mbed* #{StroboPath}/mbed"
|
86
|
+
cmd << "mv #{StroboPath}/BLE_API* #{StroboPath}/BLE_API"
|
87
|
+
cmd.each do |temp|
|
88
|
+
execute_out, _, _ = *Open3.capture3(temp)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
data/lib/iot/mkhex.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Iot
|
2
|
+
module Mkhex
|
3
|
+
def mkhex(softdevicehex_path, projecthex_path)
|
4
|
+
str = File.read softdevicehex_path
|
5
|
+
str.gsub!(":00000001FF", "")
|
6
|
+
str.chomp!
|
7
|
+
|
8
|
+
str << "\n"
|
9
|
+
str << File.read(projecthex_path)
|
10
|
+
|
11
|
+
File.write("combined.hex", str)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/iot/new.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require "FileUtils"
|
2
|
+
require "open3"
|
3
|
+
|
4
|
+
# Template files
|
5
|
+
require "iot/new/main"
|
6
|
+
require "iot/new/makefile"
|
7
|
+
require "iot/new/stservice"
|
8
|
+
require "iot/new/stbledevice"
|
9
|
+
require "iot/new/stdeviceinfo"
|
10
|
+
require "iot/new/bleyaml"
|
11
|
+
|
12
|
+
Iot_dir = "iot"
|
13
|
+
|
14
|
+
module Iot
|
15
|
+
module New
|
16
|
+
def new project_path
|
17
|
+
|
18
|
+
if project_path.empty?
|
19
|
+
puts "No value provided for required arguments 'app_path'"
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
if File.exist? project_path
|
24
|
+
puts "#{project_path} already exists"
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
project_path = File.expand_path project_path
|
29
|
+
|
30
|
+
|
31
|
+
Dir.mkdir project_path
|
32
|
+
Dir.mkdir "#{project_path}/#{Iot_dir}"
|
33
|
+
|
34
|
+
init_files = [
|
35
|
+
"Makefile",
|
36
|
+
"main.cpp",
|
37
|
+
"ble.yml",
|
38
|
+
"#{Iot_dir}/STService.h",
|
39
|
+
"#{Iot_dir}/STBLEdevice.h",
|
40
|
+
"#{Iot_dir}/STDeviceInfo.h"
|
41
|
+
]
|
42
|
+
|
43
|
+
template_files = [
|
44
|
+
Template_makefile,
|
45
|
+
Template_main,
|
46
|
+
Template_bleyaml,
|
47
|
+
Template_stservice,
|
48
|
+
Template_stbledevice,
|
49
|
+
Template_stdeviceinfo
|
50
|
+
]
|
51
|
+
|
52
|
+
count = 0
|
53
|
+
init_files.each do |init_file|
|
54
|
+
File.open("#{project_path}/#{init_file}", "w") do |file|
|
55
|
+
file.puts template_files[count]
|
56
|
+
count += 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/iot/new/main.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
Template_main = <<-EOS
|
2
|
+
#ifndef INCLUDED_MBED
|
3
|
+
#include "mbed.h"
|
4
|
+
#endif
|
5
|
+
|
6
|
+
#ifndef INCLUDED_BLEDEVICE
|
7
|
+
#include "BLEDevice.h"
|
8
|
+
#endif
|
9
|
+
|
10
|
+
#include "STService.h"
|
11
|
+
#include "STBLEDevice.h"
|
12
|
+
|
13
|
+
STBLEDevice ble;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* BLE callback
|
17
|
+
*/
|
18
|
+
void onConnectionCallback(Gap::Handle_t handle, Gap::addr_type_t peerAddrType, const Gap::address_t peerAddr, const Gap::ConnectionParams_t *params)
|
19
|
+
{
|
20
|
+
}
|
21
|
+
|
22
|
+
void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
|
23
|
+
{
|
24
|
+
ble.startAdvertising();
|
25
|
+
}
|
26
|
+
|
27
|
+
void onDataWritten(const GattCharacteristicWriteCBParams *params)
|
28
|
+
{
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* main function
|
33
|
+
*/
|
34
|
+
int main(void) {
|
35
|
+
|
36
|
+
ble.setup(); // custom method of STBLEDevice class
|
37
|
+
ble.setAdPacket(); // custom method of STBLEDevice class
|
38
|
+
uint8_t serviceCount = sizeof(GattServices) / sizeof(GattService *);
|
39
|
+
ble.addServices( GattServices, serviceCount ); // custom method of STBLEDevice class
|
40
|
+
|
41
|
+
// set up callback
|
42
|
+
ble.onConnection( onConnectionCallback );
|
43
|
+
ble.onDisconnection( disconnectionCallback );
|
44
|
+
ble.onDataWritten( onDataWritten );
|
45
|
+
|
46
|
+
ble.startAdvertising();
|
47
|
+
|
48
|
+
while (true) {
|
49
|
+
/*
|
50
|
+
* write some code
|
51
|
+
*/
|
52
|
+
}
|
53
|
+
}
|
54
|
+
EOS
|
@@ -0,0 +1,159 @@
|
|
1
|
+
Template_makefile = <<-EOS
|
2
|
+
|
3
|
+
# This file was automagically generated by mbed.org. For more information,
|
4
|
+
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
|
5
|
+
|
6
|
+
PROJECT = TEMP
|
7
|
+
OBJECTS += ./main.o
|
8
|
+
|
9
|
+
GCC_BIN = /usr/local/strobo/gcc-arm-none-eabi-4_9-2014q4/bin/
|
10
|
+
OBJECTS += \\
|
11
|
+
/usr/local/strobo/BLE_API/common/UUID.o\\
|
12
|
+
/usr/local/strobo/BLE_API/common/GapAdvertisingData.o\\
|
13
|
+
/usr/local/strobo/BLE_API/common/BLEDevice.o\\
|
14
|
+
/usr/local/strobo/BLE_API/common/GapAdvertisingParams.o\\
|
15
|
+
/usr/local/strobo/BLE_API/common/GattService.o\\
|
16
|
+
/usr/local/strobo/BLE_API/services/UARTService.o\\
|
17
|
+
/usr/local/strobo/BLE_API/services/DFUService.o\\
|
18
|
+
/usr/local/strobo/nRF51822/nRF51Gap.o\\
|
19
|
+
/usr/local/strobo/nRF51822/nRF51GattServer.o\\
|
20
|
+
/usr/local/strobo/nRF51822/nRF51822n.o\\
|
21
|
+
/usr/local/strobo/nRF51822/btle/btle_advertising.o\\
|
22
|
+
/usr/local/strobo/nRF51822/btle/btle_gap.o\\
|
23
|
+
/usr/local/strobo/nRF51822/btle/btle.o\\
|
24
|
+
/usr/local/strobo/nRF51822/btle/custom/custom_helper.o\\
|
25
|
+
/usr/local/strobo/nRF51822/nordic/softdevice_handler.o\\
|
26
|
+
/usr/local/strobo/nRF51822/nordic/app_common/pstorage.o\\
|
27
|
+
/usr/local/strobo/nRF51822/nordic/app_common/crc16.o\\
|
28
|
+
/usr/local/strobo/nRF51822/nordic/ble/ble_advdata.o\\
|
29
|
+
/usr/local/strobo/nRF51822/nordic/ble/ble_advdata_parser.o\\
|
30
|
+
/usr/local/strobo/nRF51822/nordic/ble/ble_error_log.o\\
|
31
|
+
/usr/local/strobo/nRF51822/nordic/ble/ble_debug_assert_handler.o\\
|
32
|
+
/usr/local/strobo/nRF51822/nordic/ble/ble_conn_params.o\\
|
33
|
+
/usr/local/strobo/nRF51822/nordic/ble/ble_bondmngr.o\\
|
34
|
+
/usr/local/strobo/nRF51822/nordic/ble/ble_services/ble_srv_common.o\\
|
35
|
+
/usr/local/strobo/nRF51822/nordic/bootloader_dfu/bootloader_util_arm.o\\
|
36
|
+
/usr/local/strobo/nRF51822/nordic/bootloader_dfu/dfu_app_handler.o\\
|
37
|
+
/usr/local/strobo/nRF51822/nordic/app_common/hci_mem_pool.o\\
|
38
|
+
/usr/local/strobo/nRF51822/nordic/app_common/app_scheduler.o\\
|
39
|
+
/usr/local/strobo/nRF51822/nordic/app_common/app_gpiote.o\\
|
40
|
+
|
41
|
+
SYS_OBJECTS = \\
|
42
|
+
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/startup_NRF51822.o\\
|
43
|
+
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/cmsis_nvic.o\\
|
44
|
+
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/board.o\\
|
45
|
+
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/system_nrf51822.o\\
|
46
|
+
/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/retarget.o
|
47
|
+
|
48
|
+
INCLUDE_PATHS =\\
|
49
|
+
-I.\\
|
50
|
+
-I/usr/local/strobo/mbed\\
|
51
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017\\
|
52
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM\\
|
53
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC\\
|
54
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822\\
|
55
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib\\
|
56
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nrf-sdk\\
|
57
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nrf-sdk/sd_common\\
|
58
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/nrf-sdk/app_common\\
|
59
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_1_0\\
|
60
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_1_0/s110_nrf51822_7.1.0_API\\
|
61
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_1_0/s110_nrf51822_7.1.0_API/include\\
|
62
|
+
-I/usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/TARGET_HRM1017\\
|
63
|
+
-I/usr/local/strobo/BLE_API\\
|
64
|
+
-I/usr/local/strobo/BLE_API/common\\
|
65
|
+
-I/usr/local/strobo/BLE_API/services\\
|
66
|
+
-I/usr/local/strobo/BLE_API/public\\
|
67
|
+
-I/usr/local/strobo/nRF51822\\
|
68
|
+
-I/usr/local/strobo/nRF51822/btle\\
|
69
|
+
-I/usr/local/strobo/nRF51822/btle/custom\\
|
70
|
+
-I/usr/local/strobo/nRF51822/common\\
|
71
|
+
-I/usr/local/strobo/nRF51822/nordic\\
|
72
|
+
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk\\
|
73
|
+
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/s110\\
|
74
|
+
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/sd_common\\
|
75
|
+
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/bootloader_dfu\\
|
76
|
+
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/app_common\\
|
77
|
+
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/ble\\
|
78
|
+
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/ble/ble_services\\
|
79
|
+
-I/usr/local/strobo/nRF51822/nordic/nrf-sdk/ble/device_manager\\
|
80
|
+
-I/usr/local/strobo/nRF51822/nordic/bootloader_dfu\\
|
81
|
+
-I/usr/local/strobo/nRF51822/nordic/app_common\\
|
82
|
+
-I/usr/local/strobo/nRF51822/nordic/ble\\
|
83
|
+
-I/usr/local/strobo/nRF51822/nordic/ble/ble_services\\
|
84
|
+
-I./iot
|
85
|
+
|
86
|
+
LIBRARY_PATHS = -L/usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM
|
87
|
+
LIBRARIES = -lmbed
|
88
|
+
LINKER_SCRIPT = /usr/local/strobo/mbed/TARGET_HRM1017/TOOLCHAIN_GCC_ARM/NRF51822.ld
|
89
|
+
SOFTDEVICE = /usr/local/strobo/mbed/TARGET_HRM1017/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_1_0/s110_nrf51822_7.1.0_softdevice.hex
|
90
|
+
|
91
|
+
###############################################################################
|
92
|
+
AS = $(GCC_BIN)arm-none-eabi-as
|
93
|
+
CC = $(GCC_BIN)arm-none-eabi-gcc
|
94
|
+
CPP = $(GCC_BIN)arm-none-eabi-g++
|
95
|
+
LD = $(GCC_BIN)arm-none-eabi-gcc
|
96
|
+
OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy
|
97
|
+
OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
|
98
|
+
SIZE = $(GCC_BIN)arm-none-eabi-size
|
99
|
+
|
100
|
+
CPU = -mcpu=cortex-m0 -mthumb
|
101
|
+
CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer
|
102
|
+
CC_FLAGS += -MMD -MP
|
103
|
+
CC_SYMBOLS = -DTARGET_HRM1017 -DTARGET_M0 -DTARGET_CORTEX_M -DTARGET_NORDIC -DTARGET_MCU_NRF51822 -DTARGET_MCU_NORDIC_16K -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M0 -DARM_MATH_CM0 -DMBED_BUILD_TIMESTAMP=1418113723.35 -D__MBED__=1 -DTARGET_NRF51822
|
104
|
+
|
105
|
+
LD_FLAGS = $(CPU) -Wl,--gc-sections -Wl,--wrap=main --specs=nano.specs -u _printf_float -u _scanf_float
|
106
|
+
LD_FLAGS += -Wl,-Map=$(PROJECT).map,--cref
|
107
|
+
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
|
108
|
+
|
109
|
+
ifeq ($(DEBUG), 1)
|
110
|
+
CC_FLAGS += -DDEBUG -O0
|
111
|
+
else
|
112
|
+
CC_FLAGS += -DNDEBUG -Os
|
113
|
+
endif
|
114
|
+
|
115
|
+
all: $(PROJECT).bin copy
|
116
|
+
|
117
|
+
clean:
|
118
|
+
rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) combined.hex
|
119
|
+
|
120
|
+
.s.o:
|
121
|
+
$(AS) $(CPU) -o $@ $<
|
122
|
+
|
123
|
+
.c.o:
|
124
|
+
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<
|
125
|
+
|
126
|
+
.cpp.o:
|
127
|
+
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
|
128
|
+
|
129
|
+
|
130
|
+
$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
|
131
|
+
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
|
132
|
+
$(SIZE) $@
|
133
|
+
|
134
|
+
$(PROJECT).bin: $(PROJECT).elf
|
135
|
+
@$(OBJCOPY) -O binary $< $@
|
136
|
+
|
137
|
+
$(PROJECT).hex: $(PROJECT).elf
|
138
|
+
@$(OBJCOPY) -O ihex $< $@
|
139
|
+
|
140
|
+
$(PROJECT).lst: $(PROJECT).elf
|
141
|
+
@$(OBJDUMP) -Sdh $< > $@
|
142
|
+
|
143
|
+
lst: $(PROJECT).lst
|
144
|
+
|
145
|
+
size:
|
146
|
+
$(SIZE) $(PROJECT).elf
|
147
|
+
|
148
|
+
DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
|
149
|
+
-include $(DEPS)
|
150
|
+
|
151
|
+
combined.hex: $(PROJECT).hex
|
152
|
+
iot mkhex $(SOFTDEVICE) $(PROJECT).hex
|
153
|
+
|
154
|
+
copy: combined.hex
|
155
|
+
sudo mount -u -w -o sync /Volumes/MBED
|
156
|
+
cp -X combined.hex /Volumes/MBED/
|
157
|
+
|
158
|
+
|
159
|
+
EOS
|
@@ -0,0 +1,83 @@
|
|
1
|
+
Template_stbledevice = <<-EOS
|
2
|
+
|
3
|
+
#ifndef INCLUDED_BLEDEVICE
|
4
|
+
#include "BLEDevice.h"
|
5
|
+
#endif
|
6
|
+
|
7
|
+
#ifndef INCLUDED_STDEVICEINFO
|
8
|
+
#include "STDeviceInfo.h"
|
9
|
+
#endif
|
10
|
+
|
11
|
+
|
12
|
+
class STBLEDevice : public BLEDevice{
|
13
|
+
public:
|
14
|
+
/**
|
15
|
+
* Initialize BLEDevice instanse
|
16
|
+
*/
|
17
|
+
void setup() {
|
18
|
+
this->init();
|
19
|
+
this->setDeviceName( (const uint8_t *)COMP_NAME );
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Add Service array
|
24
|
+
* @param *GattServices array of GATT service
|
25
|
+
* @param length length of *GattServices array
|
26
|
+
*/
|
27
|
+
void addServices(GattService *GattServices[], uint16_t length) {
|
28
|
+
for (int i=0; i<length ; i++) {
|
29
|
+
this->addService( *GattServices[i] );
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Set Advertising Packet
|
35
|
+
*/
|
36
|
+
void setAdPacket() {
|
37
|
+
/**
|
38
|
+
* Set PDU type
|
39
|
+
* Types of PDU type
|
40
|
+
* - ADV_CONNECTABLE_UNDIRECTED
|
41
|
+
* - ADV_CONNECTABLE_DIRECTED
|
42
|
+
* - ADV_SCANNABLE_UNDIRECTED
|
43
|
+
* - ADV_NON_CONNECTABLE_UNDIRECTED
|
44
|
+
*/
|
45
|
+
GapAdvertisingParams::AdvertisingType advType = GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED;
|
46
|
+
this->setAdvertisingType( advType );
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Set Flags
|
50
|
+
* - BR/EDR not supported
|
51
|
+
*/
|
52
|
+
this->accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Set Device Name.
|
56
|
+
* Developer has to choose one from belows.
|
57
|
+
* - SHORTENED_LOCAL_NAME
|
58
|
+
* - COMPLETE_LOCAL_NAME
|
59
|
+
*/
|
60
|
+
if (SHORT_FLG) {
|
61
|
+
this->accumulateAdvertisingPayload(
|
62
|
+
GapAdvertisingData::SHORTENED_LOCAL_NAME,
|
63
|
+
(const uint8_t *)SHORT_NAME,
|
64
|
+
sizeof(SHORT_NAME)
|
65
|
+
);
|
66
|
+
} else {
|
67
|
+
this->accumulateAdvertisingPayload(
|
68
|
+
GapAdvertisingData::COMPLETE_LOCAL_NAME,
|
69
|
+
(const uint8_t *)COMP_NAME,
|
70
|
+
sizeof(COMP_NAME)
|
71
|
+
);
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Set advertising Interval
|
76
|
+
*/
|
77
|
+
this->setAdvertisingInterval(AD_INTERVAL);
|
78
|
+
}
|
79
|
+
|
80
|
+
};
|
81
|
+
|
82
|
+
|
83
|
+
EOS
|