Commit bfc9bdbd authored by Klint Youngmeyer's avatar Klint Youngmeyer

Add firmware version get function

parent 3ec5678c
Pipeline #19 failed with stages
......@@ -722,6 +722,37 @@ STATIC mp_obj_t rs9116_macaddr(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(rs9116_macaddr_obj, rs9116_macaddr);
STATIC mp_obj_t rs9116_get_fw_version(mp_obj_t self_in) {
int status;
uint8_t buf[10] = {0};
uint16_t str_len = 0;
status = rsi_wlan_scan(NULL, 0, NULL, 0); // Stupid Hack:
// Needed to 'turn on' the module after init. Returns without doing
// anything if connected to a network.
status = rsi_wlan_get(RSI_FW_VERSION, buf, 10);
if(status != RSI_SUCCESS)
{
#ifdef RSI_ENABLE_DEBUG_PRINT
printf("Error: 0x%04x\n", status);
#endif
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "error getting FW Version\n"));
}
// buf[] is too long, but version string varies in length
// values are returned in ascii
for (int i = 0; i < 10; i++) {
if (buf[i] == 0) {
break;
}
str_len++;
}
return mp_obj_new_str((char *)buf, str_len);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(rs9116_get_fw_version_obj, rs9116_get_fw_version);
STATIC mp_obj_t rs9116_scan(mp_obj_t self_in) {
int32_t status;
mp_obj_t list = mp_obj_new_list(0, NULL);
......@@ -2136,6 +2167,7 @@ STATIC const mp_map_elem_t rs9116_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep), (mp_obj_t)&rs9116_sleep_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_scan), (mp_obj_t)&rs9116_scan_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_macaddr), (mp_obj_t)&rs9116_macaddr_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_fw_version), (mp_obj_t)&rs9116_get_fw_version_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_add_service), (mp_obj_t)&rs9116bt_add_new_service_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_add_attribute), (mp_obj_t)&rs9116bt_add_new_attr_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_start_scanning), (mp_obj_t)&rs9116bt_start_scanning_obj },
......@@ -2242,4 +2274,4 @@ void stations_connect_notify_handler(uint16_t status, uint8_t *buffer, const uin
void stations_disconnect_notify_handler(uint16_t status, uint8_t *buffer, const uint32_t length)
{
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment