Comments (4)
As far as I can see, it is always fixed to 4 bytes, big endian.
When using a array variable you can have different number of bytes, e.g. use DIM A(1) for a 1 byte characteristic.
from bluebasic.
I tried to use arrays:
GATT READ DIM A(1) ONREAD GOSUB 300
But can't run the code, it exits with Error
Syntax seems to be incorrect.
from bluebasic.
@0xFACE try to using the below code. Your syntax is indeed wrong, you cannot use DIM A(1) inside the GATT command. DIM A(1) must be outside.
A running idle loop keeps the DIM A(1) alive. If the basic program terminates, it falls back to Int32 type and you get the 4 bytes by reading. You can also not declare DIM A(1) in the GOSUB area, since this would hide the instance variable which gets accessed by GATT.
Another thing I observed is, that the DIM variable gets lost for GATT when you use a DELAY instruction during GATT access in the GOSUB section. Sometimes an "DELAY 1" is required in interactive sessions, to give control back to the BLE stack in order not to loose the console connection. But this is only the case when you execute longer tasks in the BASIC program. For GATT access I try to avoid this, by e.g. using a TIMER to shift some processing outside the GATT access (see e.g. line 400 below).
-Kai
NEW
10 DIM A(1)
// setup advertsing
20 ADVERT GENERAL
30 ADVERT "105a84de-40bd-428b-bf06-698e5e422cd9"
40 ADVERT END
50 SCAN NAME "oneByteDemo"
60 SCAN END
// setup GATT profile
100 GATT SERVICE "105a84de-40bd-428b-bf06-698e5e422cd9" ONCONNECT GOSUB 400
110 GATT CHARACTERISTIC "00d8a2c6-65f3-40c2-a342-b4e5126f45f0" "sec"
120 GATT READ WRITE A ONREAD GOSUB 300
130 GATT END
150 TIMER 0, 1000 REPEAT GOSUB 1000
// Idle loop keeping DIM A(1) alive
200 DELAY 10000
210 GOTO 200
// GATT read A
300 A(0) = T % 60
310 RETURN
// GATT Service on connect
400 TIMER 1, 2000 GOSUB 500
410 RETURN
// welcome
500 PRINT "Hello World!"
510 RETURN
// time tick
1000 T = T + 1
1010 RETURN
// this last return seems to be required
65529 RETURN
AUTORUN ON
END
REBOOT
from bluebasic.
Wow, great.
Idle loop did the trick.
Thanks a lot ;-)
from bluebasic.
Related Issues (20)
- Accessing pin 14/15 on 2541 HOT 1
- How to compile CC2540 version? HOT 1
- Using TI serial bootloader for BlueBasic HOT 4
- How to connect do fresh flashed device ? HOT 7
- loading BlueBasic using this method possible? HOT 6
- No console on appstore :( HOT 1
- Wiki typo on "Pin names and uses" HOT 4
- How to use ADC? HOT 1
- How to use SCAN ? HOT 2
- A witten program, can it be saved to create a permanently configured device? HOT 1
- Question - Can a basic program be saved and survive a power off HOT 3
- BlueBasic console for linux HOT 1
- compiler instructions for HM10, cc2541, want to upload blestack 1.4.2.2 updated hex files? HOT 3
- how to load basic programs on the chip? HOT 10
- OSX 10.12 Sierra fails HOT 6
- Large numbers > 536870912 (1<<29) are wrongly computed HOT 1
- Writing Array fails HOT 10
- Flashstore gets corrupted and programs gets garbled
- UPGRADE AVAILBLE message in console status
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bluebasic.