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
@@ -0,0 +1,118 @@
|
|
1
|
+
Template_stservice = <<-EOS
|
2
|
+
EOS
|
3
|
+
|
4
|
+
|
5
|
+
# #ifndef INCLUDED_MBED
|
6
|
+
# #include "mbed.h"
|
7
|
+
# #endif
|
8
|
+
|
9
|
+
# #ifndef INCLUDED_BLEDEVICE
|
10
|
+
# #include "BLEDevice.h"
|
11
|
+
# #endif
|
12
|
+
|
13
|
+
# /*
|
14
|
+
# * Power control service
|
15
|
+
# * Service_Uuid: 0xFF00
|
16
|
+
# */
|
17
|
+
# static const uint16_t power_control_char_uuid = 0xFF00;
|
18
|
+
# uint8_t power_control_char_value[8] = {0,};
|
19
|
+
# GattCharacteristic PowerControlChar(
|
20
|
+
# power_control_char_uuid,
|
21
|
+
# power_control_char_value,
|
22
|
+
# sizeof(power_control_char_value),
|
23
|
+
# sizeof(power_control_char_value),
|
24
|
+
# GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ |
|
25
|
+
# GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE
|
26
|
+
# );
|
27
|
+
|
28
|
+
# static const uint16_t power_state_char_uuid = 0xFF01;
|
29
|
+
# uint8_t power_state_char_value[8] = {0x41,0x42,0x43};
|
30
|
+
# GattCharacteristic PowerStateChar(
|
31
|
+
# power_state_char_uuid,
|
32
|
+
# power_state_char_value,
|
33
|
+
# sizeof(power_control_char_value),
|
34
|
+
# sizeof(power_control_char_value),
|
35
|
+
# GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
|
36
|
+
# );
|
37
|
+
|
38
|
+
# GattCharacteristic *PowerControlChars[] = { &PowerControlChar, &PowerStateChar };
|
39
|
+
|
40
|
+
# static const uint8_t power_control_service_uuid[] = {
|
41
|
+
# 0x7d, 0x2e, 0x51, 0xcd,
|
42
|
+
# 0x5a, 0xa0,
|
43
|
+
# 0x4f, 0x45,
|
44
|
+
# 0x84, 0xcf,
|
45
|
+
# 0xad, 0x3d, 0xbd, 0xf2, 0x54, 0x40
|
46
|
+
# };
|
47
|
+
# GattService PowerControlService(
|
48
|
+
# power_control_service_uuid,
|
49
|
+
# PowerControlChars,
|
50
|
+
# sizeof(PowerControlChars) / sizeof(GattCharacteristic *)
|
51
|
+
# );
|
52
|
+
|
53
|
+
# /**
|
54
|
+
# * 2nd Service
|
55
|
+
# */
|
56
|
+
# static const uint16_t energy_monitor_char_uuid = 0xFF01;
|
57
|
+
# uint8_t energy_monitor_char_value[8] = {0,};
|
58
|
+
# GattCharacteristic EnergyMonitorChar(
|
59
|
+
# energy_monitor_char_uuid,
|
60
|
+
# energy_monitor_char_value,
|
61
|
+
# sizeof(energy_monitor_char_value),
|
62
|
+
# sizeof(energy_monitor_char_value),
|
63
|
+
# GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
|
64
|
+
# );
|
65
|
+
|
66
|
+
# GattCharacteristic *EnergyChars[] = { &EnergyMonitorChar };
|
67
|
+
|
68
|
+
# static const uint8_t energy_service_uuid[] = {
|
69
|
+
# 0x7d, 0x2e, 0x51, 0xcd,
|
70
|
+
# 0x5a, 0xa0,
|
71
|
+
# 0x4f, 0x45,
|
72
|
+
# 0x84, 0xcf,
|
73
|
+
# 0xad, 0x3d, 0xbd, 0xf2, 0x54, 0x41
|
74
|
+
# };
|
75
|
+
|
76
|
+
# GattService EnergyService(
|
77
|
+
# energy_service_uuid,
|
78
|
+
# EnergyChars,
|
79
|
+
# sizeof(EnergyChars) / sizeof(GattCharacteristic *)
|
80
|
+
# );
|
81
|
+
|
82
|
+
# /**
|
83
|
+
# * Time Count Service
|
84
|
+
# */
|
85
|
+
# static const uint16_t time_monitor_char_uuid = 0xFF01;
|
86
|
+
# uint8_t time_monitor_char_value[8] = {0,};
|
87
|
+
# GattCharacteristic TimeMonitorChar(
|
88
|
+
# time_monitor_char_uuid,
|
89
|
+
# time_monitor_char_value,
|
90
|
+
# sizeof(time_monitor_char_value),
|
91
|
+
# sizeof(time_monitor_char_value),
|
92
|
+
# //GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ
|
93
|
+
# GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY
|
94
|
+
# );
|
95
|
+
|
96
|
+
# GattCharacteristic *TimeChars[] = { &TimeMonitorChar };
|
97
|
+
|
98
|
+
# static const uint8_t time_service_uuid[] = {
|
99
|
+
# 0x7d, 0x2e, 0x51, 0xcd,
|
100
|
+
# 0x5a, 0xa0,
|
101
|
+
# 0x4f, 0x45,
|
102
|
+
# 0x84, 0xcf,
|
103
|
+
# 0xad, 0x3d, 0xbd, 0xf2, 0x54, 0x42
|
104
|
+
# };
|
105
|
+
|
106
|
+
# GattService TimeService(
|
107
|
+
# time_service_uuid,
|
108
|
+
# TimeChars,
|
109
|
+
# sizeof(TimeChars) / sizeof(GattCharacteristic *)
|
110
|
+
# );
|
111
|
+
|
112
|
+
# GattService *GattServices[] = {
|
113
|
+
# &EnergyService,
|
114
|
+
# &PowerControlService,
|
115
|
+
# &TimeService };
|
116
|
+
|
117
|
+
|
118
|
+
|
data/lib/iot/run.rb
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "open3"
|
3
|
+
require "iot/bleyamlparser"
|
4
|
+
|
5
|
+
module Iot
|
6
|
+
module Run
|
7
|
+
def run
|
8
|
+
generate_template_deviceinfo
|
9
|
+
generate_template_service
|
10
|
+
generate_ad_packet
|
11
|
+
|
12
|
+
puts "building and flashing program..."
|
13
|
+
`make`
|
14
|
+
end
|
15
|
+
|
16
|
+
def generate_ad_packet
|
17
|
+
yaml = load_yaml_body
|
18
|
+
if yaml.empty?
|
19
|
+
puts "No Yaml file"
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
deviceinfo = yaml["deviceinfo"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate_template_deviceinfo
|
27
|
+
yaml = load_yaml_body
|
28
|
+
if yaml.empty?
|
29
|
+
puts "No Yaml file"
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
deviceinfo = yaml["deviceinfo"]
|
34
|
+
complete_name = deviceinfo["name"]
|
35
|
+
short_name = deviceinfo["shortname"]
|
36
|
+
ad_interval = deviceinfo["adpacket"]["interval"]
|
37
|
+
localname_flg = deviceinfo["adpacket"]["localname"]
|
38
|
+
|
39
|
+
str = ""
|
40
|
+
str << "#define COMP_NAME \"#{complete_name}\"\n"
|
41
|
+
str << "#define SHORT_NAME \"#{short_name}\"\n"
|
42
|
+
str << "#define SHORT_FLG #{localname_flg}\n"
|
43
|
+
str << "#define AD_INTERVAL #{ad_interval}\n"
|
44
|
+
|
45
|
+
File.write("./iot/STDeviceInfo.h", str)
|
46
|
+
end
|
47
|
+
|
48
|
+
def generate_template_service
|
49
|
+
yaml = load_yaml_body
|
50
|
+
if yaml.empty?
|
51
|
+
puts "No Yaml file"
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
str = ""
|
56
|
+
str << "#ifndef INCLUDED_MBED\n"
|
57
|
+
str << "#include \"mbed.h\"\n"
|
58
|
+
str << "#endif\n"
|
59
|
+
str << "#ifndef INCLUDED_BLEDEVICE\n"
|
60
|
+
str << "#include \"BLEDevice.h\"\n"
|
61
|
+
str << "#endif\n"
|
62
|
+
|
63
|
+
deviceinfo = yaml["deviceinfo"]
|
64
|
+
services = deviceinfo["services"]
|
65
|
+
|
66
|
+
services.each do |service|
|
67
|
+
service_name = service["name"]
|
68
|
+
chars = service["chars"]
|
69
|
+
|
70
|
+
chars.each do |characteristic|
|
71
|
+
char_uuid_str = characteristic["uuid"].gsub("-", "")
|
72
|
+
|
73
|
+
char_uuid = []
|
74
|
+
(0..15).each do |num|
|
75
|
+
char_uuid << char_uuid_str[num*2..(num*2+1)]
|
76
|
+
end
|
77
|
+
|
78
|
+
char_name = characteristic["name"]
|
79
|
+
|
80
|
+
str << "static const uint8_t #{char_name}_uuid[16] = {"
|
81
|
+
|
82
|
+
char_uuid.each do |temp|
|
83
|
+
str << "0x#{temp}, "
|
84
|
+
end
|
85
|
+
|
86
|
+
str << "};\n"
|
87
|
+
|
88
|
+
str << "uint8_t #{char_name}_value[8] = {0,};\n"
|
89
|
+
|
90
|
+
str << "GattCharacteristic #{char_name}(\n"
|
91
|
+
str << "#{char_name}_uuid,\n"
|
92
|
+
str << "#{char_name}_value,\n"
|
93
|
+
str << "sizeof(#{char_name}_value),\n"
|
94
|
+
str << "sizeof(#{char_name}_value),\n"
|
95
|
+
|
96
|
+
gatt_properties = []
|
97
|
+
properties = characteristic["properties"]
|
98
|
+
if properties.include? "read"
|
99
|
+
gatt_properties << "GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ"
|
100
|
+
end
|
101
|
+
|
102
|
+
if properties.include? "write"
|
103
|
+
gatt_properties << "GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE"
|
104
|
+
end
|
105
|
+
|
106
|
+
if properties.include? "notify"
|
107
|
+
gatt_properties << "GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY"
|
108
|
+
end
|
109
|
+
|
110
|
+
gatt_properties.each do |temp|
|
111
|
+
str << "#{temp} |"
|
112
|
+
end
|
113
|
+
|
114
|
+
str << ");\n"
|
115
|
+
|
116
|
+
str.gsub!("|)", ")")
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
str << "GattCharacteristic *#{service_name}_chars[] = {\n"
|
121
|
+
chars.each do |characteristic|
|
122
|
+
str << "&#{characteristic["name"]},\n"
|
123
|
+
end
|
124
|
+
str << "};\n"
|
125
|
+
|
126
|
+
service_uuid_str = service["uuid"].gsub("-", "")
|
127
|
+
service_uuid = []
|
128
|
+
(0..15).each do |num|
|
129
|
+
service_uuid << service_uuid_str[num*2..(num*2+1)]
|
130
|
+
end
|
131
|
+
|
132
|
+
service_name = service["name"]
|
133
|
+
str << "static const uint8_t #{service_name}_uuid[] = {\n"
|
134
|
+
|
135
|
+
service_uuid.each do |temp|
|
136
|
+
str << "0x#{temp}, "
|
137
|
+
end
|
138
|
+
str << "};\n"
|
139
|
+
|
140
|
+
str << "GattService #{service_name}(\n"
|
141
|
+
str << "#{service_name}_uuid,\n"
|
142
|
+
str << "#{service_name}_chars,\n"
|
143
|
+
str << "sizeof(#{service_name}_chars) / sizeof(GattCharacteristic *)\n"
|
144
|
+
str << ");\n"
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
str << "GattService *GattServices[]={\n"
|
149
|
+
services.each do |service|
|
150
|
+
str << "&#{service["name"]},"
|
151
|
+
end
|
152
|
+
str << "};"
|
153
|
+
|
154
|
+
|
155
|
+
File.write("./iot/STService.h", str)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
data/lib/iot/service.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "iot/bleyamlparser"
|
3
|
+
|
4
|
+
module Iot
|
5
|
+
module Service
|
6
|
+
|
7
|
+
def service
|
8
|
+
yaml = load_yaml_body
|
9
|
+
|
10
|
+
deviceinfo = yaml["deviceinfo"]
|
11
|
+
services = deviceinfo["services"]
|
12
|
+
|
13
|
+
services.each do |service|
|
14
|
+
char_count = service["chars"].count
|
15
|
+
puts "#{service["uuid"]}\t#{service["name"]}: has #{char_count} characteristics"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/iot/stats.rb
ADDED
data/lib/iot/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Akito Gyoten
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: IoT gem generate development environment for IoT devices and genarate
|
42
|
+
skelton code for embedded software for IoT devices.
|
43
|
+
email:
|
44
|
+
- akitogyoten@gmail.com
|
45
|
+
executables:
|
46
|
+
- iot
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/iot
|
56
|
+
- iot.gemspec
|
57
|
+
- lib/iot.rb
|
58
|
+
- lib/iot/bleyamlparser.rb
|
59
|
+
- lib/iot/characteristic.rb
|
60
|
+
- lib/iot/destroy.rb
|
61
|
+
- lib/iot/devicename.rb
|
62
|
+
- lib/iot/generate.rb
|
63
|
+
- lib/iot/help.rb
|
64
|
+
- lib/iot/install.rb
|
65
|
+
- lib/iot/mkhex.rb
|
66
|
+
- lib/iot/new.rb
|
67
|
+
- lib/iot/new/bleyaml.rb
|
68
|
+
- lib/iot/new/main.rb
|
69
|
+
- lib/iot/new/makefile.rb
|
70
|
+
- lib/iot/new/stbledevice.rb
|
71
|
+
- lib/iot/new/stdeviceinfo.rb
|
72
|
+
- lib/iot/new/stservice.rb
|
73
|
+
- lib/iot/run.rb
|
74
|
+
- lib/iot/service.rb
|
75
|
+
- lib/iot/stats.rb
|
76
|
+
- lib/iot/version.rb
|
77
|
+
homepage: http://corp.strobo.me
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.0
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Development environment for IoT devices generator
|
101
|
+
test_files: []
|