0

I'm using the BGScript for Bluetooth program. BGScript provides H/W interrupt listener API. The listener API name is hardware_io_port_status(delta, port, irq, state)

What I want to see the value are irq and state. BGScript can display value by using the SPI interface. The API interface is hardware_spi_transfer(channel, data_len, value_data)

I can display a string value like this

call hardware_spi_transfer(0,15,"Button 0       ") # OK

call hardware_spi_transfer(0,15,state) # NG Build Error

According to API Reference, I have to set the uint8array formatted value as the value_data. But I have no idea about converting from unit to unit8array.

API Reference

http://ezoelectro.narod.ru/doc-pdf/ble112/BLE_Stack_API_reference_v2.2.pdf

Can you help me? Thanks.

zono
  • 8,366
  • 21
  • 75
  • 113

1 Answers1

0

Isn't the problem that in your SPI call you set the length to 15 while you only want to send 1 byte?

call hardware_spi_transfer(0, 1, state)

If that does not work, try something like this, to explicitly save the state into a buffer variable:

dim state dim buf(1) call hardware_io_port_status(delta, port, irq, state) buf(0:1) = state call hardware_spi_transfer(0, 1, buf(0:1))

in the above replace delta, port, irq with your values.

stathisv
  • 489
  • 2
  • 7
  • In addition to this post: I might be wrong, but watch out for the outgoing format. In your first call you are propably using the ASCII format! So if the state is "1" you maybe don't get an 1 on your display in return. – Steckdoserich May 29 '15 at 10:14