aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-07-26 22:56:49 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-07-26 22:56:49 +0200
commit9b086f8c4b5e96b46a3904c3bcfe11af39347b80 (patch)
tree5a11f24f21cd75ef51453178e32854663511ac3e
parent1268da96983b522266603989cffb9a2423679c9f (diff)
downloadtrygvisio_soil_moisture-9b086f8c4b5e96b46a3904c3bcfe11af39347b80.tar.gz
trygvisio_soil_moisture-9b086f8c4b5e96b46a3904c3bcfe11af39347b80.tar.bz2
trygvisio_soil_moisture-9b086f8c4b5e96b46a3904c3bcfe11af39347b80.tar.xz
trygvisio_soil_moisture-9b086f8c4b5e96b46a3904c3bcfe11af39347b80.zip
o Adding three new characteristics:
- Model number: Set to the board id. - Hardware revision: set to the device version data from the nRF8001 device. Not very useful right now. - Firmware revision: set to the string "Arduino: " + build time if not predefined from the outside.
-rw-r--r--services.h150
-rw-r--r--services_lock.h150
-rw-r--r--trygvisio_soil_moisture.ino88
-rw-r--r--trygvisio_soil_moisture.xml92
-rw-r--r--ublue_setup.gen.out.txt54
5 files changed, 348 insertions, 186 deletions
diff --git a/services.h b/services.h
index b2b1853..3ba874b 100644
--- a/services.h
+++ b/services.h
@@ -11,7 +11,7 @@
#define SETUP_ID 0
#define SETUP_FORMAT 3 /** nRF8001 D */
-#define ACI_DYNAMIC_DATA_SIZE 166
+#define ACI_DYNAMIC_DATA_SIZE 226
/* Service: Gap - Characteristic: Device name - Pipe: SET */
#define PIPE_GAP_DEVICE_NAME_SET 1
@@ -41,8 +41,20 @@
#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET 7
#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET_MAX_SIZE 5
+/* Service: Device Information - Characteristic: Model Number String - Pipe: SET */
+#define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET 8
+#define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET_MAX_SIZE 20
-#define NUMBER_OF_PIPES 7
+/* Service: Device Information - Characteristic: Hardware Revision String - Pipe: SET */
+#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET 9
+#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET_MAX_SIZE 9
+
+/* Service: Device Information - Characteristic: Firmware Revision String - Pipe: SET */
+#define PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET 10
+#define PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET_MAX_SIZE 20
+
+
+#define NUMBER_OF_PIPES 10
#define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\
{ACI_STORE_LOCAL, ACI_SET}, \
@@ -52,6 +64,9 @@
{ACI_STORE_LOCAL, ACI_RX_ACK_AUTO}, \
{ACI_STORE_LOCAL, ACI_TX}, \
{ACI_STORE_LOCAL, ACI_SET}, \
+ {ACI_STORE_LOCAL, ACI_SET}, \
+ {ACI_STORE_LOCAL, ACI_SET}, \
+ {ACI_STORE_LOCAL, ACI_SET}, \
}
#define GAP_PPCP_MAX_CONN_INT 0xffff /**< Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */
@@ -59,73 +74,7 @@
#define GAP_PPCP_SLAVE_LATENCY 0
#define GAP_PPCP_CONN_TIMEOUT 0xffff /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */
-/** @brief do a set_local_data for PIPE_GAP_DEVICE_NAME_SET
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 10
- * @details use this function to do a set_local_data for PIPE_GAP_DEVICE_NAME_SET. If no transaction are currently
- * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called.
- */
-void services_set_gap_device_name(void *src, int size);
-
-/** @brief do a set_local_data for PIPE_BATTERY_BATTERY_LEVEL_SET
- * @param src the value to send
- * @details use this function to do a set_local_data for PIPE_BATTERY_BATTERY_LEVEL_SET. If no transaction are currently
- * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called.
- */
-void services_set_battery_battery_level(uint8_t src);
-
-/** @brief send a new value for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 20
- * @param is_freshest_sample set it to true if you want to overwrite an eventual pending transaction on this pipe.
- * @details use this function to send a new value for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX. If no transaction are currently
- * running, the send will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called. If a transaction on this pipe is already pending, then this function
- * will not overwrite the data of the previous transaction and return false.
- * @return : true if is_freshest_sample true, otherwise return false if a transaction on this pipe is already pending, true otherwise.
- */
-bool services_send_soil_moisture_soil_moisture_control(void *src, int size, bool is_freshest_sample);
-
-/** @brief do a set_local_data for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 20
- * @details use this function to do a set_local_data for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET. If no transaction are currently
- * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called.
- */
-void services_set_soil_moisture_soil_moisture_control(void *src, int size);
-
-/** @brief send a new value for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 5
- * @param is_freshest_sample set it to true if you want to overwrite an eventual pending transaction on this pipe.
- * @details use this function to send a new value for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX. If no transaction are currently
- * running, the send will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called. If a transaction on this pipe is already pending, then this function
- * will not overwrite the data of the previous transaction and return false.
- * @return : true if is_freshest_sample true, otherwise return false if a transaction on this pipe is already pending, true otherwise.
- */
-bool services_send_soil_moisture_intermediate_temperature(void *src, int size, bool is_freshest_sample);
-
-/** @brief do a set_local_data for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 5
- * @details use this function to do a set_local_data for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET. If no transaction are currently
- * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called.
- */
-void services_set_soil_moisture_intermediate_temperature(void *src, int size);
-
-/** @brief function to trig pending transaction on pipes
- * @details This function check for each pipe if it has a pending transaction (send/rx_request/ack)
- * and if so executes this transaction.
- * This function should be called in the APP_RUN state of the process function of the application.
- */
-void services_update_pipes(void);
-
-#define NB_SETUP_MESSAGES 20
+#define NB_SETUP_MESSAGES 28
#define SETUP_MESSAGES_CONTENT {\
{0x00,\
{\
@@ -134,8 +83,8 @@ void services_update_pipes(void);
},\
{0x00,\
{\
- 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x07,0x01,0x01,0x00,0x00,0x06,0x00,0x01,\
- 0xd1,0x0f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0a,0x01,0x01,0x00,0x00,0x06,0x00,0x01,\
+ 0x91,0x0f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
},\
},\
{0x00,\
@@ -211,8 +160,50 @@ void services_update_pipes(void);
},\
{0x00,\
{\
- 0x1e,0x06,0x20,0xfc,0x2a,0x16,0x04,0x06,0x05,0x00,0x11,0x2a,0x1e,0x01,0x00,0x00,0x00,0x00,0x00,0x46,\
- 0x14,0x03,0x02,0x00,0x12,0x29,0x02,0x01,0x00,0x00,0x00,\
+ 0x1f,0x06,0x20,0xfc,0x2a,0x16,0x04,0x06,0x05,0x00,0x11,0x2a,0x1e,0x01,0x00,0x00,0x00,0x00,0x00,0x46,\
+ 0x14,0x03,0x02,0x00,0x12,0x29,0x02,0x01,0x00,0x00,0x04,0x04,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x18,0x02,0x02,0x00,0x13,0x28,0x00,0x01,0x0a,0x18,0x04,0x04,0x05,0x05,0x00,0x14,0x28,\
+ 0x03,0x01,0x02,0x15,0x00,0x24,0x2a,0x04,0x04,0x14,0x00,0x00,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x34,0x15,0x2a,0x24,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x05,0x05,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x50,0x00,0x16,0x28,0x03,0x01,0x02,0x17,0x00,0x27,0x2a,0x04,0x04,0x09,0x00,0x00,0x17,\
+ 0x2a,0x27,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x6c,0x04,0x04,0x05,0x05,0x00,0x18,0x28,0x03,0x01,0x02,0x19,0x00,0x26,0x2a,0x04,0x04,\
+ 0x14,0x00,0x00,0x19,0x2a,0x26,0x01,0x00,0x00,0x00,0x00,0x00,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,\
+ 0x04,0x08,0x07,0x00,0x1a,0x29,0x04,0x01,0x19,0x00,0x00,0x00,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0xa4,0x01,0x00,0x00,0x04,0x04,0x05,0x05,0x00,0x1b,0x28,0x03,0x01,0x02,0x1c,0x00,0x29,\
+ 0x2a,0x06,0x04,0x0b,0x0a,0x00,0x1c,0x2a,0x29,0x01,0x54,0x72,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1c,0x06,0x21,0xc0,0x79,0x67,0x76,0x69,0x73,0x20,0x49,0x4f,0x06,0x04,0x08,0x07,0x00,0x1d,0x29,0x04,\
+ 0x01,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x00,\
},\
},\
{0x00,\
@@ -223,7 +214,13 @@ void services_update_pipes(void);
},\
{0x00,\
{\
- 0x0f,0x06,0x40,0x1c,0x00,0x0f,0x2a,0x1e,0x01,0x00,0x82,0x04,0x00,0x11,0x00,0x12,\
+ 0x1f,0x06,0x40,0x1c,0x00,0x0f,0x2a,0x1e,0x01,0x00,0x82,0x04,0x00,0x11,0x00,0x12,0x2a,0x24,0x01,0x00,\
+ 0x80,0x04,0x00,0x15,0x00,0x00,0x2a,0x27,0x01,0x00,0x80,0x04,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x11,0x06,0x40,0x38,0x00,0x17,0x00,0x00,0x2a,0x26,0x01,0x00,0x80,0x04,0x00,0x19,0x00,0x00,\
},\
},\
{0x00,\
@@ -233,12 +230,13 @@ void services_update_pipes(void);
},\
{0x00,\
{\
- 0x0f,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ 0x18,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ 0x00,0x00,0x00,0x00,0x00,\
},\
},\
{0x00,\
{\
- 0x06,0x06,0xf0,0x00,0x03,0xb7,0x22,\
+ 0x06,0x06,0xf0,0x00,0x03,0x1d,0x69,\
},\
},\
}
diff --git a/services_lock.h b/services_lock.h
index df5ee8d..2d4e972 100644
--- a/services_lock.h
+++ b/services_lock.h
@@ -15,7 +15,7 @@
#define SETUP_ID 0
#define SETUP_FORMAT 3 /** nRF8001 D */
-#define ACI_DYNAMIC_DATA_SIZE 166
+#define ACI_DYNAMIC_DATA_SIZE 226
/* Service: Gap - Characteristic: Device name - Pipe: SET */
#define PIPE_GAP_DEVICE_NAME_SET 1
@@ -45,8 +45,20 @@
#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET 7
#define PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET_MAX_SIZE 5
+/* Service: Device Information - Characteristic: Model Number String - Pipe: SET */
+#define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET 8
+#define PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET_MAX_SIZE 20
-#define NUMBER_OF_PIPES 7
+/* Service: Device Information - Characteristic: Hardware Revision String - Pipe: SET */
+#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET 9
+#define PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET_MAX_SIZE 9
+
+/* Service: Device Information - Characteristic: Firmware Revision String - Pipe: SET */
+#define PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET 10
+#define PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET_MAX_SIZE 20
+
+
+#define NUMBER_OF_PIPES 10
#define SERVICES_PIPE_TYPE_MAPPING_CONTENT {\
{ACI_STORE_LOCAL, ACI_SET}, \
@@ -56,6 +68,9 @@
{ACI_STORE_LOCAL, ACI_RX_ACK_AUTO}, \
{ACI_STORE_LOCAL, ACI_TX}, \
{ACI_STORE_LOCAL, ACI_SET}, \
+ {ACI_STORE_LOCAL, ACI_SET}, \
+ {ACI_STORE_LOCAL, ACI_SET}, \
+ {ACI_STORE_LOCAL, ACI_SET}, \
}
#define GAP_PPCP_MAX_CONN_INT 0xffff /**< Maximum connection interval as a multiple of 1.25 msec , 0xFFFF means no specific value requested */
@@ -63,73 +78,7 @@
#define GAP_PPCP_SLAVE_LATENCY 0
#define GAP_PPCP_CONN_TIMEOUT 0xffff /** Connection Supervision timeout multiplier as a multiple of 10msec, 0xFFFF means no specific value requested */
-/** @brief do a set_local_data for PIPE_GAP_DEVICE_NAME_SET
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 10
- * @details use this function to do a set_local_data for PIPE_GAP_DEVICE_NAME_SET. If no transaction are currently
- * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called.
- */
-void services_set_gap_device_name(void *src, int size);
-
-/** @brief do a set_local_data for PIPE_BATTERY_BATTERY_LEVEL_SET
- * @param src the value to send
- * @details use this function to do a set_local_data for PIPE_BATTERY_BATTERY_LEVEL_SET. If no transaction are currently
- * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called.
- */
-void services_set_battery_battery_level(uint8_t src);
-
-/** @brief send a new value for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 20
- * @param is_freshest_sample set it to true if you want to overwrite an eventual pending transaction on this pipe.
- * @details use this function to send a new value for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_TX. If no transaction are currently
- * running, the send will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called. If a transaction on this pipe is already pending, then this function
- * will not overwrite the data of the previous transaction and return false.
- * @return : true if is_freshest_sample true, otherwise return false if a transaction on this pipe is already pending, true otherwise.
- */
-bool services_send_soil_moisture_soil_moisture_control(void *src, int size, bool is_freshest_sample);
-
-/** @brief do a set_local_data for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 20
- * @details use this function to do a set_local_data for PIPE_SOIL_MOISTURE_SOIL_MOISTURE_CONTROL_SET. If no transaction are currently
- * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called.
- */
-void services_set_soil_moisture_soil_moisture_control(void *src, int size);
-
-/** @brief send a new value for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 5
- * @param is_freshest_sample set it to true if you want to overwrite an eventual pending transaction on this pipe.
- * @details use this function to send a new value for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_TX. If no transaction are currently
- * running, the send will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called. If a transaction on this pipe is already pending, then this function
- * will not overwrite the data of the previous transaction and return false.
- * @return : true if is_freshest_sample true, otherwise return false if a transaction on this pipe is already pending, true otherwise.
- */
-bool services_send_soil_moisture_intermediate_temperature(void *src, int size, bool is_freshest_sample);
-
-/** @brief do a set_local_data for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET
- * @param src source buffer to send data from
- * @param size the number of bytes to send. Maximum size is 5
- * @details use this function to do a set_local_data for PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET. If no transaction are currently
- * running, the set will be immediate, otherwise, it will be done at the end of the current transaction
- * when services_update_pipes will be called.
- */
-void services_set_soil_moisture_intermediate_temperature(void *src, int size);
-
-/** @brief function to trig pending transaction on pipes
- * @details This function check for each pipe if it has a pending transaction (send/rx_request/ack)
- * and if so executes this transaction.
- * This function should be called in the APP_RUN state of the process function of the application.
- */
-void services_update_pipes(void);
-
-#define NB_SETUP_MESSAGES 20
+#define NB_SETUP_MESSAGES 28
#define SETUP_MESSAGES_CONTENT {\
{0x00,\
{\
@@ -138,8 +87,8 @@ void services_update_pipes(void);
},\
{0x00,\
{\
- 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x07,0x01,0x01,0x00,0x00,0x06,0x00,0x01,\
- 0xd1,0x0f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ 0x1f,0x06,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0a,0x01,0x01,0x00,0x00,0x06,0x00,0x01,\
+ 0x91,0x0f,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
},\
},\
{0x00,\
@@ -215,8 +164,50 @@ void services_update_pipes(void);
},\
{0x00,\
{\
- 0x1e,0x06,0x20,0xfc,0x2a,0x16,0x04,0x06,0x05,0x00,0x11,0x2a,0x1e,0x01,0x00,0x00,0x00,0x00,0x00,0x46,\
- 0x14,0x03,0x02,0x00,0x12,0x29,0x02,0x01,0x00,0x00,0x00,\
+ 0x1f,0x06,0x20,0xfc,0x2a,0x16,0x04,0x06,0x05,0x00,0x11,0x2a,0x1e,0x01,0x00,0x00,0x00,0x00,0x00,0x46,\
+ 0x14,0x03,0x02,0x00,0x12,0x29,0x02,0x01,0x00,0x00,0x04,0x04,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x18,0x02,0x02,0x00,0x13,0x28,0x00,0x01,0x0a,0x18,0x04,0x04,0x05,0x05,0x00,0x14,0x28,\
+ 0x03,0x01,0x02,0x15,0x00,0x24,0x2a,0x04,0x04,0x14,0x00,0x00,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x34,0x15,0x2a,0x24,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x05,0x05,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x50,0x00,0x16,0x28,0x03,0x01,0x02,0x17,0x00,0x27,0x2a,0x04,0x04,0x09,0x00,0x00,0x17,\
+ 0x2a,0x27,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x6c,0x04,0x04,0x05,0x05,0x00,0x18,0x28,0x03,0x01,0x02,0x19,0x00,0x26,0x2a,0x04,0x04,\
+ 0x14,0x00,0x00,0x19,0x2a,0x26,0x01,0x00,0x00,0x00,0x00,0x00,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,\
+ 0x04,0x08,0x07,0x00,0x1a,0x29,0x04,0x01,0x19,0x00,0x00,0x00,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1f,0x06,0x21,0xa4,0x01,0x00,0x00,0x04,0x04,0x05,0x05,0x00,0x1b,0x28,0x03,0x01,0x02,0x1c,0x00,0x29,\
+ 0x2a,0x06,0x04,0x0b,0x0a,0x00,0x1c,0x2a,0x29,0x01,0x54,0x72,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x1c,0x06,0x21,0xc0,0x79,0x67,0x76,0x69,0x73,0x20,0x49,0x4f,0x06,0x04,0x08,0x07,0x00,0x1d,0x29,0x04,\
+ 0x01,0x19,0x00,0x00,0x00,0x01,0x00,0x00,0x00,\
},\
},\
{0x00,\
@@ -227,7 +218,13 @@ void services_update_pipes(void);
},\
{0x00,\
{\
- 0x0f,0x06,0x40,0x1c,0x00,0x0f,0x2a,0x1e,0x01,0x00,0x82,0x04,0x00,0x11,0x00,0x12,\
+ 0x1f,0x06,0x40,0x1c,0x00,0x0f,0x2a,0x1e,0x01,0x00,0x82,0x04,0x00,0x11,0x00,0x12,0x2a,0x24,0x01,0x00,\
+ 0x80,0x04,0x00,0x15,0x00,0x00,0x2a,0x27,0x01,0x00,0x80,0x04,\
+ },\
+ },\
+ {0x00,\
+ {\
+ 0x11,0x06,0x40,0x38,0x00,0x17,0x00,0x00,0x2a,0x26,0x01,0x00,0x80,0x04,0x00,0x19,0x00,0x00,\
},\
},\
{0x00,\
@@ -237,12 +234,13 @@ void services_update_pipes(void);
},\
{0x00,\
{\
- 0x0f,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ 0x18,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
+ 0x00,0x00,0x00,0x00,0x00,\
},\
},\
{0x00,\
{\
- 0x06,0x06,0xf0,0x00,0x83,0x26,0xaa,\
+ 0x06,0x06,0xf0,0x00,0x83,0x8c,0xe1,\
},\
},\
}
diff --git a/trygvisio_soil_moisture.ino b/trygvisio_soil_moisture.ino
index 4c9e0d7..183cb38 100644
--- a/trygvisio_soil_moisture.ino
+++ b/trygvisio_soil_moisture.ino
@@ -17,11 +17,43 @@
#include "Debug.h"
#ifdef PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET
-#define USE_TEMPERATURE
+#define FEATURE_TEMPERATURE
+#endif
+
+#ifdef PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET
+//#define FEATURE_HARDWARE_REVISION
#endif
#ifdef PIPE_BATTERY_BATTERY_LEVEL_SET
-#define USE_BATTERY
+#define FEATURE_BATTERY_LEVEL
+#endif
+
+#define xx(s) x(s)
+#define x(s) #s
+
+#ifdef PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET
+#define FEATURE_MODEL_NUMBER
+const char model_number[] = "Board type id: " xx(SM_BOARD_VERSION);
+#endif
+
+#ifdef PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET
+#define FEATURE_FIRMWARE_REVISION
+
+#ifdef FIRMWARE_REVISION
+const char firmware_revision[] = FIRMWARE_REVISION;
+#else
+const char firmware_revision[] = "Arduino: " __DATE__;
+#endif
+
+#endif // PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET
+
+#undef x
+#undef xx
+
+#ifdef USE_LOW_POWER
+static const bool use_low_power=1;
+#else
+static const bool use_low_power=0;
#endif
static void setup_rf();
@@ -51,12 +83,6 @@ void __ble_assert(const char *file, uint16_t line)
static void go_to_sleep();
-#ifdef USE_LOW_POWER
-static const bool use_low_power=1;
-#else
-static const bool use_low_power=0;
-#endif
-
void setup() {
#if defined(BLEND_MICRO_8MHZ)
// As the F_CPU = 8000000UL, the USB core make the PLLCSR = 0x02
@@ -162,6 +188,32 @@ static void aci_loop() {
delay(20); // Magic number used to make sure the HW error event is handled correctly.
}
else {
+#ifdef FEATURE_HARDWARE_REVISION
+ lib_aci_device_version();
+ debug.println(F("Requesting device version."));
+#endif
+
+#ifdef FEATURE_MODEL_NUMBER
+ debug.print(F("Model number: "));
+ debug.println(model_number);
+
+ size_t model_number_size = min(PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET_MAX_SIZE,
+ sizeof(model_number));
+ lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_MODEL_NUMBER_STRING_SET,
+ (uint8_t *) model_number, model_number_size);
+#endif
+
+
+#ifdef FEATURE_FIRMWARE_REVISION
+ debug.print(F("Firmware revision: "));
+ debug.println(firmware_revision);
+
+ size_t firmware_revision_size = min(PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET_MAX_SIZE,
+ sizeof(firmware_revision));
+ lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_FIRMWARE_REVISION_STRING_SET,
+ (uint8_t *) firmware_revision, firmware_revision_size);
+#endif
+
lib_aci_connect(180 /* in seconds */, 0x0050 /* advertising interval 50ms*/);
// lib_aci_broadcast(10/* in seconds */, 0x0100 /* advertising interval 100ms */);
// ret = lib_aci_open_adv_pipe(PIPE_BATTERY_BATTERY_LEVEL_BROADCAST);
@@ -194,13 +246,17 @@ static void aci_loop() {
// debug.print(F("Evt Cmd respone: Status "));
// debug.println(aci_evt->params.cmd_rsp.cmd_status, HEX);
}
+#ifdef FEATURE_HARDWARE_REVISION
if (aci_evt->params.cmd_rsp.cmd_opcode == ACI_CMD_GET_DEVICE_VERSION) {
+ debug.println(F("Got device version."));
//Store the version and configuration information of the nRF8001 in the Hardware Revision String Characteristic
- // lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET,
- // (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version),
- // sizeof(aci_evt_cmd_rsp_params_get_device_version_t));
+ lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET,
+ (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version),
+ sizeof(aci_evt_cmd_rsp_params_get_device_version_t));
}
-#ifdef USE_TEMPERATURE
+#endif // FEATURE_HARDWARE_REVISION
+
+#ifdef FEATURE_TEMPERATURE
if (aci_evt->params.cmd_rsp.cmd_opcode == ACI_CMD_GET_TEMPERATURE) {
debug.print(F("aci_evt->params.cmd_rsp.params.get_temperature="));
debug.print(aci_evt->params.cmd_rsp.params.get_temperature.temperature_value, DEC);
@@ -238,7 +294,7 @@ static void aci_loop() {
(uint8_t *) &temperature_measurement,
sizeof(temperature_measurement));
}
-#endif // USE_TEMPERATURE
+#endif // FEATURE_TEMPERATURE
break;
case ACI_EVT_CONNECTED:
@@ -248,11 +304,7 @@ static void aci_loop() {
debug.print(F("aci_state.data_credit_available="));
debug.println(aci_state.data_credit_available, DEC);
- // Get the device version of the nRF8001 and store it in the Hardware Revision String.
- // This will trigger a ACI_CMD_GET_DEVICE_VERSION.
- lib_aci_device_version();
-
-#ifdef USE_TEMPERATURE
+#ifdef FEATURE_TEMPERATURE
lib_aci_get_temperature();
#endif
sm_on_connect();
diff --git a/trygvisio_soil_moisture.xml b/trygvisio_soil_moisture.xml
index 196cfb4..35dd562 100644
--- a/trygvisio_soil_moisture.xml
+++ b/trygvisio_soil_moisture.xml
@@ -77,6 +77,98 @@
<PeriodForProperties/>
</Characteristic>
</Service>
+ <Service Type="local" PrimaryService="true">
+ <Name>Device Information</Name>
+ <Uuid>180a</Uuid>
+ <Characteristic>
+ <Name>Model Number String</Name>
+ <Uuid>2a24</Uuid>
+ <DefaultValue></DefaultValue>
+ <UsePresentationFormat>0</UsePresentationFormat>
+ <MaxDataLength>20</MaxDataLength>
+ <AttributeLenType>2</AttributeLenType>
+ <ForceOpen>false</ForceOpen>
+ <ForceEncryption>false</ForceEncryption>
+ <Properties>
+ <WriteWithoutResponse>false</WriteWithoutResponse>
+ <Write>false</Write>
+ <Notify>false</Notify>
+ <Indicate>false</Indicate>
+ <Broadcast>false</Broadcast>
+ </Properties>
+ <SetPipe>true</SetPipe>
+ <AckIsAuto>false</AckIsAuto>
+ <PresentationFormatDescriptor Value="0000" Exponent="0" Format="25" NameSpace="01" Unit="0000"/>
+ <PeriodForReadingThisCharacteristic>0</PeriodForReadingThisCharacteristic>
+ <PeriodForProperties/>
+ </Characteristic>
+ <Characteristic>
+ <Name>Hardware Revision String</Name>
+ <Uuid>2a27</Uuid>
+ <DefaultValue></DefaultValue>
+ <UsePresentationFormat>0</UsePresentationFormat>
+ <MaxDataLength>9</MaxDataLength>
+ <AttributeLenType>2</AttributeLenType>
+ <ForceOpen>false</ForceOpen>
+ <ForceEncryption>false</ForceEncryption>
+ <Properties>
+ <WriteWithoutResponse>false</WriteWithoutResponse>
+ <Write>false</Write>
+ <Notify>false</Notify>
+ <Indicate>false</Indicate>
+ <Broadcast>false</Broadcast>
+ </Properties>
+ <SetPipe>true</SetPipe>
+ <AckIsAuto>false</AckIsAuto>
+ <PresentationFormatDescriptor Value="0000" Exponent="0" Format="25" NameSpace="01" Unit="0000"/>
+ <PeriodForReadingThisCharacteristic>0</PeriodForReadingThisCharacteristic>
+ <PeriodForProperties/>
+ </Characteristic>
+ <Characteristic>
+ <Name>Firmware Revision String</Name>
+ <Uuid>2a26</Uuid>
+ <DefaultValue></DefaultValue>
+ <UsePresentationFormat>1</UsePresentationFormat>
+ <MaxDataLength>20</MaxDataLength>
+ <AttributeLenType>2</AttributeLenType>
+ <ForceOpen>false</ForceOpen>
+ <ForceEncryption>false</ForceEncryption>
+ <Properties>
+ <WriteWithoutResponse>false</WriteWithoutResponse>
+ <Write>false</Write>
+ <Notify>false</Notify>
+ <Indicate>false</Indicate>
+ <Broadcast>false</Broadcast>
+ </Properties>
+ <SetPipe>true</SetPipe>
+ <AckIsAuto>false</AckIsAuto>
+ <PresentationFormatDescriptor Value="0000" Exponent="0" Format="25" NameSpace="01" Unit="0000"/>
+ <PeriodForReadingThisCharacteristic>0</PeriodForReadingThisCharacteristic>
+ <PeriodForProperties/>
+ </Characteristic>
+ <Characteristic>
+ <Name>Manufacturer Name String</Name>
+ <Uuid>2a29</Uuid>
+ <DefaultValue>Trygvis IO</DefaultValue>
+ <UsePresentationFormat>1</UsePresentationFormat>
+ <MaxDataLength>10</MaxDataLength>
+ <AttributeLenType>1</AttributeLenType>
+ <ForceOpen>false</ForceOpen>
+ <ForceEncryption>false</ForceEncryption>
+ <Properties>
+ <WriteWithoutResponse>false</WriteWithoutResponse>
+ <Write>false</Write>
+ <Notify>false</Notify>
+ <Indicate>false</Indicate>
+ <Broadcast>false</Broadcast>
+ </Properties>
+ <SetPipe>false</SetPipe>
+ <AckIsAuto>false</AckIsAuto>
+ <PresentationFormatDescriptor Value="0000" Exponent="0" Format="25" NameSpace="01" Unit="0000"/>
+ <PeriodForReadingThisCharacteristic>0</PeriodForReadingThisCharacteristic>
+ <PeriodForProperties/>
+ </Characteristic>
+ </Service>
<Gapsettings>
<Name>Woot</Name>
<DeviceNameWriteLength>10</DeviceNameWriteLength>
diff --git a/ublue_setup.gen.out.txt b/ublue_setup.gen.out.txt
index dffc2b2..4852b30 100644
--- a/ublue_setup.gen.out.txt
+++ b/ublue_setup.gen.out.txt
@@ -1,28 +1,28 @@
------------------------------------------------------------------------------
uBlue Setup generation report
Generated with uBlue setup DLL version: 1.0.0.16903
- Generated: Sun Jul 26 15:48:26 2015 (UTC)
+ Generated: Sun Jul 26 20:14:17 2015 (UTC)
This file is automatically generated, do not modify
------------------------------------------------------------------------------
[Counts]
-Setup data size = 520 bytes
-Local database size = 279 bytes
-Local attribute count = 4
+Setup data size = 785 bytes
+Local database size = 473 bytes
+Local attribute count = 7
Remote attribute count = 0
-Total pipe count = 7
-Dynamic data size = 166 bytes (worst case)
+Total pipe count = 10
+Dynamic data size = 226 bytes (worst case)
[Setup Area Layout]
Setup area, total = 1595 bytes
-Setup area, used = 347 bytes ( 21% of total )
-Local services = 279 bytes ( 80% of used )
+Setup area, used = 580 bytes ( 36% of total )
+Local services = 473 bytes ( 81% of used )
Remote services = 0 bytes ( 0% of used )
-Pipes = 40 bytes ( 11% of used )
-VS UUID area = 16 bytes ( 4% of used )
-Extended Attr area = 12 bytes ( 3% of used )
+Pipes = 70 bytes ( 12% of used )
+VS UUID area = 16 bytes ( 2% of used )
+Extended Attr area = 21 bytes ( 3% of used )
[Device Settings]
@@ -78,6 +78,17 @@ Handle Pipes Structure
0x0010 |----- |Characteristic: "?" (01:0x2A1E) [rd|not] [rd:allow|wr:none]
0x0011 x> |Value: {0x00 0x00 0x00 0x00 0x00} [rd:allow|wr:none]
0x0012 |----- |Descriptor: "Client Characteristic Configuration" (01:0x2902) Value: {0x00 0x00} [rd:allow|wr:allow]
+0x0013 +----- Service (Primary): "Device Info" (01:0x180A)
+0x0014 |----- |Characteristic: "Model Num" (01:0x2A24) [rd] [rd:allow|wr:none]
+0x0015 x |Value: {} [rd:allow|wr:none]
+0x0016 |----- |Characteristic: "HW Rev" (01:0x2A27) [rd] [rd:allow|wr:none]
+0x0017 x |Value: {} [rd:allow|wr:none]
+0x0018 |----- |Characteristic: "FW Rev" (01:0x2A26) [rd] [rd:allow|wr:none]
+0x0019 x |Value: {} [rd:allow|wr:none]
+0x001A |----- |Descriptor: "Characteristic Format" (01:0x2904) Value: {0x19 0x00 0x00 0x00 0x01 0x00 0x00} [rd:allow|wr:none]
+0x001B |----- |Characteristic: "Manu. Name" (01:0x2A29) [rd] [rd:allow|wr:none]
+0x001C |Value: {0x54 0x72 0x79 0x67 0x76 0x69 0x73 0x20 0x49 0x4F} [rd:allow|wr:none]
+0x001D |----- |Descriptor: "Characteristic Format" (01:0x2904) Value: {0x19 0x00 0x00 0x00 0x01 0x00 0x00} [rd:allow|wr:none]
[Remote Database]
@@ -95,11 +106,14 @@ Pipe Store Type Service Char. CPF Desc.
05 Local RX_AA 02:0x0010 02:0x0011 -- --
06 Local TX 02:0x0010 01:0x2A1E -- --
07 Local SET 02:0x0010 01:0x2A1E -- --
+08 Local SET 01:0x180A 01:0x2A24 -- --
+09 Local SET 01:0x180A 01:0x2A27 -- --
+10 Local SET 01:0x180A 01:0x2A26 -- --
[Setup Data]
07-06-00-00-03-02-42-07
-1F-06-10-00-00-00-00-00-00-00-04-00-07-01-01-00-00-06-00-01-D1-0F-18-00-00-00-00-00-00-00-00-00
+1F-06-10-00-00-00-00-00-00-00-07-00-0A-01-01-00-00-06-00-01-91-0F-18-00-00-00-00-00-00-00-00-00
1F-06-10-1C-10-02-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-50-03-90-01-FF
1F-06-10-38-FF-FF-02-58-0A-05-00-00-00-00-00-00-00-10-00-00-00-00-00-00-00-00-00-00-00-00-00-00
05-06-10-54-00-00
@@ -112,9 +126,17 @@ Pipe Store Type Service Char. CPF Desc.
1F-06-20-A8-00-D0-32-04-04-13-13-00-0D-28-03-01-1A-0E-00-3F-D8-1F-4A-8E-BC-D3-70-C5-59-5D-03-11
1F-06-20-C4-00-D0-32-54-14-14-00-00-0E-00-11-02-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
1F-06-20-E0-00-00-00-00-46-14-03-02-00-0F-29-02-01-00-00-04-04-05-05-00-10-28-03-01-12-11-00-1E
-1E-06-20-FC-2A-16-04-06-05-00-11-2A-1E-01-00-00-00-00-00-46-14-03-02-00-12-29-02-01-00-00-00
+1F-06-20-FC-2A-16-04-06-05-00-11-2A-1E-01-00-00-00-00-00-46-14-03-02-00-12-29-02-01-00-00-04-04
+1F-06-21-18-02-02-00-13-28-00-01-0A-18-04-04-05-05-00-14-28-03-01-02-15-00-24-2A-04-04-14-00-00
+1F-06-21-34-15-2A-24-01-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-04-04-05-05
+1F-06-21-50-00-16-28-03-01-02-17-00-27-2A-04-04-09-00-00-17-2A-27-01-00-00-00-00-00-00-00-00-00
+1F-06-21-6C-04-04-05-05-00-18-28-03-01-02-19-00-26-2A-04-04-14-00-00-19-2A-26-01-00-00-00-00-00
+1F-06-21-88-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-06-04-08-07-00-1A-29-04-01-19-00-00-00
+1F-06-21-A4-01-00-00-04-04-05-05-00-1B-28-03-01-02-1C-00-29-2A-06-04-0B-0A-00-1C-2A-29-01-54-72
+1C-06-21-C0-79-67-76-69-73-20-49-4F-06-04-08-07-00-1D-29-04-01-19-00-00-00-01-00-00-00
1F-06-40-00-2A-00-01-00-80-04-00-03-00-00-2A-19-01-00-80-04-00-0B-00-00-00-11-02-04-82-04-00-0E
-0F-06-40-1C-00-0F-2A-1E-01-00-82-04-00-11-00-12
+1F-06-40-1C-00-0F-2A-1E-01-00-82-04-00-11-00-12-2A-24-01-00-80-04-00-15-00-00-2A-27-01-00-80-04
+11-06-40-38-00-17-00-00-2A-26-01-00-80-04-00-19-00-00
13-06-50-00-3F-D8-1F-4A-8E-BC-D3-70-C5-59-5D-03-00-00-D0-32
-0F-06-60-00-00-00-00-00-00-00-00-00-00-00-00-00
-06-06-F0-00-83-26-AA
+18-06-60-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
+06-06-F0-00-83-8C-E1