Coder Social home page Coder Social logo

aanon4 / bluebasic Goto Github PK

View Code? Open in Web Editor NEW
96.0 18.0 55.0 17.34 MB

BASIC interpreter for CC2540 and CC2541 Bluetooth LE chips

Home Page: https://gitlab.com/timwilkinson/BlueBasic

C++ 6.05% C 91.99% Shell 0.04% Assembly 0.01% JavaScript 0.15% Swift 1.49% Batchfile 0.17% Objective-C 0.11%

bluebasic's Introduction

BlueBasic

NOTE: I no longer have access to either hardware or tools to update the builds.

ALSO NOTE: This project has moved to https://gitlab.com/timwilkinson/BlueBasic

BASIC interpreter for CC2540 and CC2541 Bluetooth LE chips.

This project contains a BASIC interpreter which can be flashed onto a CC2540 or CC2541 Bluetooth module. Once installed, simple use the Bluetooth Console tool to connect and start coding on the device using good old BASIC.

The project was inspired by experimenting with the HM-10 modules (a cheap BLE module) and a need to provide an easy way to prototype ideas (rather than coding in C using the very expensive IAR compiler). Hopefully other will find this useful.

For more information see https://github.com/aanon4/BlueBasic/wiki/Blue-Basic:-An-Introduction

bluebasic's People

Contributors

aanon4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bluebasic's Issues

loading BlueBasic using this method possible?

Hi excellent project, have been trying to load BlueBasic to a module for a couple of hours today.
this is the method I'm using https://github.com/RedBearLab/CCLoader

uses an arduino to act as a programmer.
The module I am trying to update is a ble-cc41-a, which has a cc2541 on it.

I was trying using the bin file for the cc2541 chip from you repo.
it appears to flash ok, but cannot see any devices in the console.

Is the .bin from this repo comptable do you think?
Is there are way to check that code is running, debug output from module on serial ?

thanks in advance

How do I install this?

May be a stupid question but I would love to install and use this!

I have cloned the project but am not sure how to install or what to install...

Writing Array fails

Hello,

I understand that this repro is kind of "dead" since Tim has left the project. However this is the only place to "hope" for exchange of experience... maybe someone is reading here.

Writing an array to a file works, however after the write command the execution stalls.
Here is my program list

10 OPEN 0, READ "A"
15 FOR I = 1 TO 10
20  READ #0, B
30  PRINT I,",",B
40 NEXT I
60 RETURN 
100 OPEN 0, TRUNCATE "A"
110 DIM U(10)
120 WRITE #0, U
140 CLOSE 0
150 RETURN 

goto 100
Bad expression
>> 140 CLOSE 0

I can read the file successfully by walking to its elements via:

run
1,0
2,0
3,0
4,0
5,0
6,0
7,0
8,0
9,0
10,0
OK

The issue I am fighting is that I wanted to implement an IoT data logger for solar cells mounted on the camping car. Therefore I need a way to store and access some historic values. Doing by writing single vars wastes a lot of memory, e.g. each var occupies 8 bytes (examine the reported memory). So I was looking to write an array instead. It looks like that each array element consumes 1 byte.

I have tried to write different array sizes since I suspected an alignment requirements, but this fails, too. I tried array sizes of 1, 2, 3, 4, 5, 8, 16. Also I checked different file name "A" or "F".

Is there anybody out there that have successfully used these functions?

Thanks
Kai

How to connect do fresh flashed device ?

Hello, I successfully flashed BLE HM-10 module with BlueBasic-CC2541.hex file.
But now I don't how to connect.
I tried to scan for the BLE devices, but HM-10 module is not advertising any more.
Is it ok ? Can I use RX/TX pins to connect console?

Unfortunately I don't have IOS/ OSX device to use the BlueBasicConsole from your repo.

Blue Basic IOS not connecting

hi tim, now i had the chance to test with an ipad (ios 8)
The HM-10 (in fact this seems to be a copycat - according to the HM-10 pdf) shows up as BASIC@DC, but no connection can be made - Connecting ... and nothing more ...
I used the BLE Packet Sniffer from TI (with the USB Dongle) to get a better idea whats happening.
Unfortunately i do not have an IAR EW (puh - the price is tough stuff) to try to debug the code itself...
But may be you can read somethin out of the BLE Sniffer Log...
up to [4] is the scan - the rest is the quick connection - disconnection ...

[1] : <Tx> - 10:25:57.023
-Type       : 0x01 (Command)
-Opcode     : 0xFE04 (GAP_DeviceDiscoveryRequest)
-Data Length    : 0x03 (3) byte(s)
 Mode       : 0x03 (All)
 ActiveScan : 0x01 (Enable)
 WhiteList      : 0x00 (Disable)
Dump(Tx):
01 04 FE 03 03 01 00 
------------------------------------------------------------------------------------------------------------------------
[2] : <Rx> - 10:25:57.038
-Type       : 0x04 (Event)
-EventCode  : 0xFF (HCI_LE_ExtEvent)
-Data Length    : 0x06 (6) bytes(s)
 Event      : 0x067F (GAP_HCI_ExtentionCommandStatus)
 Status     : 0x00 (Success)
 OpCode     : 0xFE04 (GAP_DeviceDiscoveryRequest)
 DataLength : 0x00 (0)
Dump(Rx):
04 FF 06 7F 06 00 04 FE 00 
------------------------------------------------------------------------------------------------------------------------
[3] : <Rx> - 10:25:57.647
-Type       : 0x04 (Event)
-EventCode  : 0xFF (HCI_LE_ExtEvent)
-Data Length    : 0x2C (44) bytes(s)
 Event      : 0x060D (GAP_DeviceInformation)
 Status     : 0x00 (Success)
 EventType  : 0x00 (Connectable Undirect Advertisement)
 AddrType   : 0x00 (Public)
 Addr       : 7C:66:9D:9A:72:DC
 Rssi       : 0xC5 (197)
 DataLength : 0x1F (31)
 Data       : 02:01:05:11:06:3A:A7:BD:64:0A:F7:A3:B5:8D:44:16:
          16:91:9E:FB:25:09:09:42:41:53:49:43:23:44:43
Dump(Rx):
04 FF 2C 0D 06 00 00 00 DC 72 9A 9D 66 7C C5 1F 
02 01 05 11 06 3A A7 BD 64 0A F7 A3 B5 8D 44 16 
16 91 9E FB 25 09 09 42 41 53 49 43 23 44 43 
------------------------------------------------------------------------------------------------------------------------
[4] : <Rx> - 10:26:07.303
-Type       : 0x04 (Event)
-EventCode  : 0xFF (HCI_LE_ExtEvent)
-Data Length    : 0x0C (12) bytes(s)
 Event      : 0x0601 (GAP_DeviceDiscoveryDone)
 Status     : 0x00 (Success)
 NumDevs    : 0x01 (1)
 Device #0
 EventType  : 0x00 (Connectable Undirect Advertisement)
 AddrType   : 0x00 (Public)
 Addr       : 7C:66:9D:9A:72:DC
Dump(Rx):
04 FF 0C 01 06 00 01 00 00 DC 72 9A 9D 66 7C 
------------------------------------------------------------------------------------------------------------------------
[5] : <Tx> - 10:26:12.575
-Type       : 0x01 (Command)
-Opcode     : 0xFE09 (GAP_EstablishLinkRequest)
-Data Length    : 0x09 (9) byte(s)
 HighDutyCycle  : 0x00 (Disable)
 WhiteList      : 0x00 (Disable)
 AddrTypePeer   : 0x00 (Public)
 PeerAddr       : DC:72:9A:9D:66:7C
Dump(Tx):
01 09 FE 09 00 00 00 DC 72 9A 9D 66 7C 
------------------------------------------------------------------------------------------------------------------------
[6] : <Rx> - 10:26:12.607
-Type       : 0x04 (Event)
-EventCode  : 0xFF (HCI_LE_ExtEvent)
-Data Length    : 0x06 (6) bytes(s)
 Event      : 0x067F (GAP_HCI_ExtentionCommandStatus)
 Status     : 0x00 (Success)
 OpCode     : 0xFE09 (GAP_EstablishLinkRequest)
 DataLength : 0x00 (0)
Dump(Rx):
04 FF 06 7F 06 00 09 FE 00 
------------------------------------------------------------------------------------------------------------------------
[7] : <Info> - 10:26:13.387
Device Connected
Handle = 0x0000
Addr Type = 0x00 (Public)
BDAddr = 7C:66:9D:9A:72:DC
------------------------------------------------------------------------------------------------------------------------
[8] : <Rx> - 10:26:13.387
-Type       : 0x04 (Event)
-EventCode  : 0xFF (HCI_LE_ExtEvent)
-Data Length    : 0x13 (19) bytes(s)
 Event      : 0x0605 (GAP_EstablishLink)
 Status     : 0x00 (Success)
 DevAddrType    : 0x00 (Public)
 DevAddr        : 7C:66:9D:9A:72:DC
 ConnHandle : 0x0000 (0)
 ConnInterval   : 0x0050 (80)
 ConnLatency    : 0x0000 (0)
 ConnTimeout    : 0x07D0 (2000)
 ClockAccuracy  : 0x00 (0)
Dump(Rx):
04 FF 13 05 06 00 00 DC 72 9A 9D 66 7C 00 00 50 
00 00 00 D0 07 00 
------------------------------------------------------------------------------------------------------------------------
[9] : <Info> - 10:26:13.932
Device Disconnected
Handle = 0x0000
Addr Type = 0x00 (Public)
BDAddr = 7C:66:9D:9A:72:DC
------------------------------------------------------------------------------------------------------------------------
[10] : <Rx> - 10:26:13.932
-Type       : 0x04 (Event)
-EventCode  : 0xFF (HCI_LE_ExtEvent)
-Data Length    : 0x06 (6) bytes(s)
 Event      : 0x0606 (GAP_TerminateLink)
 Status     : 0x00 (Success)
 ConnHandle : 0x0000 (0)
 Reason     : 0x3E (Failed To Establish)
Dump(Rx):
04 FF 06 06 06 00 00 00 3E 
------------------------------------------------------------------------------------------------------------------------

Upgradable

When connecting to the Beacon now I get a "Upgradable" in the bottom console window where it would normally say "Connected".

Steps:

  1. Built a new beacon
  2. Downloaded the latest Hex file from the repo (Flashed it to the 2540)
  3. Opened BasicBlue clicked on the new beacon. (Getting Upgradable and not Connected)

I am able to connect to another beacon i built and flashed with the hex file (was flashed a few weeks ago).

Set Major Minor (iBeacon)

Hello,
I am trying to set the Major and Minor values using the iBeacon example but am running into an issue.

The values in the example are (work just fine):

M(0) = 0
M(1) = 1

I am trying to set:

M(0) = 0x11
M(1) = 0x59D8

I am able to program the chip and it comes back with "OK" but the values are not set along... I am using hex values should i be doing something different?

Run basic code after reboot ?

Is is possible to run basic code after reboot?

BlueBasic support upload basic file, so if BlueBasic can load and run basic file after started
(say init.bbasic), it should work.

Setting the advertisement interval after reboot?

Hi all,

I'm trying to set up a low power consumption beacon with the following code:

1 T= 3200
2 CONFIG POWER, 1
3 BTPOKE LIM_DISC_ADV_INT_MIN, T
4 BTPOKE LIM_DISC_ADV_INT_MAX, T
5 BTPOKE GEN_DISC_ADV_INT_MIN, T
6 BTPOKE GEN_DISC_ADV_INT_MAX, T
7 PINMODE P0(4) INPUT PULLDOWN
10 // "A Simple iBeacon service"
20 DIM M(5)
30 // "Major (0-65535), Minor (0-65535), Power"
40 M = 0x00, 0x02, 0x00, 0x04, 0xC8
90 ADVERT GENERAL
100 ADVERT CUSTOM "FF 4C 00 02 15" "74 27 8B DA B6 44 45 20 8F 0C 72 0E AF 05 99 35" M
110 ADVERT END
120 // SET A NAME IN THE SCAN RESPONSE
130 SCAN NAME "iBeacon"
140 SCAN END
150 AUTORUN ON

The problem i'm having is that the part of the code that sets the advertisement interval (line 1 to 6) does not work after a reboot or battery swap. The ibeacon advertisement settings are set up properly as does the led, so the script must have run on boot.

The advertisement interval lines do work when connecting and then typing RUN in the console. On another device, I check the advertisements, and they come in every 2 seconds. The strange thing is though, if I disconnect the console, the advertisements stop. The only way to make the device visible again is taking out the battery, and reinsert it. Unfortunately, the advertisement interval is then back to the fast mode it boots up with.

I think the issue all boils down to: how to make the advertisement interval non volatile?

BlueBasic console for linux

Hello,
I started developing BlueBasic console for Linux. It still looks like dirty hack ( unfortunately I'm not C hacker), but at least works for me.
Here is the code: https://github.com/0xFACE/bbconsole
This is not the issue, but rather an invitation for users who like BlueBasic project ;-)

Thanks.

UPGRADE AVAILBLE message in console status

What does UPGRADE AVAILBLE means in console status at bottom ?

the place where you have CONNECTED , CONNECTING..

and one last question, how to broadcast the battery level in iBeakon mode ?

Serial/UART handshaking

Love BlueBasic! Thanks!!!!

Right now, BlueBasic only support hardware handshaking
SERIAL 9600,N,8,1,H

This will give error:
SERIAL 9600,N,8,1,N

Here are the codes in OS_serial_open function (os.c ) :
// Only support port 0, no-parity, 8-bits, 1 stop bit
if (port != 0 || parity != 'N' || bits != 8 || stop != 1 || flow != 'H')
{
return 3;
}

Example on how to read from BLE slave?

Is it possible to add a simple example on how to read data from a BlueTooth BLE slave?

I was trying to use BlueBasic to read data from SensorTag, but only able to discover the device, not able to figure out how to read data from SensorTag.

Thanks a lot!

Large numbers > 536870912 (1<<29) are wrongly computed

Large numbers result in wrong values, e.g.

PRINT 1<<29
536870912
OK
PRINT 1<<29+1
761419044
OK

In some circumstances this crashes the system. One example is the millis() function:

CONFIG MILLIS, 1<<31
OK
PRINT MILLIS()
... system not responding anymore

This means when using millis() the time counter gets corrupted during day 373 (after 536870912 ms). This might be an issue for IoT applications running extend periods of time and using millis() for time reference.

OSX 10.12 Sierra fails

BlueBasic under OSX Sierra fails:

  • after connecting File/Load to device doesn't show file selector
  • pasting code to the console fails to complete

xcode 8.1 doesn't support Swift 1.2 anymore. In an attempt to fix the above issue, I imported the project to Xcode 8.1 and converted it to Swift 3. Then I fixed the upload issue by reducing the upload data chunks from 64 down to 20 bytes.

See fork here:
kscheff@6de2ee0

Accessing pin 14/15 on 2541

I'm trying to use BlueBasic on an existing device with I2C peripherals. Looks like they used the hardware I2C on pins 14/15. Possible to access these as general I/O pins ?

Advertising interval

Hello again! I have been using BlueBasic for a few days now and love it so thank you for making it!!

I am looking to set the Advertising interval on the iBeacon example but i am not 100% sure how to change that... Is this something you have built in? Any examples would be much appreciated!

Flashstore gets corrupted and programs gets garbled

When writing files and program code the memory becomes eventually low. BlueBasic then tries to free up some memory by compacting the flash store. However this function is seriously broken and it messes up the flash store. Typically this destroys parts of the stored program. In some cases this locks the entire device, so you can only recover by CC-Debugger.

This bug gets triggered when the flash store_compact() routine gets called.
I have fixed the bug here kscheff@d202a8f

How to use SCAN ?

Thank you very much for BlueBasic!

How to use SCAN ? I only see use SCAN to set SCAN response in iBeacon example.

How about SCAN GENERAL|LIMITED ? SCAN "" ?

Can I use SCAN to list other BLE devices nearby ?

Beacon dies after 48 hours?

Have you seen any issues with the beacon running the iBeacon example then dyeing after about 48 hours?

I have 8+ beacons that all died at about the same time (within two hours of each other). The fix was to take the battery out and then place it back in.

Note: All beacons had been programmed within two hours of each other.

How to compile CC2540 version?

Hi.

Thanks for really awesome project!

By the way, I want to customize BlueBasic with myself.

So, I downloaded Project files and open it with IAR.

I opened the project file in BlueBasic/Build.

And compiled it for 'CC2540'.

But, the hex what I created doesn't work at all.

When I flashed the hex what you provided , it works like charm.

But, the hex I compiled doesn't work.

Are there any specific options or process for compiling CC2540 version hex?

(What I want to do is adding PWM function in BlueBasic.

Because I coudn't find how to make PWM pulse currently. )

Thank you.

How to use ADC?

Thanks for creating BlueBasic.

How to use ADC? I looked every page in the Wiki and could not find it.

Thanks again!

Unable to use P2_1 through P2_4 for output

When I try to use P2_1 and later for output, get the message "Bad pin". Transcript of session below.

Thanks for creating this, I'm very excited!

BlueBasic CC2541/20150213105740/OAD v0.6
http://blog.xojs.org/bluebasic
7856 bytes free.
OK
PINMODE P2(0) OUTPUT
OK
P2(0) = 1
OK
PINMODE P2(1) OUTPUT
Bad pin
P2(1) = 1
Bad pin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.