Skip to content

Commit

Permalink
Merge pull request #53 from ps2/dev
Browse files Browse the repository at this point in the history
Version 2.0
  • Loading branch information
ps2 authored Jun 8, 2018
2 parents ecc891b + f1dd01c commit f4df313
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion firmware/ble113_rfspy/gatt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<characteristic uuid="30d99dc9-7c91-4295-a051-0a104d238cf2">
<description>Version</description>
<properties read="true" const="true"/>
<value>ble_rfspy 0.9</value>
<value>ble_rfspy 2.0</value>
</characteristic>
<characteristic uuid="c6d84241-f1a7-4f9c-a25f-fce16732f14e" id="xgatt_led_mode">
<description>LED Mode</description>
Expand Down
14 changes: 11 additions & 3 deletions firmware/ble113_rfspy/main.bgs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dim spi_out_buf_len
# 1 = waiting for ble client to read bytes from data attr.
# We halt spi comms until this happens. Crude flow control.
dim waiting_for_client
dim connected
dim slave_bytes_avail
dim spi_xfer_size
dim spi_batch_size
Expand Down Expand Up @@ -94,6 +95,10 @@ procedure set_led_mode(value)
end

procedure do_spi()
if in_spi = 1 then
return
end if

in_spi = 1
call hardware_io_port_write(0, $10, 0)

Expand Down Expand Up @@ -153,13 +158,14 @@ event attributes_value(connection, reason, handle, offset, value_len, value_data
if handle = xgatt_data then
if offset = 0 then
expected_length = value_data(0:1) + 1
waiting_for_client = 0
end if
spi_out_buf(offset:value_len) = value_data(0:value_len)

# Write to SPI if finished
if offset + value_len = expected_length then
spi_out_buf_len = expected_length
if waiting_for_client != 1 && in_spi = 0
if waiting_for_client != 1
call do_spi()
end if
end if
Expand Down Expand Up @@ -200,9 +206,9 @@ event attributes_user_read_request(connection, handle, offset, maxsize)

if waiting_for_client = 0
call set_data_led(0)
call do_spi()
end if


end if

if handle = xgatt_led_mode then
Expand Down Expand Up @@ -240,7 +246,7 @@ end

# Timer event listener to poll data from spi
event hardware_soft_timer(handle)
if waiting_for_client != 1 && in_spi = 0
if waiting_for_client != 1 && connected = 1 then
call do_spi()
end if

Expand All @@ -258,6 +264,7 @@ end
event connection_status(connection, flags, address, address_type, conn_interval, timeout, latency, bonding)
# Device is connected. Turn on green led
call hardware_io_port_write(0, $1, $1)
connected = 1

# Drop any data what was waiting to go to client from
# previous connection.
Expand All @@ -272,6 +279,7 @@ event connection_disconnected(handle,res)
call gap_set_mode(gap_general_discoverable,gap_undirected_connectable)
# Device disconnected. Turn off green led
call hardware_io_port_write(0, $1, $0)
connected = 0

# Save name
if name_len > 0
Expand Down
49 changes: 25 additions & 24 deletions firmware/ble113_rfspy/variable_memory_usage.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
644
648
0:0 GAP_AD_FLAG_BREDR_NOT_SUPPORTED
0:0 GAP_AD_FLAG_GENERAL_DISCOVERABLE
0:0 GAP_AD_FLAG_LIMITED_DISCOVERABLE
Expand Down Expand Up @@ -89,26 +89,27 @@
261:255 spi_out_buf
516:4 spi_out_buf_len
520:4 waiting_for_client
524:4 slave_bytes_avail
528:4 spi_xfer_size
532:4 spi_batch_size
536:4 spi_batch_offset
540:32 name
572:4 name_len
576:4 result
580:4 channel
584:4 continue
588:4 escaping
592:4 bytes_to_send
596:4 tlen
600:4 idx
604:4 response_count
608:4 expected_length
612:4 send_idx
616:4 chunk_size
620:4 in_spi
624:4 timer_tick_count
628:4 timer_update_count
632:4 led_mode
636:4 batconn_handle
640:4 batresult
524:4 connected
528:4 slave_bytes_avail
532:4 spi_xfer_size
536:4 spi_batch_size
540:4 spi_batch_offset
544:32 name
576:4 name_len
580:4 result
584:4 channel
588:4 continue
592:4 escaping
596:4 bytes_to_send
600:4 tlen
604:4 idx
608:4 response_count
612:4 expected_length
616:4 send_idx
620:4 chunk_size
624:4 in_spi
628:4 timer_tick_count
632:4 timer_update_count
636:4 led_mode
640:4 batconn_handle
644:4 batresult

0 comments on commit f4df313

Please sign in to comment.